add toast

This commit is contained in:
2026-10-30 01:31:16 +07:00
parent e03b04793c
commit 64f4c3ff0c
13 changed files with 558 additions and 44 deletions
+12
View File
@@ -29,6 +29,10 @@ pub struct ColorTokens {
pub accent_foreground: Hsla,
pub destructive: Hsla,
pub destructive_foreground: Hsla,
pub success: Hsla,
pub success_foreground: Hsla,
pub warning: Hsla,
pub warning_foreground: Hsla,
pub border: Hsla,
pub input: Hsla,
pub ring: Hsla,
@@ -57,6 +61,10 @@ impl ColorTokens {
accent_foreground: hex(0xffffff),
destructive: hex(0xdc2626),
destructive_foreground: hex(0xffffff),
success: hex(0x16a34a),
success_foreground: hex(0xffffff),
warning: hex(0xd97706),
warning_foreground: hex(0xffffff),
border: hex(0xe4e4e7),
input: hex(0xe4e4e7),
ring: hex(0x93c5fd),
@@ -84,6 +92,10 @@ impl ColorTokens {
accent_foreground: hex(0xffffff),
destructive: hex(0xef4444),
destructive_foreground: hex(0xffffff),
success: hex(0x22c55e),
success_foreground: hex(0x052e16),
warning: hex(0xf59e0b),
warning_foreground: hex(0x451a03),
border: hex(0x27272a),
input: hex(0x27272a),
ring: hex(0x1d4ed8),
+20
View File
@@ -25,6 +25,10 @@ pub struct ThemeDefinition {
pub muted_foreground: Option<String>,
pub destructive: Option<String>,
pub destructive_foreground: Option<String>,
pub success: Option<String>,
pub success_foreground: Option<String>,
pub warning: Option<String>,
pub warning_foreground: Option<String>,
pub border: Option<String>,
pub input: Option<String>,
pub ring: Option<String>,
@@ -94,6 +98,22 @@ impl ThemeDefinition {
parse_hex(self.destructive_foreground.as_deref()?)
}
pub fn success(&self) -> Option<Hsla> {
parse_hex(self.success.as_deref()?)
}
pub fn success_foreground(&self) -> Option<Hsla> {
parse_hex(self.success_foreground.as_deref()?)
}
pub fn warning(&self) -> Option<Hsla> {
parse_hex(self.warning.as_deref()?)
}
pub fn warning_foreground(&self) -> Option<Hsla> {
parse_hex(self.warning_foreground.as_deref()?)
}
pub fn border(&self) -> Option<Hsla> {
parse_hex(self.border.as_deref()?)
}
+26
View File
@@ -10,6 +10,8 @@ pub struct Ramps {
pub primary: AccentShades,
pub secondary: AccentShades,
pub destructive: AccentShades,
pub success: AccentShades,
pub warning: AccentShades,
}
/// Everything a component paints from, after the overlay chain.
@@ -58,6 +60,16 @@ pub(crate) fn resolve(
system_palette.destructive,
base.destructive,
);
let success = pick(
def_color(|d| d.success()),
system_palette.success,
base.success,
);
let warning = pick(
def_color(|d| d.warning()),
system_palette.warning,
base.warning,
);
let mut colors = ColorTokens {
background: pick(
@@ -114,6 +126,18 @@ pub(crate) fn resolve(
None,
contrast_foreground(destructive),
),
success: pick(def_color(|d| d.success()), None, base.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_foreground: pick(
def_color(|d| d.warning_foreground()),
None,
contrast_foreground(warning),
),
border: pick(
def_color(|d| d.border()),
system_palette.border,
@@ -182,6 +206,8 @@ pub(crate) fn resolve(
colors.background,
variant == ThemeVariant::Dark,
),
success: derive_shades(success, colors.background, variant == ThemeVariant::Dark),
warning: derive_shades(warning, colors.background, variant == ThemeVariant::Dark),
},
colors,
radius,
+2
View File
@@ -81,6 +81,8 @@ impl MacosSource {
muted: None,
muted_foreground: Self::color_to_hsla(&NSColor::secondaryLabelColor()),
destructive: Self::color_to_hsla(&NSColor::systemRedColor()),
success: None,
warning: None,
border: Self::color_to_hsla(&NSColor::separatorColor()),
input: Self::color_to_hsla(&NSColor::controlBackgroundColor()),
ring: Self::color_to_hsla(&NSColor::keyboardFocusIndicatorColor()),
+3
View File
@@ -43,6 +43,9 @@ pub struct PartialPalette {
pub muted: Option<Hsla>,
pub muted_foreground: Option<Hsla>,
pub destructive: Option<Hsla>,
/// No platform states severity colors; presets override them.
pub success: Option<Hsla>,
pub warning: Option<Hsla>,
pub border: Option<Hsla>,
pub input: Option<Hsla>,
pub ring: Option<Hsla>,