Files
zeekayandHanzo Dev bf9fbd156f Document the whole library from its own source
The docs site renders every component the barrel names, the gallery
harvests rules for all of them, and the pages come from the packages
rather than a hand-kept copy.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-07 18:59:54 -07:00

103 lines
2.9 KiB
TypeScript

import { YStack } from "@hanzo/gui"
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@hanzo/ui"
const invoices = [
{ invoice: "INV001", status: "Paid", method: "Credit Card", amount: "$250.00" },
{ invoice: "INV002", status: "Pending", method: "PayPal", amount: "$150.00" },
{ invoice: "INV003", status: "Unpaid", method: "Bank Transfer", amount: "$350.00" },
]
/** Invoices — a caption, a header row, body rows and a footer total. */
export function Invoices() {
return (
<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead>Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((row) => (
<TableRow key={row.invoice}>
<TableCell>{row.invoice}</TableCell>
<TableCell>{row.status}</TableCell>
<TableCell>{row.method}</TableCell>
<TableCell>{row.amount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell>$750.00</TableCell>
</TableRow>
</TableFooter>
</Table>
)
}
/** Selected row — `selected` marks a row's `data-state` and gives it a hover-toned background. */
export function SelectedRow() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>INV001</TableCell>
<TableCell>Paid</TableCell>
</TableRow>
<TableRow selected>
<TableCell>INV002</TableCell>
<TableCell>Pending</TableCell>
</TableRow>
</TableBody>
</Table>
)
}
/** Narrow viewport — the table scrolls horizontally as one unit inside a fixed-width frame. */
export function ScrollsHorizontally() {
return (
<YStack width={240} borderWidth={1} borderColor="$borderColor" rounded="$3">
<Table>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead>Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((row) => (
<TableRow key={row.invoice}>
<TableCell>{row.invoice}</TableCell>
<TableCell>{row.status}</TableCell>
<TableCell>{row.method}</TableCell>
<TableCell>{row.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</YStack>
)
}