Added color for warning for TERRA, and added warning field to Extended with the needed struct and generate
This commit is contained in:
parent
39f2cdd946
commit
3bc836827a
1 changed files with 33 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue