From ff7e17988d5868c72cfb39d09ccf4efb05d3ceda Mon Sep 17 00:00:00 2001 From: Polesznyák Márk Date: Sat, 22 Nov 2025 08:30:00 +0100 Subject: feat!: combine `Primary`, `Secondary`, `Tertiary` and `Error` Now only a singular `ColorQuartet` struct exists. Also rename some `Surface` and `Inverse` fields for consistency. --- Cargo.toml | 2 +- examples/styling.rs | 7 ++- src/button.rs | 18 +++---- src/checkbox.rs | 34 ++++++------ src/container.rs | 48 ++++++++--------- src/dialog.rs | 4 +- src/lib.rs | 152 +++++++++++++++++++--------------------------------- src/menu.rs | 10 ++-- src/pane_grid.rs | 6 +-- src/pick_list.rs | 12 ++--- src/progress_bar.rs | 4 +- src/qr_code.rs | 2 +- src/radio.rs | 14 ++--- src/scrollable.rs | 12 ++--- src/selection.rs | 2 +- src/slider.rs | 12 ++--- src/text.rs | 22 ++++---- src/text_editor.rs | 16 +++--- src/text_input.rs | 20 +++---- src/toggler.rs | 34 +++++------- 20 files changed, 184 insertions(+), 247 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 64bb14e..c40a7a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "iced_material" description = "A Material3 inspired theme for `iced`" authors = ["pml68 "] -version = "0.14.0-dev" +version = "0.1.0" edition = "2024" license = "MIT" repository = "https://git.sr.ht/~pml68/iced_builder" diff --git a/examples/styling.rs b/examples/styling.rs index cff0b77..4ed643e 100644 --- a/examples/styling.rs +++ b/examples/styling.rs @@ -51,7 +51,7 @@ impl Styling { toggler_value: false, } } - + fn update(&mut self, message: Message) { match message { Message::ThemeChanged(theme) => { @@ -98,7 +98,7 @@ impl Styling { .padding([5, 10]) .width(Fill) .style(|theme: &Theme| { - let color = theme.colors().surface.on_surface; + let color = theme.colors().surface.text; container::Style { background: Some( disabled_container(color).into(), @@ -178,8 +178,7 @@ impl Styling { .style(|theme| { let style = iced_material::container::surface_container_lowest(theme); - let border_color = - theme.colors().surface.surface_container.high; + let border_color = theme.colors().surface.container.high; container::Style { border: style.border.color(border_color).width(1), diff --git a/src/button.rs b/src/button.rs index 7a35e10..3b2d871 100644 --- a/src/button.rs +++ b/src/button.rs @@ -70,8 +70,8 @@ pub fn elevated(theme: &Theme, status: Status) -> Style { let surface = theme.colors().surface; let foreground = theme.colors().primary.color; - let background = surface.surface_container.low; - let disabled = surface.on_surface; + let background = surface.container.low; + let disabled = surface.text; let shadow_color = theme.colors().shadow; @@ -81,9 +81,9 @@ pub fn elevated(theme: &Theme, status: Status) -> Style { pub fn filled(theme: &Theme, status: Status) -> Style { let primary = theme.colors().primary; - let foreground = primary.on_primary; + let foreground = primary.text; let background = primary.color; - let disabled = theme.colors().surface.on_surface; + let disabled = theme.colors().surface.text; let shadow_color = theme.colors().shadow; @@ -93,9 +93,9 @@ pub fn filled(theme: &Theme, status: Status) -> Style { pub fn filled_tonal(theme: &Theme, status: Status) -> Style { let secondary = theme.colors().secondary; - let foreground = secondary.on_secondary_container; - let background = secondary.secondary_container; - let disabled = theme.colors().surface.on_surface; + let foreground = secondary.container_text; + let background = secondary.container; + let disabled = theme.colors().surface.text; let shadow_color = theme.colors().shadow; styled(background, foreground, disabled, shadow_color, 0, status) @@ -104,7 +104,7 @@ pub fn filled_tonal(theme: &Theme, status: Status) -> Style { pub fn outlined(theme: &Theme, status: Status) -> Style { let foreground = theme.colors().primary.color; let background = Color::TRANSPARENT; - let disabled = theme.colors().surface.on_surface; + let disabled = theme.colors().surface.text; let outline = theme.colors().outline.color; @@ -136,7 +136,7 @@ pub fn outlined(theme: &Theme, status: Status) -> Style { pub fn text(theme: &Theme, status: Status) -> Style { let foreground = theme.colors().primary.color; let background = Color::TRANSPARENT; - let disabled = theme.colors().surface.on_surface; + let disabled = theme.colors().surface.text; let style = styled( background, diff --git a/src/checkbox.rs b/src/checkbox.rs index 7a3729c..cb5b96c 100644 --- a/src/checkbox.rs +++ b/src/checkbox.rs @@ -52,28 +52,28 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Active { is_checked } => styled( primary.color, None, - primary.on_primary, - surface.on_surface_variant, - Some(surface.on_surface), + primary.text, + surface.text_variant, + Some(surface.text), is_checked, ), Status::Hovered { is_checked } => styled( - mix(primary.color, surface.on_surface, HOVERED_LAYER_OPACITY), + mix(primary.color, surface.text, HOVERED_LAYER_OPACITY), Some(Color { a: HOVERED_LAYER_OPACITY, - ..surface.on_surface + ..surface.text }), - primary.on_primary, - surface.on_surface_variant, - Some(surface.on_surface), + primary.text, + surface.text_variant, + Some(surface.text), is_checked, ), Status::Disabled { is_checked } => styled( - disabled_text(surface.on_surface), + disabled_text(surface.text), None, surface.color, - disabled_text(surface.on_surface), - Some(surface.on_surface), + disabled_text(surface.text), + Some(surface.text), is_checked, ), } @@ -87,28 +87,28 @@ pub fn error(theme: &Theme, status: Status) -> Style { Status::Active { is_checked } => styled( error.color, None, - error.on_error, + error.text, error.color, Some(error.color), is_checked, ), Status::Hovered { is_checked } => styled( - mix(error.color, surface.on_surface, HOVERED_LAYER_OPACITY), + mix(error.color, surface.text, HOVERED_LAYER_OPACITY), Some(Color { a: HOVERED_LAYER_OPACITY, ..error.color }), - error.on_error, + error.text, error.color, Some(error.color), is_checked, ), Status::Disabled { is_checked } => styled( - disabled_text(surface.on_surface), + disabled_text(surface.text), None, surface.color, - disabled_text(surface.on_surface), - Some(surface.on_surface), + disabled_text(surface.text), + Some(surface.text), is_checked, ), } diff --git a/src/container.rs b/src/container.rs index 3b63d5f..5cda84d 100644 --- a/src/container.rs +++ b/src/container.rs @@ -27,7 +27,7 @@ pub fn primary(theme: &Theme) -> Style { Style { background: Some(Background::Color(primary.color)), - text_color: Some(primary.on_primary), + text_color: Some(primary.text), border: border::rounded(4), ..Style::default() } @@ -37,8 +37,8 @@ pub fn primary_container(theme: &Theme) -> Style { let primary = theme.colors().primary; Style { - background: Some(Background::Color(primary.primary_container)), - text_color: Some(primary.on_primary_container), + background: Some(Background::Color(primary.container)), + text_color: Some(primary.container_text), border: border::rounded(8), ..Style::default() } @@ -49,7 +49,7 @@ pub fn secondary(theme: &Theme) -> Style { Style { background: Some(Background::Color(secondary.color)), - text_color: Some(secondary.on_secondary), + text_color: Some(secondary.text), border: border::rounded(4), ..Style::default() } @@ -59,8 +59,8 @@ pub fn secondary_container(theme: &Theme) -> Style { let secondary = theme.colors().secondary; Style { - background: Some(Background::Color(secondary.secondary_container)), - text_color: Some(secondary.on_secondary_container), + background: Some(Background::Color(secondary.container)), + text_color: Some(secondary.container_text), border: border::rounded(8), ..Style::default() } @@ -71,7 +71,7 @@ pub fn tertiary(theme: &Theme) -> Style { Style { background: Some(Background::Color(tertiary.color)), - text_color: Some(tertiary.on_tertiary), + text_color: Some(tertiary.text), border: border::rounded(4), ..Style::default() } @@ -81,8 +81,8 @@ pub fn tertiary_container(theme: &Theme) -> Style { let tertiary = theme.colors().tertiary; Style { - background: Some(Background::Color(tertiary.tertiary_container)), - text_color: Some(tertiary.on_tertiary_container), + background: Some(Background::Color(tertiary.container)), + text_color: Some(tertiary.container_text), border: border::rounded(8), ..Style::default() } @@ -93,7 +93,7 @@ pub fn error(theme: &Theme) -> Style { Style { background: Some(Background::Color(error.color)), - text_color: Some(error.on_error), + text_color: Some(error.text), border: border::rounded(4), ..Style::default() } @@ -103,8 +103,8 @@ pub fn error_container(theme: &Theme) -> Style { let error = theme.colors().error; Style { - background: Some(Background::Color(error.error_container)), - text_color: Some(error.on_error_container), + background: Some(Background::Color(error.container)), + text_color: Some(error.container_text), border: border::rounded(8), ..Style::default() } @@ -115,7 +115,7 @@ pub fn surface(theme: &Theme) -> Style { Style { background: Some(Background::Color(surface.color)), - text_color: Some(surface.on_surface), + text_color: Some(surface.text), border: border::rounded(4), ..Style::default() } @@ -125,8 +125,8 @@ pub fn surface_container_lowest(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - background: Some(Background::Color(surface.surface_container.lowest)), - text_color: Some(surface.on_surface), + background: Some(Background::Color(surface.container.lowest)), + text_color: Some(surface.text), border: border::rounded(8), ..Style::default() } @@ -136,8 +136,8 @@ pub fn surface_container_low(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - background: Some(Background::Color(surface.surface_container.low)), - text_color: Some(surface.on_surface), + background: Some(Background::Color(surface.container.low)), + text_color: Some(surface.text), border: border::rounded(8), ..Style::default() } @@ -147,8 +147,8 @@ pub fn surface_container(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - background: Some(Background::Color(surface.surface_container.base)), - text_color: Some(surface.on_surface), + background: Some(Background::Color(surface.container.base)), + text_color: Some(surface.text), border: border::rounded(8), ..Style::default() } @@ -158,8 +158,8 @@ pub fn surface_container_high(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - background: Some(Background::Color(surface.surface_container.high)), - text_color: Some(surface.on_surface), + background: Some(Background::Color(surface.container.high)), + text_color: Some(surface.text), border: border::rounded(8), ..Style::default() } @@ -169,8 +169,8 @@ pub fn surface_container_highest(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - background: Some(Background::Color(surface.surface_container.highest)), - text_color: Some(surface.on_surface), + background: Some(Background::Color(surface.container.highest)), + text_color: Some(surface.text), border: border::rounded(8), ..Style::default() } @@ -181,7 +181,7 @@ pub fn inverse_surface(theme: &Theme) -> Style { Style { background: Some(Background::Color(inverse.inverse_surface)), - text_color: Some(inverse.inverse_on_surface), + text_color: Some(inverse.inverse_surface_text), border: border::rounded(4), ..Style::default() } diff --git a/src/dialog.rs b/src/dialog.rs index c839948..0c26fa8 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -27,8 +27,8 @@ impl Catalog for Theme { pub fn default_container(theme: &Theme) -> container::Style { let colors = theme.colors().surface; container::Style { - background: Some(Background::Color(colors.surface_container.high)), - text_color: Some(colors.on_surface_variant), + background: Some(Background::Color(colors.container.high)), + text_color: Some(colors.text_variant), border: border::rounded(28), ..container::Style::default() } diff --git a/src/lib.rs b/src/lib.rs index 12d0a6c..d31633a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,7 +134,7 @@ impl Base for Theme { fn base(&self) -> Style { Style { background_color: self.colors().surface.color, - text_color: self.colors().surface.on_surface, + text_color: self.colors().surface.text, } } @@ -143,9 +143,9 @@ impl Base for Theme { Some(iced_widget::theme::Palette { background: colors.surface.color, - text: colors.surface.on_surface, + text: colors.surface.text, primary: colors.primary.color, - success: colors.primary.primary_container, + success: colors.primary.container, warning: mix(from_argb!(0xffffff00), colors.primary.color, 0.25), danger: colors.error.color, }) @@ -246,13 +246,13 @@ impl Clone for Custom { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ColorScheme { /// The primary colors. - pub primary: Primary, + pub primary: ColorQuartet, /// The secondary colors. - pub secondary: Secondary, + pub secondary: ColorQuartet, /// The tertiary colors. - pub tertiary: Tertiary, + pub tertiary: ColorQuartet, /// The error colors. - pub error: Error, + pub error: ColorQuartet, /// The surface colors. pub surface: Surface, /// The inverse colors. @@ -270,35 +270,35 @@ pub struct ColorScheme { #[allow(clippy::cast_precision_loss)] impl ColorScheme { const DARK: Self = Self { - primary: Primary { + primary: ColorQuartet { color: color!(0x9bd4a1), - on_primary: color!(0x003916), - primary_container: color!(0x1b5129), - on_primary_container: color!(0xb6f1bb), + text: color!(0x003916), + container: color!(0x1b5129), + container_text: color!(0xb6f1bb), }, - secondary: Secondary { + secondary: ColorQuartet { color: color!(0xb8ccb6), - on_secondary: color!(0x233425), - secondary_container: color!(0x394b3a), - on_secondary_container: color!(0xd3e8d1), + text: color!(0x233425), + container: color!(0x394b3a), + container_text: color!(0xd3e8d1), }, - tertiary: Tertiary { + tertiary: ColorQuartet { color: color!(0xa1ced7), - on_tertiary: color!(0x00363e), - tertiary_container: color!(0x1f4d55), - on_tertiary_container: color!(0xbdeaf4), + text: color!(0x00363e), + container: color!(0x1f4d55), + container_text: color!(0xbdeaf4), }, - error: Error { + error: ColorQuartet { color: color!(0xffb4ab), - on_error: color!(0x690005), - error_container: color!(0x93000a), - on_error_container: color!(0xffdad6), + text: color!(0x690005), + container: color!(0x93000a), + container_text: color!(0xffdad6), }, surface: Surface { color: color!(0x101510), - on_surface: color!(0xe0e4dc), - on_surface_variant: color!(0xc1c9be), - surface_container: SurfaceContainer { + text: color!(0xe0e4dc), + text_variant: color!(0xc1c9be), + container: SurfaceContainer { lowest: color!(0x0b0f0b), low: color!(0x181d18), base: color!(0x1c211c), @@ -308,7 +308,7 @@ impl ColorScheme { }, inverse: Inverse { inverse_surface: color!(0xe0e4dc), - inverse_on_surface: color!(0x2d322c), + inverse_surface_text: color!(0x2d322c), inverse_primary: color!(0x34693f), }, outline: Outline { @@ -320,35 +320,35 @@ impl ColorScheme { }; const LIGHT: Self = Self { - primary: Primary { + primary: ColorQuartet { color: color!(0x34693f), - on_primary: color!(0xffffff), - primary_container: color!(0xb6f1bb), - on_primary_container: color!(0x1b5129), + text: color!(0xffffff), + container: color!(0xb6f1bb), + container_text: color!(0x1b5129), }, - secondary: Secondary { + secondary: ColorQuartet { color: color!(0x516351), - on_secondary: color!(0xffffff), - secondary_container: color!(0xd3e8d1), - on_secondary_container: color!(0x394b3a), + text: color!(0xffffff), + container: color!(0xd3e8d1), + container_text: color!(0x394b3a), }, - tertiary: Tertiary { + tertiary: ColorQuartet { color: color!(0x39656d), - on_tertiary: color!(0xffffff), - tertiary_container: color!(0xbdeaf4), - on_tertiary_container: color!(0x1f4d55), + text: color!(0xffffff), + container: color!(0xbdeaf4), + container_text: color!(0x1f4d55), }, - error: Error { + error: ColorQuartet { color: color!(0xba1a1a), - on_error: color!(0xffffff), - error_container: color!(0xffdad6), - on_error_container: color!(0x93000a), + text: color!(0xffffff), + container: color!(0xffdad6), + container_text: color!(0x93000a), }, surface: Surface { color: color!(0xf7fbf2), - on_surface: color!(0x181d18), - on_surface_variant: color!(0x414941), - surface_container: SurfaceContainer { + text: color!(0x181d18), + text_variant: color!(0x414941), + container: SurfaceContainer { lowest: color!(0xffffff), low: color!(0xf1f5ed), base: color!(0xebefe7), @@ -358,7 +358,7 @@ impl ColorScheme { }, inverse: Inverse { inverse_surface: color!(0x2d322c), - inverse_on_surface: color!(0xeef2ea), + inverse_surface_text: color!(0xeef2ea), inverse_primary: color!(0x9bd4a1), }, outline: Outline { @@ -373,57 +373,15 @@ impl ColorScheme { #[derive(Debug, Clone, Copy, PartialEq)] #[cfg_attr(feature = "animate", derive(iced_anim::Animate))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Primary { +pub struct ColorQuartet { #[cfg_attr(feature = "serde", serde(with = "color_serde"))] pub color: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_primary: Color, + pub text: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub primary_container: Color, + pub container: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_primary_container: Color, -} - -#[derive(Debug, Clone, Copy, PartialEq)] -#[cfg_attr(feature = "animate", derive(iced_anim::Animate))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Secondary { - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub color: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_secondary: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub secondary_container: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_secondary_container: Color, -} - -#[derive(Debug, Clone, Copy, PartialEq)] -#[cfg_attr(feature = "animate", derive(iced_anim::Animate))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Tertiary { - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub color: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_tertiary: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub tertiary_container: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_tertiary_container: Color, -} - -#[derive(Debug, Clone, Copy, PartialEq)] -#[cfg_attr(feature = "animate", derive(iced_anim::Animate))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Error { - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub color: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_error: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub error_container: Color, - #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_error_container: Color, + pub container_text: Color, } #[derive(Debug, Clone, Copy, PartialEq)] @@ -433,10 +391,10 @@ pub struct Surface { #[cfg_attr(feature = "serde", serde(with = "color_serde"))] pub color: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_surface: Color, + pub text: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub on_surface_variant: Color, - pub surface_container: SurfaceContainer, + pub text_variant: Color, + pub container: SurfaceContainer, } #[derive(Debug, Clone, Copy, PartialEq)] @@ -462,7 +420,7 @@ pub struct Inverse { #[cfg_attr(feature = "serde", serde(with = "color_serde"))] pub inverse_surface: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] - pub inverse_on_surface: Color, + pub inverse_surface_text: Color, #[cfg_attr(feature = "serde", serde(with = "color_serde"))] pub inverse_primary: Color, } diff --git a/src/menu.rs b/src/menu.rs index d595c2f..4741ecd 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -21,13 +21,13 @@ pub fn default(theme: &Theme) -> Style { Style { border: border::rounded(4), - background: Background::Color(colors.surface_container.base), - text_color: colors.on_surface, + background: Background::Color(colors.container.base), + text_color: colors.text, selected_background: Background::Color(mix( - colors.surface_container.base, - colors.on_surface, + colors.container.base, + colors.text, HOVERED_LAYER_OPACITY, )), - selected_text_color: colors.on_surface, + selected_text_color: colors.text, } } diff --git a/src/pane_grid.rs b/src/pane_grid.rs index fb69a32..c89536e 100644 --- a/src/pane_grid.rs +++ b/src/pane_grid.rs @@ -20,8 +20,8 @@ pub fn default(theme: &Theme) -> Style { Style { hovered_region: Highlight { background: Background::Color(mix( - theme.colors().tertiary.tertiary_container, - theme.colors().surface.on_surface, + theme.colors().tertiary.container, + theme.colors().surface.text, HOVERED_LAYER_OPACITY, )), border: border::rounded(12), @@ -31,7 +31,7 @@ pub fn default(theme: &Theme) -> Style { width: 2.0, }, hovered_split: Line { - color: theme.colors().surface.on_surface, + color: theme.colors().surface.text, width: 6.0, }, } diff --git a/src/pick_list.rs b/src/pick_list.rs index 1fe015e..c4d8a68 100644 --- a/src/pick_list.rs +++ b/src/pick_list.rs @@ -23,21 +23,21 @@ pub fn default(theme: &Theme, status: Status) -> Style { let surface = theme.colors().surface; let active = Style { - text_color: surface.on_surface, - placeholder_color: surface.on_surface_variant, - handle_color: surface.on_surface_variant, - background: Background::Color(surface.surface_container.highest), + text_color: surface.text, + placeholder_color: surface.text_variant, + handle_color: surface.text_variant, + background: Background::Color(surface.container.highest), border: border::rounded(4), }; match status { Status::Active => active, Status::Hovered => Style { - background: Background::Color(surface.surface_container.highest), + background: Background::Color(surface.container.highest), ..active }, Status::Opened { .. } => Style { - background: Background::Color(surface.surface_container.highest), + background: Background::Color(surface.container.highest), border: border::rounded(4), ..active }, diff --git a/src/progress_bar.rs b/src/progress_bar.rs index 9b4e844..5e079ff 100644 --- a/src/progress_bar.rs +++ b/src/progress_bar.rs @@ -17,9 +17,7 @@ impl Catalog for Theme { pub fn default(theme: &Theme) -> Style { Style { - background: Background::Color( - theme.colors().secondary.secondary_container, - ), + background: Background::Color(theme.colors().secondary.container), bar: Background::Color(theme.colors().primary.color), border: border::rounded(400), } diff --git a/src/qr_code.rs b/src/qr_code.rs index f603440..159833e 100644 --- a/src/qr_code.rs +++ b/src/qr_code.rs @@ -18,7 +18,7 @@ pub fn default(theme: &Theme) -> Style { let surface = theme.colors().surface; Style { - cell: surface.on_surface, + cell: surface.text, background: surface.color, } } diff --git a/src/radio.rs b/src/radio.rs index 7fb7a3f..fcd6856 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -33,25 +33,21 @@ pub fn default(theme: &Theme, status: Status) -> Style { border_color: if is_selected { active.border_color } else { - surface.on_surface + surface.text }, ..active }, Status::Hovered { is_selected } => Style { - dot_color: mix( - primary.color, - surface.on_surface, - HOVERED_LAYER_OPACITY, - ), + dot_color: mix(primary.color, surface.text, HOVERED_LAYER_OPACITY), border_color: if is_selected { - mix(primary.color, surface.on_surface, HOVERED_LAYER_OPACITY) + mix(primary.color, surface.text, HOVERED_LAYER_OPACITY) } else { - disabled_text(surface.on_surface) + disabled_text(surface.text) }, background: Background::Color(if is_selected { Color { a: HOVERED_LAYER_OPACITY, - ..surface.on_surface + ..surface.text } } else { Color::TRANSPARENT diff --git a/src/scrollable.rs b/src/scrollable.rs index 341f047..f7bed54 100644 --- a/src/scrollable.rs +++ b/src/scrollable.rs @@ -29,18 +29,16 @@ pub fn default(theme: &Theme, status: Status) -> Style { let active = Rail { background: None, scroller: Scroller { - color: surface.on_surface, + color: surface.text, border: border::rounded(400), }, border: Border::default(), }; let disabled = Rail { - background: Some(Background::Color(disabled_container( - surface.on_surface, - ))), + background: Some(Background::Color(disabled_container(surface.text))), scroller: Scroller { - color: disabled_text(surface.on_surface), + color: disabled_text(surface.text), border: border::rounded(400), }, ..active @@ -79,7 +77,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { let hovered_rail = Rail { scroller: Scroller { color: mix( - surface.on_surface, + surface.text, surface.color, HOVERED_LAYER_OPACITY, ), @@ -115,7 +113,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { let dragged_rail = Rail { scroller: Scroller { color: mix( - surface.on_surface, + surface.text, surface.color, PRESSED_LAYER_OPACITY, ), diff --git a/src/selection.rs b/src/selection.rs index cbf8bd4..0846fac 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -17,6 +17,6 @@ impl Catalog for Theme { pub fn default(theme: &Theme) -> Style { Style { color: None, - selection: theme.colors().primary.primary_container, + selection: theme.colors().primary.container, } } diff --git a/src/slider.rs b/src/slider.rs index ae9ee4b..2146acb 100644 --- a/src/slider.rs +++ b/src/slider.rs @@ -46,17 +46,15 @@ pub fn default(theme: &Theme, status: Status) -> Style { let secondary = theme.colors().secondary; match status { - Status::Active => { - styled(primary.color, secondary.secondary_container, 12.0) - } + Status::Active => styled(primary.color, secondary.container, 12.0), Status::Hovered => styled( - mix(primary.color, surface.on_surface, HOVERED_LAYER_OPACITY), - secondary.secondary_container, + mix(primary.color, surface.text, HOVERED_LAYER_OPACITY), + secondary.container, 12.0, ), Status::Dragged => styled( - mix(primary.color, surface.on_surface, PRESSED_LAYER_OPACITY), - secondary.secondary_container, + mix(primary.color, surface.text, PRESSED_LAYER_OPACITY), + secondary.container, 11.0, ), } diff --git a/src/text.rs b/src/text.rs index 8da3cdf..43979ba 100644 --- a/src/text.rs +++ b/src/text.rs @@ -21,66 +21,66 @@ pub fn none(_: &Theme) -> Style { pub fn primary(theme: &Theme) -> Style { Style { - color: Some(theme.colors().primary.on_primary), + color: Some(theme.colors().primary.text), } } pub fn primary_container(theme: &Theme) -> Style { Style { - color: Some(theme.colors().primary.on_primary_container), + color: Some(theme.colors().primary.container_text), } } pub fn secondary(theme: &Theme) -> Style { Style { - color: Some(theme.colors().secondary.on_secondary), + color: Some(theme.colors().secondary.text), } } pub fn secondary_container(theme: &Theme) -> Style { Style { - color: Some(theme.colors().secondary.on_secondary_container), + color: Some(theme.colors().secondary.container_text), } } pub fn tertiary(theme: &Theme) -> Style { Style { - color: Some(theme.colors().tertiary.on_tertiary), + color: Some(theme.colors().tertiary.text), } } pub fn tertiary_container(theme: &Theme) -> Style { Style { - color: Some(theme.colors().tertiary.on_tertiary_container), + color: Some(theme.colors().tertiary.container_text), } } pub fn error(theme: &Theme) -> Style { Style { - color: Some(theme.colors().error.on_error), + color: Some(theme.colors().error.text), } } pub fn error_container(theme: &Theme) -> Style { Style { - color: Some(theme.colors().error.on_error_container), + color: Some(theme.colors().error.container_text), } } pub fn surface(theme: &Theme) -> Style { Style { - color: Some(theme.colors().surface.on_surface), + color: Some(theme.colors().surface.text), } } pub fn surface_variant(theme: &Theme) -> Style { Style { - color: Some(theme.colors().surface.on_surface_variant), + color: Some(theme.colors().surface.text_variant), } } pub fn inverse_surface(theme: &Theme) -> Style { Style { - color: Some(theme.colors().inverse.inverse_on_surface), + color: Some(theme.colors().inverse.inverse_surface_text), } } diff --git a/src/text_editor.rs b/src/text_editor.rs index 168d1c8..8fea65f 100644 --- a/src/text_editor.rs +++ b/src/text_editor.rs @@ -21,14 +21,14 @@ pub fn default(theme: &Theme, status: Status) -> Style { let primary = theme.colors().primary; let active = Style { - background: Background::Color(surface.surface_container.highest), + background: Background::Color(surface.container.highest), border: Border { color: theme.colors().outline.color, width: 1.0, radius: 4.into(), }, - placeholder: surface.on_surface_variant, - value: surface.on_surface, + placeholder: surface.text_variant, + value: surface.text, selection: disabled_text(primary.color), }; @@ -36,7 +36,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Active => active, Status::Hovered => Style { border: Border { - color: surface.on_surface, + color: surface.text, ..active.border }, ..active @@ -53,13 +53,13 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Disabled => Style { background: Color::TRANSPARENT.into(), border: Border { - color: disabled_container(surface.on_surface), + color: disabled_container(surface.text), width: 1.0, radius: border::radius(4), }, - placeholder: disabled_text(surface.on_surface), - value: disabled_text(surface.on_surface), - selection: disabled_text(surface.on_surface), + placeholder: disabled_text(surface.text), + value: disabled_text(surface.text), + selection: disabled_text(surface.text), }, } } diff --git a/src/text_input.rs b/src/text_input.rs index 4db220b..51bbb89 100644 --- a/src/text_input.rs +++ b/src/text_input.rs @@ -21,34 +21,34 @@ pub fn default(theme: &Theme, status: Status) -> Style { let primary = theme.colors().primary; let active = Style { - background: Background::Color(surface.surface_container.highest), + background: Background::Color(surface.container.highest), border: Border { color: theme.colors().outline.color, width: 1.0, radius: 4.into(), }, - icon: surface.on_surface_variant, - placeholder: surface.on_surface_variant, - value: surface.on_surface, + icon: surface.text_variant, + placeholder: surface.text_variant, + value: surface.text, selection: disabled_text(primary.color), }; match status { Status::Active => active, Status::Hovered => Style { - border: active.border.color(surface.on_surface), + border: active.border.color(surface.text), ..active }, Status::Disabled => Style { background: Color::TRANSPARENT.into(), border: Border { - color: disabled_container(surface.on_surface), + color: disabled_container(surface.text), ..active.border }, - icon: disabled_text(surface.on_surface), - placeholder: disabled_text(surface.on_surface), - value: disabled_text(surface.on_surface), - selection: disabled_text(surface.on_surface), + icon: disabled_text(surface.text), + placeholder: disabled_text(surface.text), + value: disabled_text(surface.text), + selection: disabled_text(surface.text), }, Status::Focused { .. } => Style { border: Border { diff --git a/src/toggler.rs b/src/toggler.rs index cf2aa1d..61e11a7 100644 --- a/src/toggler.rs +++ b/src/toggler.rs @@ -42,47 +42,37 @@ pub fn default(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_toggled } => { if is_toggled { - styled( - primary.color, - primary.on_primary, - surface.on_surface, - None, - ) + styled(primary.color, primary.text, surface.text, None) } else { styled( - surface.surface_container.highest, + surface.container.highest, theme.colors().outline.color, - surface.on_surface, + surface.text, Some(theme.colors().outline.color), ) } } Status::Hovered { is_toggled } => { if is_toggled { - styled( - primary.color, - primary.primary_container, - surface.on_surface, - None, - ) + styled(primary.color, primary.container, surface.text, None) } else { styled( mix( - surface.surface_container.highest, - surface.on_surface, + surface.container.highest, + surface.text, HOVERED_LAYER_OPACITY, ), - surface.on_surface_variant, - surface.on_surface, + surface.text_variant, + surface.text, Some(theme.colors().outline.color), ) } } Status::Disabled => styled( - disabled_container(surface.surface_container.highest), - disabled_text(surface.on_surface), - surface.on_surface, - Some(disabled_text(surface.on_surface)), + disabled_container(surface.container.highest), + disabled_text(surface.text), + surface.text, + Some(disabled_text(surface.text)), ), } } -- cgit v1.2.3