add muted_hover token and rework tab strip visuals
This commit is contained in:
@@ -24,6 +24,7 @@ pub struct ColorTokens {
|
||||
pub secondary: Hsla,
|
||||
pub secondary_foreground: Hsla,
|
||||
pub muted: Hsla,
|
||||
pub muted_hover: Hsla,
|
||||
pub muted_foreground: Hsla,
|
||||
pub accent: Hsla,
|
||||
pub accent_foreground: Hsla,
|
||||
@@ -58,6 +59,7 @@ impl ColorTokens {
|
||||
secondary: hex(0xf4f4f5),
|
||||
secondary_foreground: hex(0x18181b),
|
||||
muted: hex(0xf4f4f5),
|
||||
muted_hover: hex(0xe4e4e7),
|
||||
muted_foreground: hex(0x71717a),
|
||||
accent: hex(0x2563eb),
|
||||
accent_foreground: hex(0xffffff),
|
||||
@@ -91,6 +93,7 @@ impl ColorTokens {
|
||||
secondary: hex(0x27272a),
|
||||
secondary_foreground: hex(0xfafafa),
|
||||
muted: hex(0x27272a),
|
||||
muted_hover: hex(0x3f3f46),
|
||||
muted_foreground: hex(0xa1a1aa),
|
||||
accent: hex(0x3b82f6),
|
||||
accent_foreground: hex(0xffffff),
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct ThemeDefinition {
|
||||
pub secondary: Option<String>,
|
||||
pub secondary_foreground: Option<String>,
|
||||
pub muted: Option<String>,
|
||||
pub muted_hover: Option<String>,
|
||||
pub muted_foreground: Option<String>,
|
||||
pub destructive: Option<String>,
|
||||
pub destructive_foreground: Option<String>,
|
||||
@@ -88,6 +89,10 @@ impl ThemeDefinition {
|
||||
parse_hex(self.muted.as_deref()?)
|
||||
}
|
||||
|
||||
pub fn muted_hover(&self) -> Option<Hsla> {
|
||||
parse_hex(self.muted_hover.as_deref()?)
|
||||
}
|
||||
|
||||
pub fn muted_foreground(&self) -> Option<Hsla> {
|
||||
parse_hex(self.muted_foreground.as_deref()?)
|
||||
}
|
||||
|
||||
@@ -111,6 +111,11 @@ pub(crate) fn resolve(
|
||||
base.secondary_foreground,
|
||||
),
|
||||
muted: pick(def_color(|d| d.muted()), system_palette.muted, base.muted),
|
||||
muted_hover: pick(
|
||||
def_color(|d| d.muted_hover()),
|
||||
system_palette.muted_hover,
|
||||
base.muted_hover,
|
||||
),
|
||||
muted_foreground: pick(
|
||||
def_color(|d| d.muted_foreground()),
|
||||
system_palette.muted_foreground,
|
||||
@@ -601,4 +606,20 @@ mod tests {
|
||||
let preset_stated = resolve(&system(ThemeVariant::Dark, palette, None), Some(&def), None);
|
||||
assert_eq!(preset_stated.colors.info, hsla(0x0ea5e9));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn muted_hover_follows_the_overlay_chain() {
|
||||
// No platform states a hover wash; a preset or user file is the only
|
||||
// override above the neutral base.
|
||||
let palette = PartialPalette {
|
||||
muted_hover: Some(hsla(0x155e75)),
|
||||
..PartialPalette::default()
|
||||
};
|
||||
let stated = resolve(&system(ThemeVariant::Dark, palette, None), None, None);
|
||||
assert_eq!(stated.colors.muted_hover, hsla(0x155e75));
|
||||
|
||||
let def = ThemeDefinition::parse_toml("muted_hover = \"#0ea5e9\"\n").unwrap();
|
||||
let preset_stated = resolve(&system(ThemeVariant::Dark, palette, None), Some(&def), None);
|
||||
assert_eq!(preset_stated.colors.muted_hover, hsla(0x0ea5e9));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ impl MacosSource {
|
||||
secondary: None,
|
||||
secondary_foreground: Self::color_to_hsla(&NSColor::secondaryLabelColor()),
|
||||
muted: None,
|
||||
muted_hover: None,
|
||||
muted_foreground: Self::color_to_hsla(&NSColor::secondaryLabelColor()),
|
||||
destructive: Self::color_to_hsla(&NSColor::systemRedColor()),
|
||||
success: None,
|
||||
|
||||
@@ -50,9 +50,11 @@ pub struct PartialPalette {
|
||||
pub secondary: Option<Hsla>,
|
||||
pub secondary_foreground: Option<Hsla>,
|
||||
pub muted: Option<Hsla>,
|
||||
/// No platform states a hover wash, presets override it.
|
||||
pub muted_hover: Option<Hsla>,
|
||||
pub muted_foreground: Option<Hsla>,
|
||||
pub destructive: Option<Hsla>,
|
||||
/// No platform states severity colors; presets override them.
|
||||
/// No platform states severity colors, presets override them.
|
||||
pub success: Option<Hsla>,
|
||||
pub warning: Option<Hsla>,
|
||||
pub info: Option<Hsla>,
|
||||
|
||||
Reference in New Issue
Block a user