swarm ui: landmarks, a skip link, a page heading, named repeated buttons and a log role on the terminal
The shell now has a main landmark that takes the focus when a page opens, a skip link as the first Tab stop, a labelled nav, aria-current on the active tab, and a hidden h1 with the page's name (no page drew one). The tab close button and tab link get a visible focus ring and a larger target. Repeated edit, remove, delete, fire now, pause, duplicate buttons and the icon-only terminal, expand and close badges get a name that says what they act on (Button gains ariaLabel). A badge can be pressed (aria-pressed), used for the internet modes and the SSH target form, whose fake tablist is now a labelled group. The terminal is a focusable role=log with live announcements off, and a latest badge scrolls back to the newest row once the operator has scrolled up and the terminal has stopped following.
This commit is contained in:
parent
1ca82b3e09
commit
c9e6cd2e61
21 changed files with 218 additions and 17 deletions
|
|
@ -153,6 +153,15 @@ the browser gives up on the stream, a **reconnect** badge opens it again. The
|
||||||
terminal's own tab keeps these badges, with the model, beside the agent's name;
|
terminal's own tab keeps these badges, with the model, beside the agent's name;
|
||||||
the turn-state badge says how long the agent has been in that state.
|
the turn-state badge says how long the agent has been in that state.
|
||||||
|
|
||||||
|
The terminal is a `role="log"` that takes the keyboard focus, so the arrow keys
|
||||||
|
scroll it, and it doesn't announce new rows, since many can arrive in a second.
|
||||||
|
Once you scroll up it stops following the newest row, and a **latest** badge over
|
||||||
|
its bottom-right corner scrolls back and follows again.
|
||||||
|
|
||||||
|
The page around it has a skip link (**skip to content**, the first Tab stop), a
|
||||||
|
`<main>` landmark that takes the focus when a page opens, and a hidden `<h1>`
|
||||||
|
with the page's name. The active tab in the header carries `aria-current`.
|
||||||
|
|
||||||
The connection is a **light** on the agent's icon in the name badge: green when
|
The connection is a **light** on the agent's icon in the name badge: green when
|
||||||
the stream is live, amber while it connects or reconnects, red when it closes.
|
the stream is live, amber while it connects or reconnects, red when it closes.
|
||||||
In the card's preview, which has no name badge, the light stands alone. The
|
In the card's preview, which has no name badge, the light stands alone. The
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,11 @@ export interface BadgeProps {
|
||||||
* is an icon and a number, say.
|
* is an icon and a number, say.
|
||||||
*/
|
*/
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
|
/**
|
||||||
|
* A badge that is one choice of a few: whether it is the chosen one, said to a
|
||||||
|
* screen reader (`aria-pressed`). Its look already says it, by fill.
|
||||||
|
*/
|
||||||
|
pressed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Badge({
|
export function Badge({
|
||||||
|
|
@ -92,13 +97,17 @@ export function Badge({
|
||||||
class: extraClass,
|
class: extraClass,
|
||||||
title,
|
title,
|
||||||
ariaLabel,
|
ariaLabel,
|
||||||
|
pressed,
|
||||||
}: BadgeProps) {
|
}: BadgeProps) {
|
||||||
// `disabled` alone still means "button, just not clickable right
|
// `disabled` alone still means "button, just not clickable right
|
||||||
// now" — see the prop's own doc above for why this can't just check
|
// now" — see the prop's own doc above for why this can't just check
|
||||||
// `onClick`. Both the branch below and the interactive-styling class
|
// `onClick`. Both the branch below and the interactive-styling class
|
||||||
// key off this one derived flag, not off `onClick` separately, so
|
// key off this one derived flag, not off `onClick` separately, so
|
||||||
// they can no longer drift apart the way they used to.
|
// they can no longer drift apart the way they used to.
|
||||||
const interactive = Boolean(onClick) || Boolean(disabled);
|
// A `pressed` badge is a toggle, so it is a button even when it is the one
|
||||||
|
// already chosen and has nothing to do on a click.
|
||||||
|
const interactive =
|
||||||
|
Boolean(onClick) || Boolean(disabled) || pressed !== undefined;
|
||||||
const classes = [
|
const classes = [
|
||||||
"ui-badge",
|
"ui-badge",
|
||||||
`ui-badge-${tone}`,
|
`ui-badge-${tone}`,
|
||||||
|
|
@ -127,6 +136,7 @@ export function Badge({
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-expanded={expanded}
|
aria-expanded={expanded}
|
||||||
|
aria-pressed={pressed}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -238,3 +238,25 @@ export function GripIcon() {
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An arrow pointing down at a line, for "scroll to the end". Same size and
|
||||||
|
// stroke as `ExpandIcon`.
|
||||||
|
export function ArrowDownIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width="1.3em"
|
||||||
|
height="1.3em"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<line x1="12" y1="4" x2="12" y2="16" />
|
||||||
|
<polyline points="6 11 12 17 18 11" />
|
||||||
|
<line x1="5" y1="21" x2="19" y2="21" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,7 @@ export function AgentInference({ agent }: { agent: string }) {
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value="edit"
|
value="edit"
|
||||||
|
ariaLabel={`edit ${agent}'s inference settings`}
|
||||||
title={`set the swarm's model, effort, subagent models, subagent cap and context limits for ${agent}`}
|
title={`set the swarm's model, effort, subagent models, subagent cap and context limits for ${agent}`}
|
||||||
onClick={() => setEditing(true)}
|
onClick={() => setEditing(true)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ export function AgentInstructions({ agent }: { agent: string }) {
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value="edit"
|
value="edit"
|
||||||
|
ariaLabel={`edit ${agent}'s AGENTS.md`}
|
||||||
title={`read and change ${agent}'s AGENTS.md`}
|
title={`read and change ${agent}'s AGENTS.md`}
|
||||||
onClick={() => setEditing(true)}
|
onClick={() => setEditing(true)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,7 @@ export function AgentLimits({ agent }: { agent: string }) {
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value="edit"
|
value="edit"
|
||||||
|
ariaLabel={`edit ${agent}'s resource caps`}
|
||||||
title={`set the swarm's CPU and memory caps for ${agent}`}
|
title={`set the swarm's CPU and memory caps for ${agent}`}
|
||||||
onClick={() => setEditing(true)}
|
onClick={() => setEditing(true)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,7 @@ export function AgentInternet({ agent, g }: { agent: string; g: GrantState }) {
|
||||||
<Badge
|
<Badge
|
||||||
variant={m === mode ? "default" : "quiet"}
|
variant={m === mode ? "default" : "quiet"}
|
||||||
tone={m === mode ? "accent" : "neutral"}
|
tone={m === mode ? "accent" : "neutral"}
|
||||||
|
pressed={m === mode}
|
||||||
value={label}
|
value={label}
|
||||||
title={`${meaning} for ${agent}`}
|
title={`${meaning} for ${agent}`}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,13 @@ export function AgentSsh({ agent, g }: { agent: string; g: GrantState }) {
|
||||||
<code><user></code> replaced by the account it logs in as.
|
<code><user></code> replaced by the account it logs in as.
|
||||||
The key is the swarm's CA, a public value.
|
The key is the swarm's CA, a public value.
|
||||||
</p>
|
</p>
|
||||||
<div role="tablist" aria-label="target kind">
|
<div role="group" aria-label="target kind">
|
||||||
{TARGET_FORMS.map(([f, label]) => (
|
{TARGET_FORMS.map(([f, label]) => (
|
||||||
<Badge
|
<Badge
|
||||||
key={f}
|
key={f}
|
||||||
variant={f === form ? "default" : "quiet"}
|
variant={f === form ? "default" : "quiet"}
|
||||||
tone={f === form ? "accent" : "neutral"}
|
tone={f === form ? "accent" : "neutral"}
|
||||||
|
pressed={f === form}
|
||||||
value={label}
|
value={label}
|
||||||
onClick={() => setForm(f)}
|
onClick={() => setForm(f)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ export function AllowedDomains({ agent }: { agent: string }) {
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value="remove"
|
value="remove"
|
||||||
|
ariaLabel={`remove ${e.domain}`}
|
||||||
title={`stop allowing ${e.domain} for ${
|
title={`stop allowing ${e.domain} for ${
|
||||||
e.agent === undefined ? "every agent" : agent
|
e.agent === undefined ? "every agent" : agent
|
||||||
}`}
|
}`}
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,7 @@ export function LinkedAccounts({
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value="delete"
|
value="delete"
|
||||||
|
ariaLabel={`delete the ${accountKindLabel(a.kind)} account ${a.name}`}
|
||||||
title={`delete the ${accountKindLabel(a.kind)} account ${a.name}`}
|
title={`delete the ${accountKindLabel(a.kind)} account ${a.name}`}
|
||||||
onClick={() => openDelete(a)}
|
onClick={() => openDelete(a)}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ export function AgentCard({
|
||||||
<Badge
|
<Badge
|
||||||
variant="quiet"
|
variant="quiet"
|
||||||
value={<TerminalIcon />}
|
value={<TerminalIcon />}
|
||||||
|
ariaLabel={`open ${row.name}'s terminal`}
|
||||||
title={`open ${row.name}'s terminal in its own tab`}
|
title={`open ${row.name}'s terminal in its own tab`}
|
||||||
onClick={() => openTab({ href: term.page, label: term.label })}
|
onClick={() => openTab({ href: term.page, label: term.label })}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,18 @@
|
||||||
padding-block-end: 4.8em;
|
padding-block-end: 4.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The way back to the newest row, over the terminal's bottom-right corner,
|
||||||
|
above the message box where there is one. */
|
||||||
|
.ui-agent-term-preview-latest {
|
||||||
|
position: absolute;
|
||||||
|
right: 1.8em;
|
||||||
|
bottom: 1em;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.ui-agent-term-preview-with-input .ui-agent-term-preview-latest {
|
||||||
|
bottom: 5.4em;
|
||||||
|
}
|
||||||
|
|
||||||
.ui-agent-term-preview-wrap.terminal-wrap {
|
.ui-agent-term-preview-wrap.terminal-wrap {
|
||||||
max-height: 18em;
|
max-height: 18em;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
import { useLayoutEffect, useRef, useState } from "preact/hooks";
|
||||||
import type { ComponentChildren } from "preact";
|
import type { ComponentChildren } from "preact";
|
||||||
import { Badge } from "@hive/shared/badge.js";
|
import { Badge } from "@hive/shared/badge.js";
|
||||||
import { ExpandIcon } from "@hive/shared/icons.js";
|
import { ArrowDownIcon, ExpandIcon } from "@hive/shared/icons.js";
|
||||||
import { Row } from "@hive/shared/term-row.js";
|
import { Row } from "@hive/shared/term-row.js";
|
||||||
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
import { useDynamicTabs } from "../../shell/useDynamicTabs.js";
|
||||||
import {
|
import {
|
||||||
|
|
@ -146,7 +146,18 @@ export function AgentTermPreview({
|
||||||
<div class="ui-agent-term-preview-trailing">{trailing}</div>
|
<div class="ui-agent-term-preview-trailing">{trailing}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="live terminal" ref={logRef} onScroll={handleScroll}>
|
{/* A log, so a screen reader knows what it is; `aria-live="off"` as
|
||||||
|
rows can arrive many a second, and the operator reads them on
|
||||||
|
demand. Focusable, so the arrow keys scroll it. */}
|
||||||
|
<div
|
||||||
|
class="live terminal"
|
||||||
|
role="log"
|
||||||
|
aria-live="off"
|
||||||
|
aria-label={`${paths.label} terminal`}
|
||||||
|
tabIndex={0}
|
||||||
|
ref={logRef}
|
||||||
|
onScroll={handleScroll}
|
||||||
|
>
|
||||||
{rows.length === 0 ? (
|
{rows.length === 0 ? (
|
||||||
<div class="row note">
|
<div class="row note">
|
||||||
{/* Explicit `.row-content` wrapper, not a bare text child —
|
{/* Explicit `.row-content` wrapper, not a bare text child —
|
||||||
|
|
@ -168,6 +179,17 @@ export function AgentTermPreview({
|
||||||
rows.map((row) => <Row key={row.key} row={row} />)
|
rows.map((row) => <Row key={row.key} row={row} />)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{/* Scrolled up, the terminal stops following: this is the way back. */}
|
||||||
|
{!stickToBottom && rows.length > 0 && (
|
||||||
|
<div class="ui-agent-term-preview-latest">
|
||||||
|
<Badge
|
||||||
|
icon={<ArrowDownIcon />}
|
||||||
|
value="latest"
|
||||||
|
title="scroll to the newest row and follow it again"
|
||||||
|
onClick={() => setStickToBottom(true)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{subagent === undefined && <AgentInputForm agentName={agentName} />}
|
{subagent === undefined && <AgentInputForm agentName={agentName} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,7 @@ export function AgentGroupPage({
|
||||||
<>
|
<>
|
||||||
<Badge
|
<Badge
|
||||||
value={<ExpandIcon />}
|
value={<ExpandIcon />}
|
||||||
|
ariaLabel={`open ${key}'s terminal on its own`}
|
||||||
title={`maximize: open ${key}'s terminal on its own`}
|
title={`maximize: open ${key}'s terminal on its own`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
open({
|
open({
|
||||||
|
|
@ -159,6 +160,7 @@ export function AgentGroupPage({
|
||||||
/>
|
/>
|
||||||
<Badge
|
<Badge
|
||||||
value={<CloseIcon />}
|
value={<CloseIcon />}
|
||||||
|
ariaLabel={`take ${key} out of this group`}
|
||||||
title={`close: take ${key} out of this group`}
|
title={`close: take ${key} out of this group`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
groups.update(id, (r) => removeAgent(r, key) ?? r)
|
groups.update(id, (r) => removeAgent(r, key) ?? r)
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,10 @@ export function NotificationRouter() {
|
||||||
onChange={(checked) => setBuiltin(flow.id, checked)}
|
onChange={(checked) => setBuiltin(flow.id, checked)}
|
||||||
/>
|
/>
|
||||||
<ActionRow class="notify-flow-actions">
|
<ActionRow class="notify-flow-actions">
|
||||||
<Button onClick={() => draftFrom(flow.id)}>
|
<Button
|
||||||
|
onClick={() => draftFrom(flow.id)}
|
||||||
|
ariaLabel={`duplicate to edit ${flow.name}`}
|
||||||
|
>
|
||||||
duplicate to edit
|
duplicate to edit
|
||||||
</Button>
|
</Button>
|
||||||
</ActionRow>
|
</ActionRow>
|
||||||
|
|
@ -188,7 +191,12 @@ export function NotificationRouter() {
|
||||||
onChange={(checked) => setBuiltin(af.key, checked)}
|
onChange={(checked) => setBuiltin(af.key, checked)}
|
||||||
/>
|
/>
|
||||||
<ActionRow class="notify-flow-actions">
|
<ActionRow class="notify-flow-actions">
|
||||||
<Button onClick={() => draftFrom(af.key)}>duplicate</Button>
|
<Button
|
||||||
|
onClick={() => draftFrom(af.key)}
|
||||||
|
ariaLabel={`duplicate ${af.key}`}
|
||||||
|
>
|
||||||
|
duplicate
|
||||||
|
</Button>
|
||||||
</ActionRow>
|
</ActionRow>
|
||||||
</div>
|
</div>
|
||||||
<div class="notify-flow-agents">
|
<div class="notify-flow-agents">
|
||||||
|
|
@ -232,13 +240,19 @@ export function NotificationRouter() {
|
||||||
</span>
|
</span>
|
||||||
<ActionRow class="notify-flow-actions">
|
<ActionRow class="notify-flow-actions">
|
||||||
<Button
|
<Button
|
||||||
|
ariaLabel={`edit ${flow.name}`}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/notifications/${encodeURIComponent(flow.id)}`)
|
navigate(`/notifications/${encodeURIComponent(flow.id)}`)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
edit
|
edit
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => draftFrom(flow.id)}>duplicate</Button>
|
<Button
|
||||||
|
onClick={() => draftFrom(flow.id)}
|
||||||
|
ariaLabel={`duplicate ${flow.name}`}
|
||||||
|
>
|
||||||
|
duplicate
|
||||||
|
</Button>
|
||||||
</ActionRow>
|
</ActionRow>
|
||||||
</div>
|
</div>
|
||||||
<FlowGraph flow={flow} hits={hitsOf(shown, flow.id)} />
|
<FlowGraph flow={flow} hits={hitsOf(shown, flow.id)} />
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,11 @@ export function ScheduleCard({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ActionRow align="end" class="ui-schedule-card-actions">
|
<ActionRow align="end" class="ui-schedule-card-actions">
|
||||||
<Button onClick={onEdit} disabled={pending}>
|
<Button
|
||||||
|
onClick={onEdit}
|
||||||
|
disabled={pending}
|
||||||
|
ariaLabel={`edit ${schedule.name}`}
|
||||||
|
>
|
||||||
edit
|
edit
|
||||||
</Button>
|
</Button>
|
||||||
<span
|
<span
|
||||||
|
|
@ -89,14 +93,26 @@ export function ScheduleCard({
|
||||||
: "fires it now: its start moves to this moment, so it repeats from now on"
|
: "fires it now: its start moves to this moment, so it repeats from now on"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button onClick={onFireNow} disabled={pending || schedule.paused}>
|
<Button
|
||||||
|
onClick={onFireNow}
|
||||||
|
disabled={pending || schedule.paused}
|
||||||
|
ariaLabel={`fire now ${schedule.name}`}
|
||||||
|
>
|
||||||
fire now
|
fire now
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
<Button onClick={onTogglePaused} disabled={pending}>
|
<Button
|
||||||
|
onClick={onTogglePaused}
|
||||||
|
disabled={pending}
|
||||||
|
ariaLabel={`${schedule.paused ? "resume" : "pause"} ${schedule.name}`}
|
||||||
|
>
|
||||||
{schedule.paused ? "resume" : "pause"}
|
{schedule.paused ? "resume" : "pause"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={onRemove} disabled={pending}>
|
<Button
|
||||||
|
onClick={onRemove}
|
||||||
|
disabled={pending}
|
||||||
|
ariaLabel={`remove ${schedule.name}`}
|
||||||
|
>
|
||||||
remove
|
remove
|
||||||
</Button>
|
</Button>
|
||||||
</ActionRow>
|
</ActionRow>
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,11 @@ function DomainSection({
|
||||||
{swarmWide.map((e) => (
|
{swarmWide.map((e) => (
|
||||||
<li key={e.domain}>
|
<li key={e.domain}>
|
||||||
<code>{e.domain}</code>
|
<code>{e.domain}</code>
|
||||||
<Button disabled={busy} onClick={() => void remove(e)}>
|
<Button
|
||||||
|
disabled={busy}
|
||||||
|
ariaLabel={`remove ${e.domain}`}
|
||||||
|
onClick={() => void remove(e)}
|
||||||
|
>
|
||||||
remove
|
remove
|
||||||
</Button>
|
</Button>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,36 @@
|
||||||
all: unset;
|
all: unset;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
padding: 0.1em 0.3em;
|
padding: 0.25em 0.45em;
|
||||||
border-radius: 0.2em;
|
border-radius: 0.2em;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
/* `all: unset` drops the browser's focus ring, and so does the tab link's
|
||||||
|
own reset, so both draw one. */
|
||||||
|
.shell-tab-close:focus-visible,
|
||||||
|
.shell-tab-link:focus-visible {
|
||||||
|
outline: 2px solid var(--purple);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
/* A skip link, drawn only while it has the keyboard focus. */
|
||||||
|
.shell-skip-link {
|
||||||
|
position: absolute;
|
||||||
|
left: 0.5em;
|
||||||
|
top: -4em;
|
||||||
|
z-index: 100;
|
||||||
|
padding: 0.5em 1em;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
background: var(--bg-elev);
|
||||||
|
color: var(--fg);
|
||||||
|
border: 1px solid var(--purple);
|
||||||
|
}
|
||||||
|
.shell-skip-link:focus {
|
||||||
|
top: 0.5em;
|
||||||
|
}
|
||||||
|
/* The page container takes the focus when a page opens, and is not a control. */
|
||||||
|
.shell-body:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
.shell-tab-close:hover {
|
.shell-tab-close:hover {
|
||||||
color: var(--fg);
|
color: var(--fg);
|
||||||
background: color-mix(in srgb, var(--fg) 10%, transparent);
|
background: color-mix(in srgb, var(--fg) 10%, transparent);
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,11 @@ function NavLink({
|
||||||
textRef: (el: HTMLSpanElement | null) => void;
|
textRef: (el: HTMLSpanElement | null) => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Link href={href} className="shell-nav-link">
|
<Link
|
||||||
|
href={href}
|
||||||
|
className="shell-nav-link"
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
>
|
||||||
{/* Touch target (min-height) lives on the <a> so the whole row is
|
{/* Touch target (min-height) lives on the <a> so the whole row is
|
||||||
tappable. The underline lives on the shared
|
tappable. The underline lives on the shared
|
||||||
`.shell-nav-indicator`, not here — this span is still what
|
`.shell-nav-indicator`, not here — this span is still what
|
||||||
|
|
@ -216,6 +220,7 @@ function DynamicTabLink({
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href={href}
|
||||||
className="shell-tab-link"
|
className="shell-tab-link"
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
draggable={false}
|
draggable={false}
|
||||||
title={onRename === undefined ? undefined : "double click to rename"}
|
title={onRename === undefined ? undefined : "double click to rename"}
|
||||||
onDblClick={
|
onDblClick={
|
||||||
|
|
@ -249,6 +254,7 @@ export function Shell({ children }: { children: ComponentChildren }) {
|
||||||
const swarmName = useSwarmName();
|
const swarmName = useSwarmName();
|
||||||
const [location] = useLocation();
|
const [location] = useLocation();
|
||||||
const navRef = useRef<HTMLElement | null>(null);
|
const navRef = useRef<HTMLElement | null>(null);
|
||||||
|
const mainRef = useRef<HTMLElement | null>(null);
|
||||||
const textRefs = useRef<Record<string, HTMLSpanElement | null>>({});
|
const textRefs = useRef<Record<string, HTMLSpanElement | null>>({});
|
||||||
const [indicator, setIndicator] = useState<IndicatorRect | null>(null);
|
const [indicator, setIndicator] = useState<IndicatorRect | null>(null);
|
||||||
// The nav-item index the indicator is currently sitting at (or mid-hop
|
// The nav-item index the indicator is currently sitting at (or mid-hop
|
||||||
|
|
@ -409,6 +415,17 @@ export function Shell({ children }: { children: ComponentChildren }) {
|
||||||
document.title = pageLabel ? `${pageLabel} · ${brand}` : brand;
|
document.title = pageLabel ? `${pageLabel} · ${brand}` : brand;
|
||||||
}, [brand, pageLabel]);
|
}, [brand, pageLabel]);
|
||||||
|
|
||||||
|
// A new page starts at the top for the keyboard and a screen reader: the
|
||||||
|
// focus goes to the page's container, not left on the link that was used.
|
||||||
|
const firstPage = useRef(true);
|
||||||
|
useEffect(() => {
|
||||||
|
if (firstPage.current) {
|
||||||
|
firstPage.current = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mainRef.current?.focus({ preventScroll: true });
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
// Same value the indicator itself is drawn with, including mid-sweep —
|
// Same value the indicator itself is drawn with, including mid-sweep —
|
||||||
// the brand text rides the identical hop sequence rather than
|
// the brand text rides the identical hop sequence rather than
|
||||||
// computing its own, so "the header's accent" reads as one thing
|
// computing its own, so "the header's accent" reads as one thing
|
||||||
|
|
@ -417,6 +434,18 @@ export function Shell({ children }: { children: ComponentChildren }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={"shell" + (isFullBleedRoute(location) ? " shell-full" : "")}>
|
<div class={"shell" + (isFullBleedRoute(location) ? " shell-full" : "")}>
|
||||||
|
<a
|
||||||
|
class="shell-skip-link"
|
||||||
|
href="#main"
|
||||||
|
onClick={(e) => {
|
||||||
|
// A plain hash would hand the click to the router; move the focus
|
||||||
|
// here instead.
|
||||||
|
e.preventDefault();
|
||||||
|
mainRef.current?.focus();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
skip to content
|
||||||
|
</a>
|
||||||
<header class="shell-header">
|
<header class="shell-header">
|
||||||
<Link href="/" class="shell-brand-link">
|
<Link href="/" class="shell-brand-link">
|
||||||
<span
|
<span
|
||||||
|
|
@ -434,7 +463,7 @@ export function Shell({ children }: { children: ComponentChildren }) {
|
||||||
{brand}
|
{brand}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
<nav class="shell-nav" ref={navRef}>
|
<nav class="shell-nav" aria-label="main" ref={navRef}>
|
||||||
{navItems.map((item) => (
|
{navItems.map((item) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={item.href}
|
key={item.href}
|
||||||
|
|
@ -522,14 +551,23 @@ export function Shell({ children }: { children: ComponentChildren }) {
|
||||||
</header>
|
</header>
|
||||||
{/* Keyed by route so it remounts (and replays its entrance
|
{/* Keyed by route so it remounts (and replays its entrance
|
||||||
animation) on every navigation — see the file-top comment. */}
|
animation) on every navigation — see the file-top comment. */}
|
||||||
<div
|
<main
|
||||||
|
id="main"
|
||||||
|
tabIndex={-1}
|
||||||
|
ref={mainRef}
|
||||||
class={
|
class={
|
||||||
"shell-body" + (isFullBleedRoute(location) ? " shell-body-full" : "")
|
"shell-body" + (isFullBleedRoute(location) ? " shell-body-full" : "")
|
||||||
}
|
}
|
||||||
key={location}
|
key={location}
|
||||||
>
|
>
|
||||||
|
{/* The page's name for a screen reader. Only the start page draws an
|
||||||
|
`<h1>` of its own (the swarm's name), so it gets no second one;
|
||||||
|
the document title is the only other place the name shows. */}
|
||||||
|
{location !== "/" && (
|
||||||
|
<h1 class="ui-visually-hidden">{pageLabel ?? brand}</h1>
|
||||||
|
)}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,16 @@
|
||||||
a {
|
a {
|
||||||
color: var(--blue);
|
color: var(--blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Text for a screen reader that is not drawn: the page's `<h1>`. */
|
||||||
|
.ui-visually-hidden {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
margin: -1px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
clip-path: inset(50%);
|
||||||
|
white-space: nowrap;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue