From 65cae95851421674b23a02f790dd3f627aedced9 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Sat, 7 Nov 2026 20:25:14 +0700 Subject: [PATCH] audit toast --- crates/core/src/toast.rs | 45 ++++++++++++++++++---------------------- docs/CHECKLIST.md | 5 ++++- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/crates/core/src/toast.rs b/crates/core/src/toast.rs index ff0595c..c0e8045 100644 --- a/crates/core/src/toast.rs +++ b/crates/core/src/toast.rs @@ -12,7 +12,8 @@ use gpui::{ use gpui_native_icons::{IconRole, icon}; use gpui_native_theme::ActiveTheme as _; -use crate::common::DismissHandler; +use crate::button::{Button, ButtonVariant}; +use crate::common::{DismissHandler, Sizable as _}; /// The action handler of a [`Toast`]. pub type ActionHandler = Rc; @@ -256,12 +257,13 @@ impl RenderOnce for ToastsView { fn pill(entry: &ToastEntry, toasts: &Entity, cx: &App) -> gpui::Stateful { let theme = cx.theme(); let surface = theme.colors.surface; - let border = theme.colors.border; + let border = if theme.borders.overlays { + theme.colors.border + } else { + surface + }; let foreground = theme.colors.foreground; let muted = theme.colors.muted; - let primary = theme.ramps.primary.base; - let primary_hover = theme.ramps.primary.hover; - let primary_foreground = theme.colors.primary_foreground; let radius = theme.radius.full; let shadows = theme.elevations.popover.shadows(); let icon_size = theme.sizes.small.icon_size; @@ -304,25 +306,18 @@ fn pill(entry: &ToastEntry, toasts: &Entity, cx: &App) -> gpui::Stateful .when_some(toast.action.clone(), |pill, action| { let toasts = toasts.clone(); pill.child( - div() - .id(("toast-action", id)) - .flex_none() - .ml_1p5() - .cursor_pointer() - .px_2() - .py_0p5() - .rounded(radius) - .bg(primary) - .hover(|style| style.bg(primary_hover)) - .text_size(text_size) - .text_color(primary_foreground) - .child(action.label.clone()) - .on_click(move |_, _window, cx| { - (action.handler.clone())(cx); - toasts.update(cx, |toasts, cx| { - toasts.dismiss(id, cx); - }); - }), + div().flex_none().ml_2p5().child( + Button::new(("toast-action", id)) + .label(action.label.clone()) + .variant(ButtonVariant::Primary) + .small() + .on_click(move |_, _window, cx| { + (action.handler.clone())(cx); + toasts.update(cx, |toasts, cx| { + toasts.dismiss(id, cx); + }); + }), + ), ) }) .child( @@ -331,7 +326,7 @@ fn pill(entry: &ToastEntry, toasts: &Entity, cx: &App) -> gpui::Stateful .flex_none() .ml_4() .cursor_pointer() - .p_0p5() + .p_1() .rounded(theme.radius.sm) .hover(|style| style.bg(muted)) .child( diff --git a/docs/CHECKLIST.md b/docs/CHECKLIST.md index f980d0a..22a0dd7 100644 --- a/docs/CHECKLIST.md +++ b/docs/CHECKLIST.md @@ -14,7 +14,6 @@ is the first downstream consumer; its screens drive the order. Platform metric adoption continues one component at a time; each stop goes through the review gate and a gallery pass. -- [ ] **Toast platform chrome** — overlay border gate. - [ ] **Tooltip platform chrome** — overlay border gate. - [ ] **Alert platform chrome** — overlay border gate. - [ ] **Combobox platform chrome** — popup border behind @@ -115,6 +114,10 @@ Gaps surfaced by the signed comparison; ordered by signed's usage. - [x] Dialog platform chrome — the panel border behind `Theme::borders.overlays` (and dark mode), taking the surface color where the platform paints none +- [x] Toast platform chrome — the pill border behind + `Theme::borders.overlays` (and dark mode), taking the surface color + where the platform paints none; the pill rides the popover elevation, + so dark mode's no-shadow rule applies to it too - [x] Button, Checkbox, Switch, Radio + RadioGroup, Toggle, Link, Slider, Progress, Avatar (image + seeded pixel-art fallback) - [x] Spinner — painted ring + rotating-icon variant, indeterminate and