forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

table.tsx68 lines, 2.3 KiBHistoryRawDownload
1import type { ComponentProps, ParentProps } from "solid-js";
2import { splitProps } from "solid-js";
3import { cn } from "@/lib/cn";
4
5// No scroll wrapper here: every Table sits inside DataTableFrame, which is the
6// single overflow container — a second one nests scrollbars inside the border.
7export function Table(props: ParentProps<ComponentProps<"table">>) {
8 const [local, rest] = splitProps(props, ["class", "children"]);
9 return (
10 <table class={cn("w-full min-w-full caption-bottom text-sm leading-5", local.class)} {...rest}>
11 {local.children}
12 </table>
13 );
14}
15
16export function TableHeader(props: ParentProps<ComponentProps<"thead">>) {
17 const [local, rest] = splitProps(props, ["class", "children"]);
18 return (
19 <thead class={cn("bg-surface-overlay [&_tr]:border-b", local.class)} {...rest}>
20 {local.children}
21 </thead>
22 );
23}
24
25export function TableBody(props: ParentProps<ComponentProps<"tbody">>) {
26 const [local, rest] = splitProps(props, ["class", "children"]);
27 return (
28 <tbody class={cn("[&_tr:last-child]:border-0", local.class)} {...rest}>
29 {local.children}
30 </tbody>
31 );
32}
33
34export function TableRow(props: ParentProps<ComponentProps<"tr">>) {
35 const [local, rest] = splitProps(props, ["class", "children"]);
36 return (
37 <tr
38 class={cn("border-b border-border-hairline transition-colors hover:bg-surface-overlay data-[state=selected]:bg-surface-tint", local.class)}
39 {...rest}
40 >
41 {local.children}
42 </tr>
43 );
44}
45
46export function TableHead(props: ParentProps<ComponentProps<"th">>) {
47 const [local, rest] = splitProps(props, ["class", "children"]);
48 return (
49 <th
50 class={cn(
51 "sticky top-0 z-20 h-11 whitespace-nowrap border-r border-border-hairline px-3 text-center align-middle text-xs font-medium tracking-normal text-text-subtle last:border-r-0 first:pl-4 last:pr-4 has-[[role=checkbox]]:pr-0",
52 local.class,
53 )}
54 {...rest}
55 >
56 {local.children}
57 </th>
58 );
59}
60
61export function TableCell(props: ParentProps<ComponentProps<"td">>) {
62 const [local, rest] = splitProps(props, ["class", "children"]);
63 return (
64 <td class={cn("border-r border-border-hairline px-3 py-3 align-middle last:border-r-0 first:pl-4 last:pr-4 has-[[role=checkbox]]:pr-0", local.class)} {...rest}>
65 {local.children}
66 </td>
67 );
68}