mirror of
https://github.com/supabase/supabase.git
synced 2026-09-09 03:19:36 +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 -->
121 lines
4.6 KiB
TypeScript
121 lines
4.6 KiB
TypeScript
import { ChevronRight } from 'lucide-react'
|
|
import { useRouter } from 'next/router'
|
|
import { parseAsBoolean, parseAsString, useQueryState } from 'nuqs'
|
|
import { useEffect, useRef } from 'react'
|
|
import { Card, CardContent, cn } from 'ui'
|
|
|
|
import { useAvailableConnectModes } from '../ConnectSheet/useAvailableConnectModes'
|
|
import { CONNECT_ACTIONS } from './ConnectSection.config'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { BASE_PATH, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
|
|
export const ConnectSection = () => {
|
|
const router = useRouter()
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
const { setConnectSheetSource } = useAppStateSnapshot()
|
|
const track = useTrack()
|
|
const [, setShowConnect] = useQueryState('showConnect', parseAsBoolean.withDefault(false))
|
|
const [, setConnectTab] = useQueryState('connectTab', parseAsString)
|
|
|
|
const isActiveHealthy = selectedProject?.status === PROJECT_STATUS.ACTIVE_HEALTHY
|
|
|
|
const availableModeIds = useAvailableConnectModes()
|
|
const availableActions = CONNECT_ACTIONS.filter((action) =>
|
|
action.mode ? availableModeIds.includes(action.mode) : true
|
|
)
|
|
|
|
const hasTrackedExposure = useRef(false)
|
|
|
|
useEffect(() => {
|
|
if (!IS_PLATFORM) return
|
|
if (hasTrackedExposure.current) return
|
|
hasTrackedExposure.current = true
|
|
track('home_connect_section_exposed')
|
|
}, [track])
|
|
|
|
const handleActionClick = (action: (typeof CONNECT_ACTIONS)[number]) => {
|
|
track('home_connect_action_clicked', { mode: action.id })
|
|
|
|
if (action.mode) {
|
|
setConnectTab(action.mode)
|
|
setConnectSheetSource('connect_section')
|
|
setShowConnect(true)
|
|
return
|
|
}
|
|
|
|
if (action.href && selectedProject?.ref) {
|
|
router.push(action.href.replace('[ref]', selectedProject.ref))
|
|
}
|
|
}
|
|
|
|
return (
|
|
<section className="w-full">
|
|
<div className="mb-6">
|
|
<h3 className="heading-section">Get connected</h3>
|
|
</div>
|
|
|
|
<Card className="bg-background/25 border-dashed relative overflow-hidden">
|
|
<div className="absolute -inset-16 z-0 opacity-50">
|
|
<img
|
|
src={`${BASE_PATH}/img/reports/bg-grafana-dark.svg`}
|
|
alt=""
|
|
className="w-full h-full object-cover object-right hidden dark:block"
|
|
/>
|
|
<img
|
|
src={`${BASE_PATH}/img/reports/bg-grafana-light.svg`}
|
|
alt=""
|
|
className="w-full h-full object-cover object-right dark:hidden"
|
|
/>
|
|
<div className="absolute inset-0 bg-linear-to-r from-background-alternative to-transparent" />
|
|
</div>
|
|
|
|
<CardContent className="relative z-10 p-0">
|
|
<div className="grid grid-cols-1 xl:grid-cols-6 divide-y xl:divide-y-0 xl:divide-x border-muted">
|
|
{availableActions.map((action) => (
|
|
<button
|
|
key={action.id}
|
|
type="button"
|
|
tabIndex={
|
|
(action.requiresActiveProject ?? true)
|
|
? !isActiveHealthy
|
|
? -1
|
|
: 0
|
|
: !selectedProject?.ref
|
|
? -1
|
|
: 0
|
|
}
|
|
disabled={
|
|
(action.requiresActiveProject ?? true) ? !isActiveHealthy : !selectedProject?.ref
|
|
}
|
|
onClick={() => handleActionClick(action)}
|
|
className={cn(
|
|
'group flex items-center gap-3 p-4 text-left transition-colors min-h-[72px] w-full',
|
|
'hover:bg-surface-100 focus-ring',
|
|
'xl:min-h-32 xl:flex-col xl:justify-center xl:p-6 xl:text-center',
|
|
((action.requiresActiveProject ?? true)
|
|
? !isActiveHealthy
|
|
: !selectedProject?.ref) && 'cursor-not-allowed opacity-50'
|
|
)}
|
|
>
|
|
<span className="shrink-0 text-foreground-light group-hover:text-foreground">
|
|
{action.icon}
|
|
</span>
|
|
<div className="flex min-w-0 flex-1 flex-col gap-1 xl:flex-initial">
|
|
<p className="text-sm">{action.heading}</p>
|
|
<p className="text-sm text-foreground-lighter">{action.subheading}</p>
|
|
</div>
|
|
<ChevronRight
|
|
size={16}
|
|
className="shrink-0 text-foreground-lighter group-hover:text-foreground xl:hidden"
|
|
/>
|
|
</button>
|
|
))}
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</section>
|
|
)
|
|
}
|