Files
Danny White 3bca21b3f8 chore(a11y): convert leftover focus recipes to focus-ring (#48219)
## What kind of change does this PR introduce?

Accessibility cleanup (DEPR-628).

## What is the current behavior?

Leftover call sites still use ad-hoc focus recipes
(`ring-foreground-muted`, `outline-brand`, Dialog/Sheet `focus:` rings,
etc.) instead of the shared utilities from #41575.

## What is the new behavior?

Converts those leftovers across `packages/ui`, Studio, www, docs, and
design-system to `focus-ring`, preferring `focus-visible`. Keeps
documented exceptions (`group-focus-visible`, InputGroup `:has()`).

## To test

Tab through controls (keyboard only). Expect a consistent offset ring on
`:focus-visible`, not a green/brand/custom stack, and no ring animation.

### www (marketing)

Preview:
https://zone-www-dot-com-git-danny-depr-628-focus-ring-fbccf9-supabase.vercel.app

- Global nav on `/`: Product, Developers, Solutions dropdowns; logo;
hamburger + mobile menu
- `/features`: view toggles and feature cards
- `/company`: card links
- `/changelog`: timeline / entry links
- `/partners/catalog`: grid/list toggle and partner cards
- `/pricing`: compute section expand control
- Product / Modules / Solutions sticky navs on product pages (e.g.
`/database`, `/storage`)
- `/state-of-startups`: TwoOptionToggle if present

### docs

Preview:
https://docs-git-danny-depr-628-focus-ring-long-tail-supabase.vercel.app

- Any guide page: top nav dropdowns and items
- Narrow viewport: hamburger, then mobile menu links + close
- Guide with PromptPanel / tabs: tab to prompt actions and tab list

### studio (dashboard)

Preview:
https://studio-staging-git-danny-depr-628-focus-ring-long-tail-supabase.vercel.app

- Project home: Connect section tiles; drag-handle focus on sortable
sections
- Integrations marketplace (`/project/<ref>/integrations`): featured
cards, list/grid toggle, list rows
- Auth (`/project/<ref>/auth/oauth-apps`,
`/project/<ref>/auth/providers`): open create/edit sheet, tab to close
(X)
- Database policies (`/project/<ref>/database/policies`): open policy
editor sheet, tab to close
- Storage policies (`/project/<ref>/storage/files/policies`): bucket
section links; policy modal close
- Query performance (`/project/<ref>/observability/query-performance`):
info icon buttons on metrics
- Replication pipeline detail (if available): slot lag / status info
icons
- Support (`/support/new`): attachment add/remove controls
- Table editor: spreadsheet import preview checkboxes; row text/JSON
editor TwoOptionToggle
- Any Dialog/Sheet/toast close (X): ring on keyboard focus only, not
mouse click

### design-system

Preview:
https://design-system-git-danny-depr-628-focus-ring-long-tail-supabase.vercel.app

- Colour palette swatches (keyboard focus)
- Form patterns sidepanel example: avatar / focusable control in the
example

## Additional context

- Linear: [DEPR-628](https://linear.app/supabase/issue/DEPR-628)
- Follow-ups: form-group CSS (DEPR-629), Storage columns selection
(DEPR-630), ESLint rule (DEPR-632)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Accessibility & Usability**
* Standardized keyboard focus indicators across navigation, dialogs,
forms, buttons, toggles, links, and tooltips using a consolidated focus
style.
* Improved toggle controls to use proper button semantics (instead of
clickable text), including `aria-pressed`/disabled handling and better
keyboard navigation.

* **Visual Updates**
* Harmonized hover/focus ring visuals across the design system, Studio,
documentation, and marketing pages while preserving existing layout and
interaction behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-23 08:52:22 +10:00

137 lines
4.4 KiB
TypeScript

import { Info } from 'lucide-react'
import {
Badge,
cn,
Popover,
PopoverContent,
PopoverTrigger,
Tooltip,
TooltipContent,
TooltipTrigger,
} from 'ui'
import { SlotWalStatus } from './ReplicationPipelineStatus.types'
import { getWalStatusMeta, WAL_STATUS_LEGEND } from './ReplicationPipelineStatus.utils'
import { InlineLink } from '@/components/ui/InlineLink'
import { DOCS_URL } from '@/lib/constants'
export type SlotStatusContext = 'pipeline' | 'table'
const CONNECTION_TEXT: Record<SlotStatusContext, { active: string; inactive: string }> = {
pipeline: {
active: "This pipeline's replication slot is active and being used right now.",
inactive: "This pipeline's replication slot is not active right now.",
},
table: {
active: "This table's replication slot is active and being used right now.",
inactive: "This table's replication slot is not active right now.",
},
}
/**
* Colored badge for a slot's WAL status, with the plain-language meaning on hover.
* Pass `context="table"` in the per-table inline view to show table-specific descriptions.
*/
export const SlotStatusBadge = ({
status,
context = 'pipeline',
}: {
status?: SlotWalStatus
context?: SlotStatusContext
}) => {
const meta = getWalStatusMeta(status)
const description = context === 'table' ? meta.tableDescription : meta.description
return (
<Tooltip>
<TooltipTrigger asChild>
<Badge variant={meta.variant} className="cursor-default">
{meta.label}
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="max-w-[260px]">
{description}
</TooltipContent>
</Tooltip>
)
}
/**
* Info button opening a legend that explains every possible slot status.
*/
export const SlotStatusLegend = () => {
return (
<Popover>
<PopoverTrigger asChild>
<button
type="button"
tabIndex={0}
aria-label="What do the slot statuses mean?"
className="inline-flex h-4 w-4 items-center justify-center rounded-full bg-surface-200 text-foreground-lighter transition-colors hover:bg-surface-300 hover:text-foreground focus-ring"
>
<Info size={12} />
</button>
</PopoverTrigger>
<PopoverContent side="bottom" align="center" className="w-[26rem] p-0">
<div className="px-4 py-3 border-b border-overlay">
<p className="text-sm text-foreground">Slot statuses</p>
<p className="text-xs text-foreground-light">
How safely your database is keeping the changes the pipeline still needs.
</p>
</div>
<ul className="flex flex-col divide-y divide-overlay">
{WAL_STATUS_LEGEND.map((meta) => (
<li key={meta.label} className="flex items-start gap-x-3 px-4 py-2.5">
<div className="flex h-5 w-28 shrink-0 items-center">
<Badge variant={meta.variant}>{meta.label}</Badge>
</div>
<span className="flex-1 text-xs leading-5 text-foreground-light">
{meta.description}
</span>
</li>
))}
</ul>
<div className="border-t border-overlay px-4 py-2.5">
<InlineLink
href={`${DOCS_URL}/guides/database/replication/pipelines-monitoring`}
className="text-xs text-foreground-light"
>
Learn more about monitoring replication
</InlineLink>
</div>
</PopoverContent>
</Popover>
)
}
/**
* Small dot + label indicating whether the slot has a live replication connection.
* Pass `context="table"` in the per-table inline view to show table-specific descriptions.
*/
export const SlotConnectionIndicator = ({
isActive,
context = 'pipeline',
}: {
isActive?: boolean
context?: SlotStatusContext
}) => {
const text = CONNECTION_TEXT[context]
return (
<Tooltip>
<TooltipTrigger asChild>
<span className="flex items-center gap-x-1.5 text-xs text-foreground-light cursor-default">
<span
className={cn(
'h-1.5 w-1.5 rounded-full shrink-0',
isActive ? 'bg-brand' : 'bg-foreground-muted'
)}
/>
{isActive ? 'Connected' : 'Not connected'}
</span>
</TooltipTrigger>
<TooltipContent side="bottom" className="max-w-[260px]">
{isActive ? text.active : text.inactive}
</TooltipContent>
</Tooltip>
)
}