Files
supabase/apps/design-system/registry/default/example/table-row-link-actions.tsx
Danny White 9bd86bee93 feat(design-system): document shared inline code defaults (#51984)
## Problem

The design system repeats inline-code styles and does not document the
new shared defaults.

## Solution

Import the shared styles from #51980 and document how sizing, colour,
weight and wrapping work. Add examples of bare and linked code, tables,
long values, Tailwind overrides and `data-code-style="plain"`. Remove
repeated styles from existing examples.

Highlighted code blocks keep an explicit `text-sm` size so removing
inline-code classes does not enlarge them.

## Review instructions

This PR changes the design-system app only.

1. Open the [Layout
page](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/layout).
Check the inline-code examples at narrow and desktop widths in both
themes.
2. Check code in headings, long values, explicit size overrides and the
plain display example. Code should use the default foreground colour and
follow the surrounding weight unless a class overrides it.
3. Check the [chart palette
example](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/charts).
CSS variable names should remain `<code>` elements with their own
display styles.

| Before | After |
| --- | --- |
| <img width="1666" height="770" alt="CleanShot 2026-10-20 at 16 37
20@2x"
src="https://github.com/user-attachments/assets/2ac87442-12a9-49ab-8e4f-f82436308567"
/> | <img width="1680" height="782" alt="CleanShot 2026-10-20 at 16 36
12@2x"
src="https://github.com/user-attachments/assets/b0074844-3431-4fb9-827b-c6fd0de889fe"
/> |
| _Layout
([live](https://supabase.com/design-system/docs/ui-patterns/layout))_ |
_Layout
([preview](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/layout))_
|
| <img width="1072" height="476" alt="CleanShot 2026-10-20 at 16 35
14@2x"
src="https://github.com/user-attachments/assets/242bf850-58fa-4b29-a978-bd0e296c2e8b"
/> | <img width="1072" height="484" alt="CleanShot 2026-10-20 at 16 34
47@2x"
src="https://github.com/user-attachments/assets/962adef0-05b7-47ed-8fdc-5229a3a332e1"
/> |
| _Charts
([live](https://supabase.com/design-system/docs/ui-patterns/charts))_ |
_Charts
([preview](https://design-system-git-dnywh-depr-707-code-design-system-supabase.vercel.app/design-system/docs/ui-patterns/charts)):
no visual changes as `data-code-style="plain"` has been used_ |
2026-10-22 00:48:57 +00:00

133 lines
4.3 KiB
TypeScript

import { ChevronRight, EllipsisVertical, Pencil, Shield, Trash2 } from 'lucide-react'
import {
Button,
Card,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from 'ui'
const policies = [
{
id: 'policy-1',
name: 'Anyone can view all active listings',
command: 'select',
appliedTo: 'public',
},
{
id: 'policy-2',
name: 'Users can delete their own listings',
command: 'delete',
appliedTo: 'authenticated',
},
{
id: 'policy-3',
name: 'Admins can update any listing',
command: 'update',
appliedTo: 'authenticated',
},
]
// Studio: See also createNavigationHandler in apps/studio/lib/navigation.ts
// It handles all of the below, plus modifier clicks and middle mouse button clicks.
const handlePolicyNavigation = (
policyId: string,
event: React.MouseEvent | React.KeyboardEvent
) => {
const url = `/${policyId}`
if (event.metaKey || event.ctrlKey) {
// window.open(`${url}`, '_blank') Disabled for demo purposes
} else {
// router.push(url) Disabled for demo purposes
}
}
export default function TableRowLinkActions() {
return (
<Card className="w-full">
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-1">
<span className="sr-only">Icon</span>
</TableHead>
<TableHead>Name</TableHead>
<TableHead>Command</TableHead>
<TableHead>Applied to</TableHead>
<TableHead className="w-1">
<span className="sr-only">Actions</span>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{policies.map((policy) => (
<TableRow
key={policy.id}
className="relative cursor-pointer focus-inset"
onClick={(event) => {
if (event.currentTarget !== event.target) return
handlePolicyNavigation(policy.id, event)
}}
onKeyDown={(event) => {
if (event.currentTarget !== event.target) return
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
handlePolicyNavigation(policy.id, event)
}
}}
tabIndex={0}
>
<TableCell className="w-1">
<Shield aria-label="policy icon" size={16} className="text-foreground-muted" />
</TableCell>
<TableCell>{policy.name}</TableCell>
<TableCell>
<code className="text-foreground-muted uppercase">{policy.command}</code>
</TableCell>
<TableCell className="text-foreground-lighter">{policy.appliedTo}</TableCell>
<TableCell className="flex justify-end items-center h-full gap-3">
<div
className="flex justify-end items-center h-full gap-3"
onClick={(event) => event.stopPropagation()}
onKeyDown={(event) => event.stopPropagation()}
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
icon={<EllipsisVertical />}
aria-label="More actions"
className="w-7 hit-area-2"
/>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className="w-40">
<DropdownMenuItem className="gap-x-2">
<Pencil size={14} />
<span>Edit policy</span>
</DropdownMenuItem>
<DropdownMenuItem className="gap-x-2">
<Trash2 size={14} />
<span>Delete</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<ChevronRight aria-hidden={true} size={14} className="text-foreground-muted/60" />
<button tabIndex={-1} className="sr-only">
Go to policy
</button>
</div>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Card>
)
}