mirror of
https://github.com/supabase/supabase.git
synced 2026-09-07 02:20:52 +08:00
## 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 -->
118 lines
4.7 KiB
TypeScript
118 lines
4.7 KiB
TypeScript
import { Info } from 'lucide-react'
|
|
import { parseAsJson, useQueryStates } from 'nuqs'
|
|
import React, { useMemo } from 'react'
|
|
import { cn, Skeleton, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { useQueryPerformanceQuery } from './useQueryPerformanceQuery'
|
|
import { NumericFilter } from '@/components/interfaces/Reports/v2/ReportsNumericFilter'
|
|
|
|
export const QueryPerformanceMetrics = () => {
|
|
const { data: queryMetrics, isLoading } = useQueryPerformanceQuery({ preset: 'queryMetrics' })
|
|
|
|
const [, setSearchParams] = useQueryStates({
|
|
totalTimeFilter: parseAsJson<NumericFilter | null>((value) =>
|
|
value === null || value === undefined ? null : (value as NumericFilter)
|
|
),
|
|
})
|
|
|
|
const stats = useMemo(() => {
|
|
const slowQueriesTitle = queryMetrics?.[0]?.slow_queries === 1 ? 'Slow Query' : 'Slow Queries'
|
|
const slowQueriesValue = queryMetrics?.[0]?.slow_queries || '0'
|
|
|
|
return [
|
|
{
|
|
title: slowQueriesTitle,
|
|
value: slowQueriesValue,
|
|
onClick: () => {
|
|
setSearchParams({
|
|
totalTimeFilter: {
|
|
operator: '>',
|
|
value: 1000,
|
|
} as NumericFilter,
|
|
})
|
|
},
|
|
},
|
|
{
|
|
title: 'Cache Hit Rate',
|
|
value: queryMetrics?.[0]?.cache_hit_rate || '0%',
|
|
tooltip:
|
|
'Percentage of data read from cache vs disk. Higher is better - it means faster queries and less database load.',
|
|
},
|
|
{
|
|
title: 'Avg. Rows Per Call',
|
|
value: queryMetrics?.[0]?.avg_rows_per_call || '0',
|
|
tooltip:
|
|
'Average number of rows returned per query execution. Helps identify queries that return too much or too little data.',
|
|
},
|
|
]
|
|
}, [queryMetrics, setSearchParams])
|
|
|
|
return (
|
|
<section className="px-6 pt-2 pb-4 flex flex-wrap gap-x-6 gap-y-2 w-full">
|
|
{stats.map((card, i) => (
|
|
<React.Fragment key={i}>
|
|
<div
|
|
className={cn('flex items-baseline gap-2 heading-subSection text-foreground-light', {
|
|
'cursor-pointer hover:text-foreground transition-colors': card.onClick,
|
|
})}
|
|
onClick={card.onClick}
|
|
>
|
|
{isLoading ? (
|
|
<Skeleton className="h-5 w-24" />
|
|
) : (
|
|
<>
|
|
<span className="text-foreground">{card.value}</span>
|
|
<span className="flex items-center gap-1">
|
|
{card.title}
|
|
{(card.title === 'Slow Queries' || card.title === 'Slow Query') && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
type="button"
|
|
tabIndex={0}
|
|
aria-label="How are slow queries calculated?"
|
|
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"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
}}
|
|
>
|
|
<Info size={12} />
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top" align="start" className="max-w-xs text-xs">
|
|
Slow queries are those with total execution time (execution time + planning
|
|
time) greater than 1000ms.
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
{card.tooltip && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
type="button"
|
|
tabIndex={0}
|
|
aria-label={`What is ${card.title}?`}
|
|
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"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
}}
|
|
>
|
|
<Info size={12} />
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top" align="start" className="max-w-xs text-xs">
|
|
{card.tooltip}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
{i < stats.length - 1 && <span className="text-foreground-muted">/</span>}
|
|
</React.Fragment>
|
|
))}
|
|
</section>
|
|
)
|
|
}
|