From 564ef834cec33a948dc10c9b401cf29db5d18373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:52:16 +0200 Subject: [PATCH] improv(theme): list_button style This adds a new `list_button` field to theme, which makes ListItem buttons stay transparent when pressed. It's essentially a mix of `text_button` and `background.component`, without hover highlights (as per designs). --- cosmic-theme/src/model/theme.rs | 11 +++++++++++ src/theme/style/button.rs | 26 +++++--------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/cosmic-theme/src/model/theme.rs b/cosmic-theme/src/model/theme.rs index 5db0f32..1bc8050 100644 --- a/cosmic-theme/src/model/theme.rs +++ b/cosmic-theme/src/model/theme.rs @@ -75,6 +75,8 @@ pub struct Theme { pub icon_button: Component, /// link button element colors pub link_button: Component, + /// list button element colors + pub list_button: Component, /// text button element colors pub text_button: Component, /// button component styling @@ -1285,6 +1287,15 @@ impl ThemeBuilder { component.on_disabled = over(component.on.with_alpha(0.5), component.base); component }, + list_button: Component::component( + Srgba::new(0.0, 0.0, 0.0, 0.0), + accent, + on_bg_component, + Srgba::new(0.0, 0.0, 0.0, 0.0), + button_pressed_overlay, + is_high_contrast, + control_steps_array[8], + ), success: Component::colored_component( success, control_steps_array[0], diff --git a/src/theme/style/button.rs b/src/theme/style/button.rs index bb52d9a..e83e48e 100644 --- a/src/theme/style/button.rs +++ b/src/theme/style/button.rs @@ -150,7 +150,7 @@ pub fn appearance( } Button::ListItem(radii) => { corner_radii = radii; - let (background, text, icon) = color(&cosmic.background.component); + let (background, text, icon) = color(&cosmic.list_button); if selected { appearance.background = @@ -197,7 +197,7 @@ impl Catalog for crate::Theme { return active(focused, self); } - let mut s = appearance(self, focused, selected, false, style, move |component| { + appearance(self, focused, selected, false, style, move |component| { let text_color = if matches!( style, Button::Icon | Button::IconVertical | Button::HeaderBar @@ -209,15 +209,7 @@ impl Catalog for crate::Theme { }; (component.base.into(), text_color, text_color) - }); - - if let Button::ListItem(_) = style { - if !selected { - s.background = None; - } - } - - s + }) } fn disabled(&self, style: &Self::Class) -> Style { @@ -245,7 +237,7 @@ impl Catalog for crate::Theme { return hovered(focused, self); } - let mut s = appearance( + appearance( self, focused || matches!(style, Button::Image), selected, @@ -264,15 +256,7 @@ impl Catalog for crate::Theme { (component.hover.into(), text_color, text_color) }, - ); - - if let Button::ListItem(_) = style { - if !selected { - s.background = None; - } - } - - s + ) } fn pressed(&self, focused: bool, selected: bool, style: &Self::Class) -> Style {