Skip to content

Commit

Permalink
Merge pull request #2261 from wiiznokes/container-style-colored
Browse files Browse the repository at this point in the history
Add a colored variant for Container style
  • Loading branch information
hecrj authored Sep 2, 2024
2 parents cb94e40 + 9d7aa11 commit 9957481
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions widget/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ pub trait Catalog {
/// A styling function for a [`Container`].
pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme) -> Style + 'a>;

impl<'a, Theme> From<Style> for StyleFn<'a, Theme> {
fn from(style: Style) -> Self {
Box::new(move |_theme| style)
}
}

impl Catalog for Theme {
type Class<'a> = StyleFn<'a, Self>;

Expand All @@ -629,6 +635,11 @@ pub fn transparent<Theme>(_theme: &Theme) -> Style {
Style::default()
}

/// A [`Container`] with the given [`Background`].
pub fn background(background: impl Into<Background>) -> Style {
Style::default().background(background)
}

/// A rounded [`Container`] with a background.
pub fn rounded_box(theme: &Theme) -> Style {
let palette = theme.extended_palette();
Expand Down

0 comments on commit 9957481

Please sign in to comment.