Toast · an alert or status role named by its title, so screen readers hear every notice
This commit is contained in:
1 file changed
+9
-1
@@ -3,7 +3,7 @@ use std::{rc::Rc, time::Duration};
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
Anchor, Animation, AnimationExt, AnyElement, App, ClickEvent, Context, ElementId, Entity,
|
Anchor, Animation, AnimationExt, AnyElement, App, ClickEvent, Context, ElementId, Entity,
|
||||||
FontWeight, HoverListenerMode, InteractiveElement, IntoElement, ParentElement, Pixels,
|
FontWeight, HoverListenerMode, InteractiveElement, IntoElement, ParentElement, Pixels,
|
||||||
RenderOnce, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas,
|
RenderOnce, Role, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas,
|
||||||
div, point, prelude::*, relative,
|
div, point, prelude::*, relative,
|
||||||
};
|
};
|
||||||
use web_time::Instant;
|
use web_time::Instant;
|
||||||
@@ -275,8 +275,16 @@ fn card(
|
|||||||
};
|
};
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let colors = &theme.colors;
|
let colors = &theme.colors;
|
||||||
|
// Read aloud: alerts interrupt, other notes wait their turn.
|
||||||
|
let role = match toast.severity {
|
||||||
|
Some(Severity::Danger | Severity::Warning) => Role::Alert,
|
||||||
|
_ => Role::Status,
|
||||||
|
};
|
||||||
let card = div()
|
let card = div()
|
||||||
.id(key.clone())
|
.id(key.clone())
|
||||||
|
.role(role)
|
||||||
|
.aria_label(toast.title.clone())
|
||||||
|
.when_some(toast.body.clone(), |card, body| card.aria_description(body))
|
||||||
.relative()
|
.relative()
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
|
|||||||
Reference in new issue
Block a user