From 3bc836827a808d17e7575923059904b7d2dbcc10 Mon Sep 17 00:00:00 2001 From: David Aguiló Domínguez Date: Wed, 25 Sep 2024 14:48:00 +0200 Subject: Added color for warning for TERRA, and added warning field to Extended with the needed struct and generate --- core/src/theme/palette.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'core/src/theme') diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 83803c9a..d4ec84f2 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -317,6 +317,7 @@ impl Palette { primary: color!(0xd1d1e0), success: color!(0xb1b695), danger: color!(0xe06b75), + warning: color!(0xf5d76e), // Honey }; } @@ -333,6 +334,8 @@ pub struct Extended { pub success: Success, /// The set of danger colors. pub danger: Danger, + /// The set of warning colors. + pub warning: Warning, /// Whether the palette is dark or not. pub is_dark: bool, } @@ -446,6 +449,11 @@ impl Extended { palette.background, palette.text, ), + warning: Warning::generate( + palette.warning, + palette.background, + palette.text, + ), is_dark: is_dark(palette.background), } } @@ -601,6 +609,31 @@ impl Danger { } } +/// A set of warning colors. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Warning { + /// The base warning color. + pub base: Pair, + /// A weaker version of the base warning color. + pub weak: Pair, + /// A stronger version of the base warning color. + pub strong: Pair, +} + +impl Warning { + /// Generates a set of [`Warning`] colors from the base, background, and text colors. + pub fn generate(base: Color, background: Color, text: Color) -> Self { + let weak = mix(base, background, 0.4); + let strong = deviate(base, 0.1); + + Self { + base: Pair::new(base, text), + weak: Pair::new(weak, text), + strong: Pair::new(strong, text), + } + } +} + fn darken(color: Color, amount: f32) -> Color { let mut hsl = to_hsl(color); -- cgit