theme: add info severity color token

This commit is contained in:
2026-10-31 09:34:09 +07:00
parent d53f4e290d
commit 9ddf8fe90f
8 changed files with 83 additions and 5 deletions
+45 -2
View File
@@ -12,6 +12,7 @@ pub struct Ramps {
pub destructive: AccentShades,
pub success: AccentShades,
pub warning: AccentShades,
pub info: AccentShades,
}
/// Everything a component paints from, after the overlay chain.
@@ -70,6 +71,7 @@ pub(crate) fn resolve(
system_palette.warning,
base.warning,
);
let info = pick(def_color(|d| d.info()), system_palette.info, base.info);
let mut colors = ColorTokens {
background: pick(
@@ -126,18 +128,24 @@ pub(crate) fn resolve(
None,
contrast_foreground(destructive),
),
success: pick(def_color(|d| d.success()), None, base.success),
success,
success_foreground: pick(
def_color(|d| d.success_foreground()),
None,
contrast_foreground(success),
),
warning: pick(def_color(|d| d.warning()), None, base.warning),
warning,
warning_foreground: pick(
def_color(|d| d.warning_foreground()),
None,
contrast_foreground(warning),
),
info,
info_foreground: pick(
def_color(|d| d.info_foreground()),
None,
contrast_foreground(info),
),
border: pick(
def_color(|d| d.border()),
system_palette.border,
@@ -208,6 +216,7 @@ pub(crate) fn resolve(
),
success: derive_shades(success, colors.background, variant == ThemeVariant::Dark),
warning: derive_shades(warning, colors.background, variant == ThemeVariant::Dark),
info: derive_shades(info, colors.background, variant == ThemeVariant::Dark),
},
colors,
radius,
@@ -523,4 +532,38 @@ mod tests {
assert!(resolved.colors.ring != resolved.colors.background);
}
}
#[test]
fn info_stays_calm_when_the_accent_warms_up() {
// The whole point of the info role: a warm platform accent (GNOME
// red, Omarchy red themes) must not make Info toasts read as Danger.
let red_accent = hsla(0xdc2626);
let resolved = resolve(
&system(
ThemeVariant::Dark,
PartialPalette::default(),
Some(red_accent),
),
None,
None,
);
assert_eq!(resolved.ramps.primary.base, red_accent);
assert_ne!(resolved.colors.info, resolved.colors.destructive);
assert_ne!(resolved.ramps.info.base, resolved.ramps.destructive.base);
}
#[test]
fn info_follows_the_severity_overlay_chain() {
let palette = PartialPalette {
info: Some(hsla(0x155e75)),
..PartialPalette::default()
};
let system_stated = resolve(&system(ThemeVariant::Dark, palette, None), None, None);
assert_eq!(system_stated.colors.info, hsla(0x155e75));
assert_eq!(system_stated.ramps.info.base, hsla(0x155e75));
let def = ThemeDefinition::parse_toml("info = \"#0ea5e9\"\n").unwrap();
let preset_stated = resolve(&system(ThemeVariant::Dark, palette, None), Some(&def), None);
assert_eq!(preset_stated.colors.info, hsla(0x0ea5e9));
}
}