mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00: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
184 lines
6.9 KiB
TypeScript
184 lines
6.9 KiB
TypeScript
import useLw15ConfData, { UserTicketData } from 'components/LaunchWeek/15/hooks/use-conf-data'
|
|
import SectionContainer from 'components/Layouts/SectionContainer'
|
|
import dayjs from 'dayjs'
|
|
import Link from 'next/link'
|
|
import { useState } from 'react'
|
|
import { Button, cn } from 'ui'
|
|
|
|
import { updateTicketColors, useRegistration } from '../hooks/use-registration'
|
|
import { FifteenSVG, LW15ThemeSwitcher, LWSVG } from '../lw15.components'
|
|
import { BG_COLORS, TYPO_COLORS } from './colors'
|
|
import LW15Ticket from './LW15Ticket'
|
|
import LW15TicketShare from './LW15TicketShare'
|
|
import TicketURLCopy from './TicketURLCopy'
|
|
|
|
const LW15TicketPage = ({
|
|
user: userFromProps,
|
|
isSharePage,
|
|
}: {
|
|
user?: UserTicketData
|
|
isSharePage?: boolean
|
|
}) => {
|
|
const register = useRegistration()
|
|
const [state, setState] = useState({ saving: false })
|
|
const [confState] = useLw15ConfData()
|
|
const user = isSharePage ? userFromProps : confState.userTicketData
|
|
const isLoggedTicketOwner = user?.username === confState.userTicketData?.username
|
|
|
|
const selectedFg = user?.metadata?.colors?.foreground || TYPO_COLORS[0]
|
|
const selectedBg = user?.metadata?.colors?.background || BG_COLORS[0]
|
|
|
|
const handleColorChange = async (type: 'foreground' | 'background', color: string) => {
|
|
if (!user?.username) return
|
|
const newColors = {
|
|
background: type === 'background' ? color : selectedBg,
|
|
foreground: type === 'foreground' ? color : selectedFg,
|
|
}
|
|
setState({ saving: true })
|
|
try {
|
|
await updateTicketColors({
|
|
username: user?.username!,
|
|
userMetadata: user?.metadata,
|
|
background: newColors.background,
|
|
foreground: newColors.foreground,
|
|
})
|
|
} finally {
|
|
setState({ saving: false })
|
|
}
|
|
}
|
|
|
|
const TicketCustomizationSection = ({ className }: { className?: string }) => (
|
|
<div
|
|
className={cn(
|
|
'flex flex-col gap-12 pt-4 w-full border-t',
|
|
isSharePage && 'border-t-0 lg:border-t pt-0 lg:pt-4',
|
|
className
|
|
)}
|
|
>
|
|
{!isSharePage && (
|
|
<div className="grid grid-cols-6 w-full gap-4">
|
|
<p className="col-span-full xl:col-span-3 lg:text-xs xl:max-w-[230px]">
|
|
Customize your ticket
|
|
</p>
|
|
<div className="col-span-full xl:col-span-3 xl:col-start-4 flex flex-col gap-4">
|
|
<div className="w-full grid grid-cols-3">
|
|
<p>Typo color</p>
|
|
<div className="flex flex-col col-span-2">
|
|
<div className="flex gap-2 flex-wrap justify-end">
|
|
{TYPO_COLORS.map((color) => (
|
|
<button
|
|
tabIndex={0}
|
|
key={color}
|
|
className={cn(
|
|
'flex-1 max-w-5 aspect-square rounded-full border flex items-center justify-center transition-all',
|
|
selectedFg === color && 'border-background ring-1 ring-foreground scale-110'
|
|
)}
|
|
style={{ background: color }}
|
|
aria-label={color}
|
|
onClick={() => handleColorChange('foreground', color)}
|
|
disabled={state.saving}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="w-full grid grid-cols-3">
|
|
<p>Bg color</p>
|
|
<div className="flex flex-col col-span-2">
|
|
<div className="flex gap-2 flex-wrap justify-end">
|
|
{BG_COLORS.map((color) => (
|
|
<button
|
|
tabIndex={0}
|
|
key={color}
|
|
className={cn(
|
|
'flex-1 max-w-5 aspect-square rounded-full border flex items-center justify-center transition-all',
|
|
selectedBg === color && 'border-background ring-1 ring-foreground scale-110'
|
|
)}
|
|
style={{ background: color }}
|
|
aria-label={color}
|
|
onClick={() => handleColorChange('background', color)}
|
|
disabled={state.saving}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
<div className="hidden lg:flex justify-between items-end gap-4 text-xs">
|
|
<div className="flex flex-col">
|
|
<p>Ticket ID: #{user?.ticket_number}</p>
|
|
<p>Claimed at: {dayjs(user?.created_at).format('DD MMM / HH:mm')}</p>
|
|
</div>
|
|
<LW15ThemeSwitcher />
|
|
</div>
|
|
</div>
|
|
)
|
|
|
|
const handleClaimTicket = () => register.signIn()
|
|
|
|
return (
|
|
<SectionContainer className="flex flex-col lg:grid lg:grid-cols-2 gap-6 py-8! md:py-10! h-full min-h-[calc(100dvh-66px)]!">
|
|
<div className="flex flex-col h-full justify-between gap-6 lg:gap-20">
|
|
<div className="grid grid-cols-6 gap-4">
|
|
<div className="col-span-full w-full hidden lg:flex items-center justify-between h-[60px] md:h-[90px] lg:h-[120px] gap-4">
|
|
<h1 className="sr-only">Supabase Launch Week 15</h1>
|
|
<LWSVG className="h-full w-auto" />
|
|
<FifteenSVG className="h-full w-auto" />
|
|
</div>
|
|
<div className="col-span-5 text-2xl lg:text-4xl">
|
|
{isSharePage ? (
|
|
<>
|
|
{user?.name?.split(' ')[0]}'s Ticket
|
|
<br />
|
|
Want your own?
|
|
</>
|
|
) : (
|
|
<>
|
|
Hey @{user?.username}, <br />
|
|
customize your <br className="hidden lg:block" />
|
|
Launch Week ticket
|
|
</>
|
|
)}
|
|
</div>
|
|
{isSharePage && !isLoggedTicketOwner && (
|
|
<div className="col-span-full">
|
|
<Button
|
|
className="h-auto py-1 px-2 min-w-[125px] min-h-[28px]"
|
|
variant="secondary"
|
|
size="medium"
|
|
onClick={handleClaimTicket}
|
|
>
|
|
Claim your ticket
|
|
</Button>
|
|
</div>
|
|
)}
|
|
{isSharePage && isLoggedTicketOwner && (
|
|
<div className="col-span-full">
|
|
<Button className="h-auto py-1 px-2" variant="secondary" size="medium" asChild>
|
|
<Link href="/launch-week/ticket">Customize your ticket</Link>
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<TicketCustomizationSection />
|
|
</div>
|
|
<div
|
|
className="w-full border border-muted h-full bg-surface-300 flex items-center justify-center p-8 transition-colors duration-300"
|
|
style={{ background: `${selectedFg}07` }}
|
|
>
|
|
<div className="flex flex-col justify-center gap-8 h-fit">
|
|
<LW15Ticket user={user} />
|
|
<div className="flex flex-col gap-1">
|
|
<TicketURLCopy user={user} />
|
|
{!isSharePage && <LW15TicketShare />}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</SectionContainer>
|
|
)
|
|
}
|
|
|
|
export default LW15TicketPage
|