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).
This commit is contained in:
parent
99c038a66a
commit
564ef834ce
2 changed files with 16 additions and 21 deletions
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue