audit toast
This commit is contained in:
+14
-19
@@ -12,7 +12,8 @@ use gpui::{
|
|||||||
use gpui_native_icons::{IconRole, icon};
|
use gpui_native_icons::{IconRole, icon};
|
||||||
use gpui_native_theme::ActiveTheme as _;
|
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`].
|
/// The action handler of a [`Toast`].
|
||||||
pub type ActionHandler = Rc<dyn Fn(&mut App)>;
|
pub type ActionHandler = Rc<dyn Fn(&mut App)>;
|
||||||
@@ -256,12 +257,13 @@ impl RenderOnce for ToastsView {
|
|||||||
fn pill(entry: &ToastEntry, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful<gpui::Div> {
|
fn pill(entry: &ToastEntry, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful<gpui::Div> {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let surface = theme.colors.surface;
|
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 foreground = theme.colors.foreground;
|
||||||
let muted = theme.colors.muted;
|
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 radius = theme.radius.full;
|
||||||
let shadows = theme.elevations.popover.shadows();
|
let shadows = theme.elevations.popover.shadows();
|
||||||
let icon_size = theme.sizes.small.icon_size;
|
let icon_size = theme.sizes.small.icon_size;
|
||||||
@@ -304,25 +306,18 @@ fn pill(entry: &ToastEntry, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful
|
|||||||
.when_some(toast.action.clone(), |pill, action| {
|
.when_some(toast.action.clone(), |pill, action| {
|
||||||
let toasts = toasts.clone();
|
let toasts = toasts.clone();
|
||||||
pill.child(
|
pill.child(
|
||||||
div()
|
div().flex_none().ml_2p5().child(
|
||||||
.id(("toast-action", id))
|
Button::new(("toast-action", id))
|
||||||
.flex_none()
|
.label(action.label.clone())
|
||||||
.ml_1p5()
|
.variant(ButtonVariant::Primary)
|
||||||
.cursor_pointer()
|
.small()
|
||||||
.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| {
|
.on_click(move |_, _window, cx| {
|
||||||
(action.handler.clone())(cx);
|
(action.handler.clone())(cx);
|
||||||
toasts.update(cx, |toasts, cx| {
|
toasts.update(cx, |toasts, cx| {
|
||||||
toasts.dismiss(id, cx);
|
toasts.dismiss(id, cx);
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
@@ -331,7 +326,7 @@ fn pill(entry: &ToastEntry, toasts: &Entity<Toasts>, cx: &App) -> gpui::Stateful
|
|||||||
.flex_none()
|
.flex_none()
|
||||||
.ml_4()
|
.ml_4()
|
||||||
.cursor_pointer()
|
.cursor_pointer()
|
||||||
.p_0p5()
|
.p_1()
|
||||||
.rounded(theme.radius.sm)
|
.rounded(theme.radius.sm)
|
||||||
.hover(|style| style.bg(muted))
|
.hover(|style| style.bg(muted))
|
||||||
.child(
|
.child(
|
||||||
|
|||||||
+4
-1
@@ -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
|
Platform metric adoption continues one component at a time; each stop goes
|
||||||
through the review gate and a gallery pass.
|
through the review gate and a gallery pass.
|
||||||
|
|
||||||
- [ ] **Toast platform chrome** — overlay border gate.
|
|
||||||
- [ ] **Tooltip platform chrome** — overlay border gate.
|
- [ ] **Tooltip platform chrome** — overlay border gate.
|
||||||
- [ ] **Alert platform chrome** — overlay border gate.
|
- [ ] **Alert platform chrome** — overlay border gate.
|
||||||
- [ ] **Combobox platform chrome** — popup border behind
|
- [ ] **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
|
- [x] Dialog platform chrome — the panel border behind
|
||||||
`Theme::borders.overlays` (and dark mode), taking the surface color
|
`Theme::borders.overlays` (and dark mode), taking the surface color
|
||||||
where the platform paints none
|
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,
|
- [x] Button, Checkbox, Switch, Radio + RadioGroup, Toggle, Link, Slider,
|
||||||
Progress, Avatar (image + seeded pixel-art fallback)
|
Progress, Avatar (image + seeded pixel-art fallback)
|
||||||
- [x] Spinner — painted ring + rotating-icon variant, indeterminate and
|
- [x] Spinner — painted ring + rotating-icon variant, indeterminate and
|
||||||
|
|||||||
Reference in New Issue
Block a user