lib: Fix and improve theming

This commit is contained in:
Erik Kundt
2026-01-21 14:07:45 +01:00
parent bb0ed113d9
commit 1f2ecd79df
3 changed files with 19 additions and 13 deletions
+1
View File
@@ -472,6 +472,7 @@ where
.with_area(area)
.with_layout(layout.into())
.with_ctx(self.ctx.clone())
.with_theme(self.theme.clone())
}
pub fn layout<R>(
+7 -7
View File
@@ -6,11 +6,11 @@ use ratatui::style::{Color, Style, Stylize};
pub struct Theme {
pub border_style: Style,
pub focus_border_style: Style,
pub scroll_style: Style,
pub focus_scroll_style: Style,
pub shortcuts_keys_style: Style,
pub shortcuts_action_style: Style,
pub textview_style: Style,
pub textview_scroll_style: Style,
pub textview_focus_scroll_style: Style,
pub bar_on_black_style: Style,
pub dim_no_focus: bool,
}
@@ -26,11 +26,11 @@ impl Theme {
Self {
border_style: Style::default().fg(Color::Rgb(170, 170, 170)),
focus_border_style: Style::default(),
scroll_style: Style::default().fg(Color::Rgb(170, 170, 170)),
focus_scroll_style: Style::default(),
shortcuts_keys_style: style::yellow(),
shortcuts_action_style: style::reset(),
textview_style: style::reset(),
textview_scroll_style: style::cyan().dim(),
textview_focus_scroll_style: style::cyan(),
bar_on_black_style: Style::default().on_gray(),
dim_no_focus: false,
}
@@ -39,12 +39,12 @@ impl Theme {
pub fn default_dark() -> Self {
Self {
border_style: Style::default().fg(Color::Indexed(240)),
focus_border_style: Style::default().fg(Color::Indexed(246)),
focus_border_style: Style::default().cyan(),
scroll_style: Style::default().fg(Color::Indexed(240)),
focus_scroll_style: style::cyan(),
shortcuts_keys_style: style::yellow().dim(),
shortcuts_action_style: style::gray().dim(),
textview_style: style::reset(),
textview_scroll_style: style::cyan().dim(),
textview_focus_scroll_style: style::cyan(),
bar_on_black_style: Style::default().on_black(),
dim_no_focus: false,
}
+11 -6
View File
@@ -572,10 +572,10 @@ where
.track_symbol(None)
.end_symbol(None)
.thumb_symbol("┃")
.style(if area_focus {
Style::default()
.style(if ui.has_focus {
ui.theme.focus_scroll_style
} else {
Style::default().dim()
ui.theme.scroll_style
});
let mut state = ScrollbarState::default()
@@ -739,7 +739,12 @@ where
.begin_symbol(None)
.track_symbol(None)
.end_symbol(None)
.thumb_symbol("┃"),
.thumb_symbol("┃")
.style(if area_focus {
ui.theme.focus_scroll_style
} else {
ui.theme.scroll_style
}),
))
.highlight_style(style::highlight(ui.has_focus))
.style(tree_style)
@@ -1016,9 +1021,9 @@ impl Widget for TextView<'_> {
.end_symbol(None)
.thumb_symbol("┃")
.style(if area_focus {
Style::default()
ui.theme.focus_scroll_style
} else {
Style::default().dim()
ui.theme.scroll_style
});
let mut scroller_state = ScrollbarState::default()