From cad140b7526000563d91487a5c845de75e027730 Mon Sep 17 00:00:00 2001 From: itsscb Date: Sat, 26 Jul 2025 21:09:14 +0200 Subject: [PATCH] feat: de-emphasize main screen on edit --- src/lib.rs | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f14ca89..e89e530 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,8 +25,10 @@ pub mod log; pub static APP_NAME: &str = "lw"; static CONFIG_PATH: OnceLock = OnceLock::new(); static COLOR_PRIMARY: Color = Color::Rgb(51, 217, 178); +static COLOR_PRIMARY_DARK: Color = Color::Rgb(33, 140, 116); static COLOR_SECONDARY: Color = Color::Rgb(52, 172, 224); static COLOR_TERTIARY: Color = Color::Rgb(247, 241, 227); +static COLOR_TERTIARY_DARK: Color = Color::Rgb(132, 129, 122); #[derive(Debug, Serialize, Deserialize)] pub struct App { @@ -92,16 +94,16 @@ impl App { .title_bottom(Line::from(vec![ Span::raw(" Save "), Span::styled( - " | ", + " | ", Style::default() - .fg(COLOR_SECONDARY) + .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), Span::raw(" Cancel "), Span::styled( - " | ", + " | ", Style::default() - .fg(COLOR_SECONDARY) + .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), ])) @@ -332,9 +334,21 @@ impl Widget for &mut App { where Self: Sized, { + let primary_color = if self.edit.is_none() { + COLOR_PRIMARY + } else { + COLOR_PRIMARY_DARK + }; + + let teritary_color = if self.edit.is_none() { + COLOR_TERTIARY + } else { + COLOR_TERTIARY_DARK + }; + let title = Line::from(Span::styled( " Log Your Work ", - Style::default().fg(COLOR_PRIMARY).bold(), + Style::default().fg(primary_color).bold(), )); let instructions = Line::from(vec![ @@ -342,49 +356,49 @@ impl Widget for &mut App { Span::styled( "", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Select "), Span::styled( " | | ", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Down "), Span::styled( "", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Up "), Span::styled( "", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Bottom "), Span::styled( "", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Top "), Span::styled( "", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), Span::raw(" Quit "), Span::styled( " | ", Style::default() - .fg(COLOR_PRIMARY) + .fg(primary_color) .add_modifier(Modifier::BOLD), ), ]); @@ -403,10 +417,16 @@ impl Widget for &mut App { .into_iter() .map(Cell::from) .collect::() - .style(Style::default().fg(COLOR_TERTIARY).bold()) + .style(Style::default().fg(teritary_color).bold()) .height(1); - let mut highlight_style = Style::new().fg(COLOR_PRIMARY).bold(); + let mut highlight_style = Style::new().fg(primary_color).bold(); + + let row_text_color = if self.edit.is_some() { + COLOR_TERTIARY_DARK + } else { + Color::White + }; let items: Vec = self .logs @@ -434,7 +454,7 @@ impl Widget for &mut App { })) }) .collect::() - .style(Style::new().fg(Color::White)) + .style(Style::new().fg(row_text_color)) .height(2) }) .collect();