mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What kind of change does this PR introduce? Accessibility / lint hardening (Safari keyboard focus). ## What is the current behavior? `supabase/require-explicit-tabindex` is `'warn'`. Studio’s ratchet was at 0 but the rule was still ratcheted; www / docs / design-system still had raw `<button>` / `role="button"` call sites without an explicit `tabIndex`. [DEPR-627](https://linear.app/supabase/issue/DEPR-627) · follow-up to #47984 / #48040 ## What is the new behavior? - Shared config: `'supabase/require-explicit-tabindex': 'error'` - Swept www / docs / design-system (+ Studio test fixtures the ratchet skipped) - Removed the rule from the Studio ratchet + baselines ## To test Prefer **Safari**. This PR only adds explicit `tabIndex` to raw `<button>` / `role="button"` call sites — not links, and not controls that already go through `Button` from `ui`. ### Marketing (`www`) ([staging link](https://zone-www-dot-com-git-danny-depr-627-promote-req-7ae43c-supabase.vercel.app/)) - [x] Homepage frameworks / dashboard feature tabs — Tab through each tab button - [x] Product pages (e.g. `/auth`, `/database`) — section tab switchers - [x] Narrow viewport — open the hamburger; Tab through menu buttons - [x] `/partners/catalog` — filter / view controls - [x] Blog view toggle (list ↔ grid) ### Docs ([staging link](https://docs-git-danny-depr-627-promote-require-explici-25e46d-supabase.vercel.app/)) - [x] **Desktop (≥ lg):** top-right **⋯ menu** (hamburger icon) — opens a dropdown that includes Theme. Not a separate theme button. - [x] **Mobile (< lg):** top-right **hamburger** opens the sheet; close (X) is the raw button we tagged. Theme inside the sheet uses `ThemeToggle` / `DropdownMenuTrigger` from `ui` (already supposed to set `tabIndex`). - [x] **Code blocks** — copy / language controls - [x] **Is this helpful?** — X / check are `Button` from `ui` (should already Tab). After voting **while signed in**, the follow-up “What went well?” / “How can we improve?” text button is the raw one we tagged. - [x] **AI Tools → Copy as Markdown** (right rail on a guide) — this is the only GuidesSidebar control this PR changed. “On this page” TOC items are **links**, not covered by this lint. - [x] **Reference docs** (e.g. JS client reference) — section headers that expand/collapse in the left nav (`Collapsible.Trigger`) - [x] **Troubleshooting index** — type in the search field, then Tab to the **clear (X)** control ### Dashboard (`studio`) No production UI changes in this PR (tests + lint config only). Quick Safari smoke that prior tabindex work still holds: - [x] Project sidebar — Tab through primary nav links - [x] Settings → General — Tab through inputs / buttons - [x] Storage → Files — Tab a bucket row / file actions
116 lines
3.8 KiB
TypeScript
116 lines
3.8 KiB
TypeScript
import { AnimatePresence, motion, useInView } from 'framer-motion'
|
|
import { Check } from 'lucide-react'
|
|
import { useTheme } from 'next-themes'
|
|
import Link from 'next/link'
|
|
import React, { useRef, useState } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
import BrowserFrame from './BrowserFrame'
|
|
|
|
export type Tab = {
|
|
label: string
|
|
panel: React.FC<{ isDark: boolean }>
|
|
highlights: { label: string; link?: string }[]
|
|
}
|
|
|
|
interface Props {
|
|
tabs: Tab[]
|
|
}
|
|
|
|
const TabsWithHighlights = (props: Props) => {
|
|
const { resolvedTheme } = useTheme()
|
|
const [activeTabIdx, setActiveTabIdx] = useState<number>(0)
|
|
const sectionRef = useRef(null)
|
|
const isInView = useInView(sectionRef, { once: true })
|
|
|
|
const Panel: any = props.tabs[activeTabIdx]?.panel ?? null
|
|
const highlights = props.tabs[activeTabIdx]?.highlights ?? [null]
|
|
|
|
const handleTabClick = (tabIndex: number) => {
|
|
setActiveTabIdx(tabIndex)
|
|
}
|
|
|
|
return (
|
|
<div className="relative flex flex-col gap-8 lg:gap-12 items-center">
|
|
{/* Threshold element used to load video 500px before reaching the video component */}
|
|
<div ref={sectionRef} className="absolute top-[-500px] not-sr-only" />
|
|
<div className="relative w-full col-span-full flex justify-center gap-2" role="tablist">
|
|
{props.tabs.map((tab, index) => (
|
|
<Tab
|
|
key={index}
|
|
isActive={index === activeTabIdx}
|
|
label={tab.label}
|
|
onClick={() => handleTabClick(index)}
|
|
/>
|
|
))}
|
|
</div>
|
|
<AnimatePresence mode="wait">
|
|
<motion.ul
|
|
key={props.tabs[activeTabIdx]?.label}
|
|
initial={{ opacity: 0 }}
|
|
animate={{ opacity: 1, transition: { duration: 0.1, delay: 0.2 } }}
|
|
exit={{ opacity: 0, transition: { duration: 0.05 } }}
|
|
className="position order-last lg:order-2 w-ful flex flex-wrap items-center gap-x-8 gap-y-4 lg:gap-8 justify-center text-center mx-auto z-30"
|
|
>
|
|
{highlights?.map((highlight) => (
|
|
<li key={highlight.label}>
|
|
<Link
|
|
href={highlight.link ?? '#'}
|
|
className="group cursor-pointer flex items-center gap-2 text-sm whitespace-nowrap text-foreground-light hover:text-foreground transition-colors hover:underline"
|
|
>
|
|
<Check className="stroke-2 w-4" />
|
|
<span>{highlight.label}</span>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</motion.ul>
|
|
</AnimatePresence>
|
|
<BrowserFrame
|
|
className="overflow-hidden lg:order-last bg-default w-full max-w-6xl mx-auto"
|
|
contentClassName="aspect-video border overflow-hidden rounded-lg"
|
|
>
|
|
{isInView && (
|
|
<AnimatePresence mode="wait">
|
|
<motion.div
|
|
key={props.tabs[activeTabIdx]?.label}
|
|
initial={{ opacity: 0 }}
|
|
animate={{ opacity: 1, transition: { duration: 0.1, delay: 0.2 } }}
|
|
exit={{ opacity: 0, transition: { duration: 0.05 } }}
|
|
className="relative w-full max-w-full h-full"
|
|
>
|
|
<Panel
|
|
key={resolvedTheme?.includes('dark')}
|
|
isDark={resolvedTheme?.includes('dark')}
|
|
/>
|
|
</motion.div>
|
|
</AnimatePresence>
|
|
)}
|
|
</BrowserFrame>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface TabProps {
|
|
label: string
|
|
isActive: boolean
|
|
onClick: VoidFunction
|
|
}
|
|
|
|
const Tab = ({ label, isActive, onClick }: TabProps) => (
|
|
<button
|
|
tabIndex={0}
|
|
onClick={onClick}
|
|
aria-selected={isActive}
|
|
role="tab"
|
|
className={cn(
|
|
'py-1.5 px-3 lg:py-2 lg:px-8 border rounded-full bg-alternative hover:border-foreground text-sm opacity-80 transition-all',
|
|
'hover:border-foreground-lighter hover:text-foreground',
|
|
isActive ? 'opacity-100 border-foreground!' : ''
|
|
)}
|
|
>
|
|
{label}
|
|
</button>
|
|
)
|
|
|
|
export default TabsWithHighlights
|