Merge pull request #2261 from wiiznokes/container-style-colored
Add a colored variant for Container style
This commit is contained in:
commit
9957481d41
1 changed files with 11 additions and 0 deletions
|
|
@ -612,6 +612,12 @@ pub trait Catalog {
|
||||||
/// A styling function for a [`Container`].
|
/// A styling function for a [`Container`].
|
||||||
pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme) -> Style + 'a>;
|
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 {
|
impl Catalog for Theme {
|
||||||
type Class<'a> = StyleFn<'a, Self>;
|
type Class<'a> = StyleFn<'a, Self>;
|
||||||
|
|
||||||
|
|
@ -629,6 +635,11 @@ pub fn transparent<Theme>(_theme: &Theme) -> Style {
|
||||||
Style::default()
|
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.
|
/// A rounded [`Container`] with a background.
|
||||||
pub fn rounded_box(theme: &Theme) -> Style {
|
pub fn rounded_box(theme: &Theme) -> Style {
|
||||||
let palette = theme.extended_palette();
|
let palette = theme.extended_palette();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue