Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions content/solid/turn-status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import { TurnStatus } from "@/components/ui/turn-status"
## With steps

Given children, the line is a button and opens to show them: the calls of the step in hand.
The activity label is announced by a separate status region, so the button keeps
its native role and updates to the clock and token count do not repeat the announcement.
When `label` is omitted or blank, the activity name supplies the announcement and
button name without adding visible text. Pass `label` to customize or translate it.

<ComponentPreview name="turn-status-steps" align="start" />

Expand Down
9 changes: 7 additions & 2 deletions src/components/ui/turn-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function TurnStatus({
const [open, setOpen] = React.useState(false)
const elapsed = useElapsed(since)
const opens = Boolean(children)
// The glyph is decorative. Even without visible words, expose the activity
// and keep the disclosure's name independent of the clock and token count.
const activityLabel = label?.trim() || activity

const line = (
<>
Expand All @@ -83,11 +86,13 @@ function TurnStatus({

return (
<div data-slot="turn-status" className={cn("flex flex-col gap-1.5", className)}>
{/* Announce activity changes without repeating the clock and count. */}
<span role="status" className="sr-only">{activityLabel}</span>
<div className="flex h-5 max-w-full items-center gap-1.5">
{opens ? (
<button
type="button"
role="status"
aria-label={activityLabel}
aria-expanded={open}
onClick={() => setOpen((value) => !value)}
className="flex w-fit max-w-full items-center gap-2 text-[12.5px] text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:text-foreground"
Expand All @@ -96,7 +101,7 @@ function TurnStatus({
<ChevronRight className={cn("size-3.5 shrink-0 transition-transform", open && "rotate-90")} />
</button>
) : (
<div role="status" className="flex w-fit max-w-full items-center gap-2 text-[12.5px] text-muted-foreground">
<div className="flex w-fit max-w-full items-center gap-2 text-[12.5px] text-muted-foreground">
{line}
</div>
)}
Expand Down
Loading