Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
lib: Improve theming
Erik Kundt committed 3 months ago
commit b15c016700640a8c346b79aed41885d6626e05ac
parent 1f2ecd7
3 files changed +15 -15
modified src/ui.rs
@@ -248,7 +248,7 @@ impl Layout {
                    ])
                    .areas(area);
                    let [right_top, right_bottom] =
-
                        Layout::vertical([Constraint::Percentage(65), Constraint::Percentage(35)])
+
                        Layout::vertical([Constraint::Percentage(60), Constraint::Percentage(40)])
                            .areas(right);

                    [left, right_top, right_bottom].into()
modified src/ui/theme.rs
@@ -39,9 +39,9 @@ impl Theme {
    pub fn default_dark() -> Self {
        Self {
            border_style: Style::default().fg(Color::Indexed(240)),
-
            focus_border_style: Style::default().cyan(),
+
            focus_border_style: Style::default().fg(Color::Indexed(249)),
            scroll_style: Style::default().fg(Color::Indexed(240)),
-
            focus_scroll_style: style::cyan(),
+
            focus_scroll_style: Style::default().fg(Color::Indexed(249)),
            shortcuts_keys_style: style::yellow().dim(),
            shortcuts_action_style: style::gray().dim(),
            textview_style: style::reset(),
@@ -49,10 +49,18 @@ impl Theme {
            dim_no_focus: false,
        }
    }
+

+
    pub fn highlight(&self, focus: bool) -> Style {
+
        if focus {
+
            style::cyan().not_dim().reversed()
+
        } else {
+
            style::cyan().dim().reversed()
+
        }
+
    }
}

pub mod style {
-
    use ratatui::style::{Color, Style, Stylize};
+
    use ratatui::style::{Color, Style};

    pub fn reset() -> Style {
        Style::default().fg(Color::Reset)
@@ -93,12 +101,4 @@ pub mod style {
    pub fn darkgray() -> Style {
        Style::default().fg(Color::DarkGray)
    }
-

-
    pub fn highlight(focus: bool) -> Style {
-
        if focus {
-
            cyan().not_dim().reversed()
-
        } else {
-
            cyan().dim().reversed()
-
        }
-
    }
}
modified src/ui/widget.rs
@@ -555,7 +555,7 @@ where
                .rows(rows)
                .widths(widths)
                .column_spacing(self.spacing.into())
-
                .row_highlight_style(style::highlight(ui.has_focus));
+
                .row_highlight_style(ui.theme.highlight(ui.has_focus));

            let table = if !area_focus && self.dim {
                table.dim()
@@ -746,13 +746,13 @@ where
                            ui.theme.scroll_style
                        }),
                ))
-
                .highlight_style(style::highlight(ui.has_focus))
+
                .highlight_style(ui.theme.highlight(ui.has_focus))
                .style(tree_style)
        } else {
            tui_tree_widget::Tree::new(&items)
                .expect("all item identifiers are unique")
                .style(tree_style)
-
                .highlight_style(style::highlight(ui.has_focus))
+
                .highlight_style(ui.theme.highlight(ui.has_focus))
        };

        frame.render_stateful_widget(tree, area, &mut state.internal);