mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 00:10:38 +08:00
lib: Improve theming
This commit is contained in:
@@ -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()
|
||||
|
||||
+11
-11
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user