Inverse surface role (surface.inverse, text.on_inverse) in every theme; toasts use it (L-300)

This commit is contained in:
Dylan M. Taylor
2026-11-22 00:34:03 -05:00
parent 3c1773674f
commit 644e6ff8c3
76 changed files with 211 additions and 11 deletions
+1
View File
@@ -125,6 +125,7 @@ fn spec_pairs() -> Vec<(T, T, f64, f64)> {
p.extend(TEXT_BGS.map(|bg| (fg, bg, 4.5, 7.0)));
}
p.extend([T::StateSelected, T::StateSelectedHover].map(|bg| (T::TextOnSelected, bg, 4.5, 7.0)));
p.push((T::TextOnInverse, T::SurfaceInverse, 4.5, 7.0));
p.extend(CONTROL_BGS.map(|bg| (T::AccentText, bg, 4.5, 7.0)));
p.push((T::AccentOnSoft, T::AccentSoft, 4.5, 7.0));
p.extend([T::AccentSolid, T::AccentHover, T::AccentPressed].map(|bg| (T::TextOnAccent, bg, 4.5, 7.0)));
+14 -3
View File
@@ -68,6 +68,9 @@ pub struct SurfaceColors {
pub knob: Rgba,
/// Translucent cover behind modal surfaces.
pub scrim: Rgba,
/// The surface that stands out from the others by being the opposite of them: light on a dark theme, dark on a
/// light one. Toasts sit on it, with `text.on_inverse` on top.
pub inverse: Rgba,
/// The colour of every cast shadow (popups, menus, dialogs, floating windows, toasts,
/// tooltips): black at the theme's alpha, as PhotoCraft's `Tokens::shadow`. Each use keeps its
/// own offset and blur (`elevation.*`).
@@ -96,6 +99,8 @@ pub struct TextColors {
pub on_status: Rgba,
/// Text on `state.selected` and `state.selected_hover`.
pub on_selected: Rgba,
/// Text on `surface.inverse`.
pub on_inverse: Rgba,
}
/// Lines and outlines.
@@ -315,9 +320,10 @@ impl ColorTokens {
sunken: c,
knob: c,
scrim: c,
inverse: c,
shadow: c,
},
text: TextColors { normal: c, muted: c, faint: c, disabled: c, on_accent: c, on_strong: c, on_status: c, on_selected: c },
text: TextColors { normal: c, muted: c, faint: c, disabled: c, on_accent: c, on_strong: c, on_status: c, on_selected: c, on_inverse: c },
line: LineColors { divider: c, border: c, control_edge: c, knob_edge: c, frame: c, mark: c, focus: c },
accent: AccentColors {
solid: c,
@@ -433,6 +439,8 @@ color_tokens! {
SurfaceKnob = "surface.knob" => surface.knob;
/// `surface.scrim`
SurfaceScrim = "surface.scrim" => surface.scrim;
/// `surface.inverse`
SurfaceInverse = "surface.inverse" => surface.inverse;
/// `surface.shadow`
SurfaceShadow = "surface.shadow" => surface.shadow;
/// `text.normal`
@@ -451,6 +459,8 @@ color_tokens! {
TextOnStatus = "text.on_status" => text.on_status;
/// `text.on_selected`
TextOnSelected = "text.on_selected" => text.on_selected;
/// `text.on_inverse`
TextOnInverse = "text.on_inverse" => text.on_inverse;
/// `line.divider`
LineDivider = "line.divider" => line.divider;
/// `line.border`
@@ -632,11 +642,12 @@ impl ColorToken {
/// (`surface.*` except `scrim` and `shadow`); those must be opaque.
pub const fn is_opaque_surface(self) -> bool {
use ColorToken::{
SurfaceBackground, SurfaceCanvas, SurfaceCanvasPattern, SurfaceChrome, SurfaceKnob, SurfacePanel, SurfaceRaised, SurfaceSunken,
SurfaceBackground, SurfaceCanvas, SurfaceCanvasPattern, SurfaceChrome, SurfaceInverse, SurfaceKnob, SurfacePanel, SurfaceRaised,
SurfaceSunken,
};
matches!(
self,
SurfaceBackground | SurfaceCanvas | SurfaceCanvasPattern | SurfaceChrome | SurfacePanel | SurfaceRaised | SurfaceSunken | SurfaceKnob
SurfaceBackground | SurfaceCanvas | SurfaceCanvasPattern | SurfaceChrome | SurfacePanel | SurfaceRaised | SurfaceSunken | SurfaceKnob | SurfaceInverse
)
}
}
+6
View File
@@ -183,6 +183,9 @@ pub(super) fn source(token: ColorToken, mode: Mode) -> ColorSource {
// Near white in both modes (dark: about 236/255), as macOS, GNOME and PhotoCraft knobs. A
// knob face is not a background grey, so it stays on the curve.
T::SurfaceKnob => Neutral(pick(12, 1)),
// The opposite of the panel: a light card on a dark theme, a dark one on a light theme. Step 12 of the ramp
// is the text colour's step, so the surface has the contrast text has in either mode.
T::SurfaceInverse => Neutral(12),
T::SurfaceScrim => Fixed(Rgba::BLACK.with_alpha(alpha(pickf(0.5, 0.35)))),
T::SurfaceShadow => Fixed(Rgba::BLACK.with_alpha(pick(SHADOW_ALPHA.1, SHADOW_ALPHA.0) as u8)),
T::TextNormal => Neutral(12),
@@ -194,6 +197,8 @@ pub(super) fn source(token: ColorToken, mode: Mode) -> ColorSource {
T::TextOnStatus => OnSolid(STATUS_SOLIDS),
// `text.normal`'s step, so neutral selections look like the rest of the text.
T::TextOnSelected => Neutral(12),
// Step 1 is the far end of the ramp from the inverse surface's step 12 in either mode.
T::TextOnInverse => Neutral(1),
T::LineDivider => Anchored(6),
T::LineBorder => Anchored(7),
T::LineControlEdge => Anchored(8),
@@ -379,6 +384,7 @@ pub(super) const RULES: &[PairRule] = &[
// A canvas scroll bar's thumb is a boundary on its track: Standard keeps the theme's own greys.
rule(&[T::TextFaint, T::TextMuted], &[Token(T::SurfaceChrome)], CONTROL_EDGE_MIN.0, CONTROL_EDGE_MIN.1),
rule(&[T::TextOnSelected], SELECTED_BGS, TEXT_MIN.0, TEXT_MIN.1),
rule(&[T::TextOnInverse], &[Token(T::SurfaceInverse)], TEXT_MIN.0, TEXT_MIN.1),
rule(&[T::AccentText], CONTROL_BGS, TEXT_MIN.0, TEXT_MIN.1),
// After `accent.text`, which it starts from.
rule(&[T::AccentOnSoft], &[Token(T::AccentSoft)], TEXT_MIN.0, TEXT_MIN.1),
@@ -8,6 +8,7 @@ surface.raised = #404044ff
surface.sunken = #404044ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #0000008c
text.normal = #ffffffff
text.muted = #fafafcff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #18181bff
line.border = #404044ff
line.control_edge = #4c4c50ff
@@ -8,6 +8,7 @@ surface.raised = #404044ff
surface.sunken = #404044ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #0000008c
text.normal = #ffffffff
text.muted = #fafafcff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #18181bff
line.border = #404044ff
line.control_edge = #4c4c50ff
@@ -8,6 +8,7 @@ surface.raised = #39393eff
surface.sunken = #404044ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #0000008c
text.normal = #ffffffff
text.muted = #c0c0c2ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #18181bff
line.border = #404044ff
line.control_edge = #4c4c50ff
@@ -8,6 +8,7 @@ surface.raised = #39393eff
surface.sunken = #404044ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #0000008c
text.normal = #ffffffff
text.muted = #c0c0c2ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #18181bff
line.border = #404044ff
line.control_edge = #4c4c50ff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ebebedff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #0000002d
text.normal = #323236ff
text.muted = #403f43ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #dedee1ff
line.border = #dadaddff
line.control_edge = #dadaddff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ebebedff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #0000002d
text.normal = #323236ff
text.muted = #403f43ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #dedee1ff
line.border = #dadaddff
line.control_edge = #dadaddff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ebebedff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #0000002d
text.normal = #323236ff
text.muted = #646468ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #dedee1ff
line.border = #dadaddff
line.control_edge = #dadaddff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ebebedff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #0000002d
text.normal = #323236ff
text.muted = #646468ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #dedee1ff
line.border = #dadaddff
line.control_edge = #dadaddff
@@ -8,6 +8,7 @@ surface.raised = #595959ff
surface.sunken = #454545ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #ffffffff
text.muted = #ffffffff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #3e3e3eff
line.border = #424242ff
line.control_edge = #686868ff
@@ -8,6 +8,7 @@ surface.raised = #595959ff
surface.sunken = #454545ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #ffffffff
text.muted = #ffffffff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #3e3e3eff
line.border = #424242ff
line.control_edge = #686868ff
@@ -8,6 +8,7 @@ surface.raised = #5c5c5cff
surface.sunken = #454545ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #eeeeeeff
text.muted = #d4d4d4ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #3e3e3eff
line.border = #424242ff
line.control_edge = #686868ff
@@ -8,6 +8,7 @@ surface.raised = #5c5c5cff
surface.sunken = #454545ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #eeeeeeff
text.muted = #d4d4d4ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #3e3e3eff
line.border = #424242ff
line.control_edge = #686868ff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #3c3c3cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #3c3c3cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #272b30ff
surface.sunken = #262a30ff
surface.knob = #e9ebeeff
surface.scrim = #00000080
surface.inverse = #e9ebeeff
surface.shadow = #00000096
text.normal = #fafbfdff
text.muted = #ccd3daff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e9ebeeff
text.on_inverse = #0d0d0dff
line.divider = #2e3236ff
line.border = #34383dff
line.control_edge = #44494fff
@@ -8,6 +8,7 @@ surface.raised = #272b30ff
surface.sunken = #262a30ff
surface.knob = #e9ebeeff
surface.scrim = #00000080
surface.inverse = #e9ebeeff
surface.shadow = #00000096
text.normal = #fafbfdff
text.muted = #ccd3daff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e9ebeeff
text.on_inverse = #0d0d0dff
line.divider = #2e3236ff
line.border = #34383dff
line.control_edge = #44494fff
@@ -8,6 +8,7 @@ surface.raised = #272b30ff
surface.sunken = #262a30ff
surface.knob = #e9ebeeff
surface.scrim = #00000080
surface.inverse = #e9ebeeff
surface.shadow = #00000096
text.normal = #fafbfdff
text.muted = #c8ced5ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e9ebeeff
text.on_inverse = #0d0d0dff
line.divider = #2e3236ff
line.border = #34383dff
line.control_edge = #44494fff
@@ -8,6 +8,7 @@ surface.raised = #272b30ff
surface.sunken = #262a30ff
surface.knob = #e9ebeeff
surface.scrim = #00000080
surface.inverse = #e9ebeeff
surface.shadow = #00000096
text.normal = #fafbfdff
text.muted = #c8ced5ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e9ebeeff
text.on_inverse = #0d0d0dff
line.divider = #2e3236ff
line.border = #34383dff
line.control_edge = #44494fff
@@ -8,6 +8,7 @@ surface.raised = #f2f4f7ff
surface.sunken = #f9fafcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #252729ff
surface.shadow = #0000002d
text.normal = #21252aff
text.muted = #363f48ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #252729ff
text.on_inverse = #fcfcfdff
line.divider = #d6dadeff
line.border = #cbd0d5ff
line.control_edge = #b8bfc6ff
@@ -8,6 +8,7 @@ surface.raised = #f2f4f7ff
surface.sunken = #f9fafcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #252729ff
surface.shadow = #0000002d
text.normal = #21252aff
text.muted = #363f48ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #252729ff
text.on_inverse = #fcfcfdff
line.divider = #d6dadeff
line.border = #cbd0d5ff
line.control_edge = #b8bfc6ff
@@ -8,6 +8,7 @@ surface.raised = #f2f4f7ff
surface.sunken = #f9fafcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #252729ff
surface.shadow = #0000002d
text.normal = #21252aff
text.muted = #363f48ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #252729ff
text.on_inverse = #fcfcfdff
line.divider = #d6dadeff
line.border = #cbd0d5ff
line.control_edge = #b8bfc6ff
@@ -8,6 +8,7 @@ surface.raised = #f2f4f7ff
surface.sunken = #f9fafcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #252729ff
surface.shadow = #0000002d
text.normal = #21252aff
text.muted = #363f48ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #252729ff
text.on_inverse = #fcfcfdff
line.divider = #d6dadeff
line.border = #cbd0d5ff
line.control_edge = #b8bfc6ff
@@ -8,6 +8,7 @@ surface.raised = #d4d0c8ff
surface.sunken = #ffffffff
surface.knob = #d4d0c8ff
surface.scrim = #00000059
surface.inverse = #282624ff
surface.shadow = #00000000
text.normal = #000000ff
text.muted = #2e2e2eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #000000ff
text.on_status = #ffffffff
text.on_selected = #ffffffff
text.on_inverse = #fdfcfcff
line.divider = #808080ff
line.border = #808080ff
line.control_edge = #808080ff
@@ -8,6 +8,7 @@ surface.raised = #d4d0c8ff
surface.sunken = #ffffffff
surface.knob = #d4d0c8ff
surface.scrim = #00000059
surface.inverse = #282624ff
surface.shadow = #00000000
text.normal = #000000ff
text.muted = #2e2e2eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #000000ff
text.on_status = #ffffffff
text.on_selected = #ffffffff
text.on_inverse = #fdfcfcff
line.divider = #808080ff
line.border = #808080ff
line.control_edge = #808080ff
@@ -8,6 +8,7 @@ surface.raised = #d4d0c8ff
surface.sunken = #ffffffff
surface.knob = #d4d0c8ff
surface.scrim = #00000059
surface.inverse = #282624ff
surface.shadow = #00000000
text.normal = #000000ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #000000ff
text.on_status = #ffffffff
text.on_selected = #ffffffff
text.on_inverse = #fdfcfcff
line.divider = #808080ff
line.border = #808080ff
line.control_edge = #808080ff
@@ -8,6 +8,7 @@ surface.raised = #d4d0c8ff
surface.sunken = #ffffffff
surface.knob = #d4d0c8ff
surface.scrim = #00000059
surface.inverse = #282624ff
surface.shadow = #00000000
text.normal = #000000ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #000000ff
text.on_status = #ffffffff
text.on_selected = #ffffffff
text.on_inverse = #fdfcfcff
line.divider = #808080ff
line.border = #808080ff
line.control_edge = #808080ff
@@ -8,6 +8,7 @@ surface.raised = #2e2e33ff
surface.sunken = #131317ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #00000096
text.normal = #ececefff
text.muted = #cacbd3ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #47474cff
line.border = #3c3c43ff
line.control_edge = #77777cff
@@ -8,6 +8,7 @@ surface.raised = #2e2e33ff
surface.sunken = #131317ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #00000096
text.normal = #ececefff
text.muted = #cacbd3ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #47474cff
line.border = #3c3c43ff
line.control_edge = #77777cff
@@ -8,6 +8,7 @@ surface.raised = #2e2e33ff
surface.sunken = #131317ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #00000096
text.normal = #ececefff
text.muted = #aeaeb6ff
@@ -17,6 +18,7 @@ text.on_accent = #19191cff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #47474cff
line.border = #3c3c43ff
line.control_edge = #77777cff
@@ -8,6 +8,7 @@ surface.raised = #2e2e33ff
surface.sunken = #131317ff
surface.knob = #ebebedff
surface.scrim = #00000080
surface.inverse = #ebebedff
surface.shadow = #00000096
text.normal = #ececefff
text.muted = #aeaeb6ff
@@ -17,6 +18,7 @@ text.on_accent = #19191cff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebedff
text.on_inverse = #0d0d0dff
line.divider = #47474cff
line.border = #3c3c43ff
line.control_edge = #77777cff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ffffffff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #00000032
text.normal = #222226ff
text.muted = #4f4f56ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #d9d9d9ff
line.border = #dadadeff
line.control_edge = #b2b2b2ff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ffffffff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #00000032
text.normal = #222226ff
text.muted = #4f4f56ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #d9d9d9ff
line.border = #dadadeff
line.control_edge = #b2b2b2ff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ffffffff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #00000032
text.normal = #222226ff
text.muted = #5e5e66ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #d9d9d9ff
line.border = #dadadeff
line.control_edge = #b2b2b2ff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #ffffffff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #262628ff
surface.shadow = #00000032
text.normal = #222226ff
text.muted = #5e5e66ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262628ff
text.on_inverse = #fcfcfdff
line.divider = #d9d9d9ff
line.border = #dadadeff
line.control_edge = #b2b2b2ff
@@ -8,6 +8,7 @@ surface.raised = #3c3c3cff
surface.sunken = #242424ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #ecececff
text.muted = #ecececff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #1e1e1eff
line.border = #1e1e1eff
line.control_edge = #4a4a4aff
@@ -8,6 +8,7 @@ surface.raised = #3c3c3cff
surface.sunken = #242424ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #ecececff
text.muted = #ecececff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ffffffff
text.on_inverse = #0d0d0dff
line.divider = #1e1e1eff
line.border = #1e1e1eff
line.control_edge = #4a4a4aff
@@ -8,6 +8,7 @@ surface.raised = #3c3c3cff
surface.sunken = #242424ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #dededeff
text.muted = #b2b2b2ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebebff
text.on_inverse = #0d0d0dff
line.divider = #1e1e1eff
line.border = #1e1e1eff
line.control_edge = #4a4a4aff
@@ -8,6 +8,7 @@ surface.raised = #3c3c3cff
surface.sunken = #242424ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #dededeff
text.muted = #b2b2b2ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebebff
text.on_inverse = #0d0d0dff
line.divider = #1e1e1eff
line.border = #1e1e1eff
line.control_edge = #4a4a4aff
@@ -8,6 +8,7 @@ surface.raised = #3c3c3cff
surface.sunken = #242424ff
surface.knob = #ebebebff
surface.scrim = #00000080
surface.inverse = #ebebebff
surface.shadow = #00000096
text.normal = #dededeff
text.muted = #b2b2b2ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #ebebebff
text.on_inverse = #0d0d0dff
line.divider = #1e1e1eff
line.border = #1e1e1eff
line.control_edge = #4a4a4aff
@@ -8,6 +8,7 @@ surface.raised = #bdbdbdff
surface.sunken = #d6d6d6ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000046
text.normal = #141414ff
text.muted = #1e1e1eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #9e9e9eff
line.border = #a0a0a0ff
line.control_edge = #8c8c8cff
@@ -8,6 +8,7 @@ surface.raised = #bdbdbdff
surface.sunken = #d6d6d6ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000046
text.normal = #141414ff
text.muted = #1e1e1eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #9e9e9eff
line.border = #a0a0a0ff
line.control_edge = #8c8c8cff
@@ -8,6 +8,7 @@ surface.raised = #bdbdbdff
surface.sunken = #d6d6d6ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000046
text.normal = #141414ff
text.muted = #343434ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #9e9e9eff
line.border = #a0a0a0ff
line.control_edge = #8c8c8cff
@@ -8,6 +8,7 @@ surface.raised = #bdbdbdff
surface.sunken = #d6d6d6ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000046
text.normal = #141414ff
text.muted = #343434ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #9e9e9eff
line.border = #a0a0a0ff
line.control_edge = #8c8c8cff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #3c3c3cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #3c3c3cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #f6f6f6ff
surface.sunken = #ffffffff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262626ff
surface.shadow = #00000032
text.normal = #141414ff
text.muted = #404040ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #262626ff
text.on_inverse = #fcfcfcff
line.divider = #d6d6d6ff
line.border = #d6d6d6ff
line.control_edge = #bababaff
@@ -8,6 +8,7 @@ surface.raised = #40404bff
surface.sunken = #40404bff
surface.knob = #eaeaf0ff
surface.scrim = #00000080
surface.inverse = #eaeaf0ff
surface.shadow = #0000006e
text.normal = #eeeef6ff
text.muted = #e5e6f2ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #eaeaf0ff
text.on_inverse = #0d0d0eff
line.divider = #24242cff
line.border = #464652ff
line.control_edge = #545462ff
@@ -8,6 +8,7 @@ surface.raised = #40404bff
surface.sunken = #40404bff
surface.knob = #eaeaf0ff
surface.scrim = #00000080
surface.inverse = #eaeaf0ff
surface.shadow = #0000006e
text.normal = #eeeef6ff
text.muted = #e5e6f2ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #eaeaf0ff
text.on_inverse = #0d0d0eff
line.divider = #24242cff
line.border = #464652ff
line.control_edge = #545462ff
@@ -8,6 +8,7 @@ surface.raised = #40404bff
surface.sunken = #40404bff
surface.knob = #eaeaf0ff
surface.scrim = #00000080
surface.inverse = #eaeaf0ff
surface.shadow = #0000006e
text.normal = #eeeef6ff
text.muted = #d4d4e0ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #eaeaf0ff
text.on_inverse = #0d0d0eff
line.divider = #24242cff
line.border = #464652ff
line.control_edge = #545462ff
@@ -8,6 +8,7 @@ surface.raised = #40404bff
surface.sunken = #40404bff
surface.knob = #eaeaf0ff
surface.scrim = #00000080
surface.inverse = #eaeaf0ff
surface.shadow = #0000006e
text.normal = #eeeef6ff
text.muted = #d4d4e0ff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #eaeaf0ff
text.on_inverse = #0d0d0eff
line.divider = #24242cff
line.border = #464652ff
line.control_edge = #545462ff
@@ -8,6 +8,7 @@ surface.raised = #f6f4f9ff
surface.sunken = #faf9fcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #272628ff
surface.shadow = #00000028
text.normal = #2c2a38ff
text.muted = #3e3c4cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #ffffffff
text.on_selected = #272628ff
text.on_inverse = #fcfcfdff
line.divider = #d2cfdaff
line.border = #d0cdd7ff
line.control_edge = #bebbc9ff
@@ -8,6 +8,7 @@ surface.raised = #f6f4f9ff
surface.sunken = #faf9fcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #272628ff
surface.shadow = #00000028
text.normal = #2c2a38ff
text.muted = #3e3c4cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #ffffffff
text.on_selected = #272628ff
text.on_inverse = #fcfcfdff
line.divider = #d2cfdaff
line.border = #d0cdd7ff
line.control_edge = #bebbc9ff
@@ -8,6 +8,7 @@ surface.raised = #f6f4f9ff
surface.sunken = #faf9fcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #272628ff
surface.shadow = #00000028
text.normal = #2c2a38ff
text.muted = #3e3c4cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #ffffffff
text.on_selected = #272628ff
text.on_inverse = #fcfcfdff
line.divider = #d2cfdaff
line.border = #d0cdd7ff
line.control_edge = #bebbc9ff
@@ -8,6 +8,7 @@ surface.raised = #f6f4f9ff
surface.sunken = #faf9fcff
surface.knob = #fcfcfdff
surface.scrim = #00000059
surface.inverse = #272628ff
surface.shadow = #00000028
text.normal = #2c2a38ff
text.muted = #3e3c4cff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #ffffffff
text.on_status = #ffffffff
text.on_selected = #272628ff
text.on_inverse = #fcfcfdff
line.divider = #d2cfdaff
line.border = #d0cdd7ff
line.control_edge = #bebbc9ff
@@ -8,6 +8,7 @@ surface.raised = #15414dff
surface.sunken = #00252fff
surface.knob = #e2edf1ff
surface.scrim = #00000080
surface.inverse = #e2edf1ff
surface.shadow = #00000096
text.normal = #e3f5f7ff
text.muted = #ddf6ffff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e2edf1ff
text.on_inverse = #0c0d0eff
line.divider = #00252fff
line.border = #00252fff
line.control_edge = #15505fff
@@ -8,6 +8,7 @@ surface.raised = #15414dff
surface.sunken = #00252fff
surface.knob = #e2edf1ff
surface.scrim = #00000080
surface.inverse = #e2edf1ff
surface.shadow = #00000096
text.normal = #e3f5f7ff
text.muted = #ddf6ffff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e2edf1ff
text.on_inverse = #0c0d0eff
line.divider = #00252fff
line.border = #00252fff
line.control_edge = #15505fff
@@ -8,6 +8,7 @@ surface.raised = #15414dff
surface.sunken = #00252fff
surface.knob = #e2edf1ff
surface.scrim = #00000080
surface.inverse = #e2edf1ff
surface.shadow = #00000096
text.normal = #839496ff
text.muted = #657b83ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e2edf1ff
text.on_inverse = #0c0d0eff
line.divider = #00252fff
line.border = #00252fff
line.control_edge = #15505fff
@@ -8,6 +8,7 @@ surface.raised = #15414dff
surface.sunken = #00252fff
surface.knob = #e2edf1ff
surface.scrim = #00000080
surface.inverse = #e2edf1ff
surface.shadow = #00000096
text.normal = #839496ff
text.muted = #657b83ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #ffffffff
text.on_status = #000000ff
text.on_selected = #e2edf1ff
text.on_inverse = #0c0d0eff
line.divider = #00252fff
line.border = #00252fff
line.control_edge = #15505fff
@@ -8,6 +8,7 @@ surface.raised = #232325ff
surface.sunken = #232326ff
surface.knob = #ebebecff
surface.scrim = #00000080
surface.inverse = #ebebecff
surface.shadow = #0000008c
text.normal = #ececf0ff
text.muted = #c8c8d0ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #0c0c0eff
text.on_status = #000000ff
text.on_selected = #ebebecff
text.on_inverse = #0d0d0dff
line.divider = #26262aff
line.border = #28282cff
line.control_edge = #343439ff
@@ -8,6 +8,7 @@ surface.raised = #232325ff
surface.sunken = #232326ff
surface.knob = #ebebecff
surface.scrim = #00000080
surface.inverse = #ebebecff
surface.shadow = #0000008c
text.normal = #ececf0ff
text.muted = #c8c8d0ff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #0c0c0eff
text.on_status = #000000ff
text.on_selected = #ebebecff
text.on_inverse = #0d0d0dff
line.divider = #26262aff
line.border = #28282cff
line.control_edge = #343439ff
@@ -8,6 +8,7 @@ surface.raised = #232325ff
surface.sunken = #232326ff
surface.knob = #ebebecff
surface.scrim = #00000080
surface.inverse = #ebebecff
surface.shadow = #0000008c
text.normal = #ececf0ff
text.muted = #96969eff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #0c0c0eff
text.on_status = #000000ff
text.on_selected = #ebebecff
text.on_inverse = #0d0d0dff
line.divider = #26262aff
line.border = #28282cff
line.control_edge = #343439ff
@@ -8,6 +8,7 @@ surface.raised = #232325ff
surface.sunken = #232326ff
surface.knob = #ebebecff
surface.scrim = #00000080
surface.inverse = #ebebecff
surface.shadow = #0000008c
text.normal = #ececf0ff
text.muted = #96969eff
@@ -17,6 +18,7 @@ text.on_accent = #000000ff
text.on_strong = #0c0c0eff
text.on_status = #000000ff
text.on_selected = #ebebecff
text.on_inverse = #0d0d0dff
line.divider = #26262aff
line.border = #28282cff
line.control_edge = #343439ff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #f2f2f5ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262627ff
surface.shadow = #00000032
text.normal = #18181cff
text.muted = #45444eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #fafafcff
text.on_status = #000000ff
text.on_selected = #262627ff
text.on_inverse = #fcfcfcff
line.divider = #e2e2e8ff
line.border = #dedee4ff
line.control_edge = #d6d6dcff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #f2f2f5ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262627ff
surface.shadow = #00000032
text.normal = #18181cff
text.muted = #45444eff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #fafafcff
text.on_status = #000000ff
text.on_selected = #262627ff
text.on_inverse = #fcfcfcff
line.divider = #e2e2e8ff
line.border = #dedee4ff
line.control_edge = #d6d6dcff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #f2f2f5ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262627ff
surface.shadow = #00000032
text.normal = #18181cff
text.muted = #60606aff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #fafafcff
text.on_status = #000000ff
text.on_selected = #262627ff
text.on_inverse = #fcfcfcff
line.divider = #e2e2e8ff
line.border = #dedee4ff
line.control_edge = #d6d6dcff
@@ -8,6 +8,7 @@ surface.raised = #ffffffff
surface.sunken = #f2f2f5ff
surface.knob = #fcfcfcff
surface.scrim = #00000059
surface.inverse = #262627ff
surface.shadow = #00000032
text.normal = #18181cff
text.muted = #60606aff
@@ -17,6 +18,7 @@ text.on_accent = #ffffffff
text.on_strong = #fafafcff
text.on_status = #000000ff
text.on_selected = #262627ff
text.on_inverse = #fcfcfcff
line.divider = #e2e2e8ff
line.border = #dedee4ff
line.control_edge = #d6d6dcff
+12 -4
View File
@@ -29,6 +29,10 @@ pub enum NoticeLayout {
/// The inline layout on a floating surface, the card width wide where the room allows: a toast. A card of a status
/// tone draws its edge and title in the tone's colour.
Card,
/// The card on the inverse surface (`surface.inverse`, with `text.on_inverse`): light on a dark theme, dark on a
/// light one. Toasts use it. The size and layout are the card's; a status tone draws its icon and edge in the
/// tone's colour.
Toast,
/// Icon, title, message and actions in a column centred in the room, at most the reading width wide: an empty
/// state. The first action is the primary button and the others secondary, all as wide as the widest, side by side
/// or stacked when they do not fit.
@@ -530,8 +534,11 @@ impl Component for Notice<'_> {
cx.tokens.space.gap.stack,
)
}
NoticeLayout::Card => {
let fill = StyleColor(cx.surface(SurfaceKind::Floating).fill);
NoticeLayout::Card | NoticeLayout::Toast => {
let toast = key.layout == NoticeLayout::Toast;
let colors = &cx.tokens.color;
let fill = if toast { cx.color(colors.surface.inverse) } else { StyleColor(cx.surface(SurfaceKind::Floating).fill) };
let normal = if toast { cx.color(colors.text.on_inverse) } else { normal };
let mut surface =
SurfaceLook::new(Stateful::new(fill)).kind(SurfaceKind::Floating).radius(UiTokens::corner(cx.tokens.shape.radius.surface));
// A card of a status tone carries the tone on its edge and title; a neutral card keeps the surface's edge.
@@ -539,7 +546,8 @@ impl Component for Notice<'_> {
normal
} else {
surface = surface.border(stateful(tone), cx.tokens.stroke.thin).border_replaces_edge();
tone
// Tone text is tuned for the ordinary surfaces, not the inverse one.
if toast { normal } else { tone }
};
(
TextLook::new(TypeRole::BodyStrong, stateful(title)),
@@ -589,7 +597,7 @@ impl Component for Notice<'_> {
let width = match (self.layout, cx.room) {
// The card is as wide as its text, up to the card width (padding included) where the room allows. A card
// that hosts content (a progress bar) has no text width of its own and takes the card width.
(NoticeLayout::Card, room) => {
(NoticeLayout::Card | NoticeLayout::Toast, room) => {
let padding = cx.style.metrics.padding;
let cap = cx.style.card_width - padding.start - padding.end;
let width = if self.content_sizes.is_empty() { natural.min(cap) } else { cap };
+7 -3
View File
@@ -1,4 +1,4 @@
//! The toast stack: draws the toast queue's cards as `Notice`s in `NoticeLayout::Card`.
//! The toast stack: draws the toast queue's cards as `Notice`s in `NoticeLayout::Toast`.
use crate::contract::toast::{CardOutcome, ToastHost};
use crate::contract::{Props as _, Show as _};
@@ -24,8 +24,12 @@ impl ToastStack {
/// Shows the queue at a bottom alignment of the body, or its locale's trailing bottom corner when `None`.
pub fn show_at(ui: &Ui, window: &WindowKey, body: Rect, alignment: Option<Align2>) {
ToastHost::show_at(ui, window, body, alignment, &mut |ui, toast, salt| {
let mut notice =
Notice::new(toast.tone, toast.message.clone()).layout(NoticeLayout::Card).lines(toast.lines.clone()).dismiss().id_salt(salt);
let mut notice = Notice::new(toast.tone, toast.message.clone()).layout(NoticeLayout::Toast).lines(toast.lines.clone()).id_salt(salt);
// A toast that leaves by itself and offers no action has no close button, as the old apps' toasts; one the
// user must close (no timeout) or that holds actions keeps it.
if toast.timeout.is_none() || !toast.actions.is_empty() {
notice = notice.dismiss();
}
if let Some(title) = &toast.title {
notice = notice.title(title.clone());
}
+32
View File
@@ -184,3 +184,35 @@ fn a_card_is_as_wide_as_its_text_up_to_the_card_width() {
assert!(short < long, "a short card is narrower than a long one: {short} vs {long}");
assert!(long < 400.0, "a long card wraps at the card width: {long}");
}
fn luminance(color: egui::Color32) -> f32 {
f32::from(color.r()) * 0.2126 + f32::from(color.g()) * 0.7152 + f32::from(color.b()) * 0.0722
}
fn rect_fills(shapes: &[egui::Shape], out: &mut Vec<(Rect, egui::Color32)>) {
for shape in shapes {
match shape {
egui::Shape::Vec(inner) => rect_fills(inner, out),
egui::Shape::Rect(rect) if rect.fill.a() == 255 => out.push((rect.rect, rect.fill)),
_ => {}
}
}
}
/// A toast sits on the inverse surface: light on a dark theme and dark on a light one, with its text the other way.
#[trial]
fn a_toast_is_light_on_a_dark_theme_and_dark_on_a_light_one() {
use craft_theme::{Contrast, Mode};
for (mode, light_card) in [(Mode::Dark, true), (Mode::Light, false)] {
let mut fixture = Fixture::new(|ui| {
Notice::new(Tone::Neutral, "No recent files").layout(NoticeLayout::Toast).show(ui);
});
fixture.theme(mode, Contrast::Standard).settle();
let shapes = fixture.frame_shapes();
let mut fills = Vec::new();
rect_fills(&shapes, &mut fills);
let text = fixture.texts().iter().find(|run| run.text == "No recent files").expect("the message is painted").rect;
let card = fills.iter().filter(|(rect, _)| rect.contains_rect(text)).min_by(|a, b| a.0.area().total_cmp(&b.0.area())).expect("a card under the text");
assert_eq!(luminance(card.1) > 128.0, light_card, "{mode:?}: the toast's card is {:?}", card.1);
}
}
+1 -1
View File
@@ -92,7 +92,7 @@ High contrast meets every minimum below: it moves pinned values that miss one. S
| Pair | Standard | High |
|---|---|---|
| `text.normal`, `text.muted`, `text.faint` on surfaces (background, panel, chrome, raised, sunken), `state.hover` and `state.pressed` | 4.5 | 7 |
| `text.on_selected` on `state.selected` and `state.selected_hover` | 4.5 | 7 |
| `text.on_selected` on `state.selected` and `state.selected_hover`; `text.on_inverse` on `surface.inverse` | 4.5 | 7 |
| `accent.text` on `surface.panel`, `surface.raised` and `surface.sunken`; `accent.on_soft` on `accent.soft` | 4.5 | 7 |
| Status text (`status.good.fg` ...) on `surface.panel`, `surface.raised` and its own `status.*.bg` | 4.5 | 7 |
| `text.on_accent` on `accent.solid`, `accent.hover` and `accent.pressed`; `text.on_strong` on `accent.strong`, `accent.strong_hover` and `accent.strong_pressed`; `text.on_status` on the status solids and their hover and pressed steps | 4.5 | 7 |