diff options
| author | Polesznyák Márk <contact@pml68.dev> | 2025-11-22 08:30:00 +0100 |
|---|---|---|
| committer | Polesznyák Márk <contact@pml68.dev> | 2025-11-22 08:30:00 +0100 |
| commit | ff7e17988d5868c72cfb39d09ccf4efb05d3ceda (patch) | |
| tree | 0734e0f409028e203532bfaea2c7372e2c646078 /src/lib.rs | |
| parent | chore: add mailmap (diff) | |
| download | iced_material-ff7e17988d5868c72cfb39d09ccf4efb05d3ceda.tar.gz | |
feat!: combine `Primary`, `Secondary`, `Tertiary` and `Error`
Now only a singular `ColorQuartet` struct exists.
Also rename some `Surface` and `Inverse` fields for consistency.
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 152 |
1 files changed, 55 insertions, 97 deletions
@@ -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, } |
