diff --git a/.claude/skills/ui-conventions/SKILL.md b/.claude/skills/ui-conventions/SKILL.md index a451420..7dcecc1 100644 --- a/.claude/skills/ui-conventions/SKILL.md +++ b/.claude/skills/ui-conventions/SKILL.md @@ -46,7 +46,7 @@ Active project reference docs (read the relevant one before changing that area): ## Tables - Application tables must use `src/components/ui/data-table.tsx` `DataTable`. -- Actions columns use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"İŞLEMLER"`. +- Actions columns stay fixed at `w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap` to prevent localized headers like `"İŞLEMLER"` from changing their size. - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages. - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally). - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may. diff --git a/.codex/skills/ui-conventions/SKILL.md b/.codex/skills/ui-conventions/SKILL.md index a451420..7dcecc1 100644 --- a/.codex/skills/ui-conventions/SKILL.md +++ b/.codex/skills/ui-conventions/SKILL.md @@ -46,7 +46,7 @@ Active project reference docs (read the relevant one before changing that area): ## Tables - Application tables must use `src/components/ui/data-table.tsx` `DataTable`. -- Actions columns use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"İŞLEMLER"`. +- Actions columns stay fixed at `w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap` to prevent localized headers like `"İŞLEMLER"` from changing their size. - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages. - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally). - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may. diff --git a/docs/ui/ui-redesign-tokens.md b/docs/ui/ui-redesign-tokens.md index 1b93338..7968220 100644 --- a/docs/ui/ui-redesign-tokens.md +++ b/docs/ui/ui-redesign-tokens.md @@ -60,18 +60,20 @@ display-font, translucent surface, or custom shadow rules. ## DataTable - Table shell: `rounded-lg border bg-card` -- Header: sticky, `11px` bold uppercase, `tracking-[0.16em]`, muted background -- Body: compact by default, even-row muted zebra, restrained hover -- Cell padding: compact `py-1.5`; normal `py-3`; comfortable `py-5` -- The rightmost action/update column is `w-28`, centered, sticky right, and - inherits the exact opaque zebra/hover row surface -- Data columns start at a consistent width, fill the available table width, and - expose mouse, touch, and keyboard resize handles; action/update stays fixed -- Search and column controls: `h-9`; search remains pill-shaped like bDash +- Header: sticky, `text-xs` medium **Title Case** (no uppercase transform), + `tracking-normal`, muted foreground/background +- Body: flat rows (no zebra), restrained hover, `tabular-nums` cells so digits + align vertically without a monospace font +- Cell padding: fixed `py-3` (no density / row-height toggle) +- The rightmost action/update column stays fixed at `110×45px`, centered, sticky + right, and inherits the exact opaque row surface +- Data columns fill the available table width at a consistent proportional width. + Column resizing is not offered (no resize handles, no width persistence) +- Search and column controls: `h-9 rounded-lg` (not pill) - Pagination includes range, optional page-size selector, previous/next, and page count -- `storageKey` remains optional. When provided, column widths, visibility, and - density persist under `hezarfen.table.` and resizing is enabled. +- `storageKey` remains optional. When provided, only column visibility persists + under `hezarfen.table.`. - Application tables use `DataTable`; page/domain components do not render table primitives directly. diff --git a/src/components/ui/data-table-search.tsx b/src/components/ui/data-table-search.tsx index 161af75..392cfed 100644 --- a/src/components/ui/data-table-search.tsx +++ b/src/components/ui/data-table-search.tsx @@ -10,7 +10,7 @@ export type DataTableSearchProps = { class?: string; }; -/** Pill-shaped search field: leading icon + conditional clear (X) button (bdash look). */ +/** Rounded search field: leading icon + conditional clear (X) button. */ export function DataTableSearch(props: DataTableSearchProps) { return (
@@ -19,7 +19,7 @@ export function DataTableSearch(props: DataTableSearchProps) { value={props.value} onInput={(event) => props.onChange(event.currentTarget.value)} placeholder={props.placeholder ?? "Ara"} - class={cn("h-9 rounded-full bg-muted/40", props.value ? "pl-9 pr-8" : "pl-9")} + class={cn("h-9 rounded-lg bg-muted/40", props.value ? "pl-9 pr-8" : "pl-9")} />
@@ -283,9 +286,13 @@ export function DataTable(props: DataTableProps + + + {(column) => } + + {(headerGroup) => ( @@ -295,43 +302,16 @@ export function DataTable(props: DataTableProps {renderHeader(header)} - -
header.column.resetSize()} - onKeyDown={(event) => { - if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return; - event.preventDefault(); - const step = event.shiftKey ? 32 : 8; - const delta = event.key === "ArrowLeft" ? -step : step; - const min = header.column.columnDef.minSize ?? 72; - prefs.setSizing({ - ...prefs.preferences().sizing, - [header.column.id]: Math.max(min, header.getSize() + delta), - }); - }} - class="absolute right-0 top-0 z-20 flex h-full w-2 cursor-col-resize touch-none select-none items-center justify-center opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden group-hover/head:opacity-100" - > - -
-
)}
@@ -371,20 +351,30 @@ export function DataTable(props: DataTableProps - {(cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - )} + {(cell) => { + const val = cell.getValue(); + const isText = typeof val === "string" || typeof val === "number"; + const isSystemColumn = ["actions", "update", "select"].includes(cell.column.id); + const isEmpty = !isSystemColumn && (val == null || val === ""); + + return ( + + -}> + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + + ); + }} )} diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx index 57ac19d..87c5318 100644 --- a/src/components/ui/table.tsx +++ b/src/components/ui/table.tsx @@ -25,7 +25,7 @@ export function TableHeader(props: ParentProps>) { export function TableBody(props: ParentProps>) { const [local, rest] = splitProps(props, ["class", "children"]); return ( -
+ {local.children} ); @@ -35,7 +35,7 @@ export function TableRow(props: ParentProps>) { const [local, rest] = splitProps(props, ["class", "children"]); return ( {local.children} @@ -48,7 +48,7 @@ export function TableHead(props: ParentProps>) { return (
localStorage.clear()); -test("reads saved widths, visibility and density", () => { +test("reads saved visibility", () => { localStorage.setItem( storageKey, - JSON.stringify({ - sizing: { name: 240 }, - visibility: { email: false }, - density: "comfortable", - }), + JSON.stringify({ visibility: { email: false } }), ); - expect(readTablePreferences(key)).toEqual({ - sizing: { name: 240 }, - visibility: { email: false }, - density: "comfortable", - }); + expect(readTablePreferences(key)).toEqual({ visibility: { email: false } }); }); -test("falls back to compact defaults for broken storage", () => { +test("falls back to defaults for broken storage", () => { localStorage.setItem(storageKey, "{broken"); expect(readTablePreferences(key)).toEqual(defaultTablePreferences); - - localStorage.setItem(storageKey, JSON.stringify({ density: "huge" })); - expect(readTablePreferences(key).density).toBe("compact"); }); function PreferencesProbe() { @@ -40,24 +29,18 @@ function PreferencesProbe() { return ( <> {JSON.stringify(controller.preferences())} - - ); } -test("persists width, visibility and density changes", () => { +test("persists visibility changes", () => { render(() => ); - fireEvent.click(screen.getByRole("button", { name: "width" })); fireEvent.click(screen.getByRole("button", { name: "visibility" })); - fireEvent.click(screen.getByRole("button", { name: "density" })); expect(JSON.parse(localStorage.getItem(storageKey) ?? "{}")).toEqual({ - sizing: { name: 320 }, visibility: { email: false }, - density: "normal", }); - expect(screen.getByTestId("preferences").textContent).toContain('"density":"normal"'); + expect(screen.getByTestId("preferences").textContent).toContain('"email":false'); }); diff --git a/src/lib/table-preferences.ts b/src/lib/table-preferences.ts index efdf925..610d1d4 100644 --- a/src/lib/table-preferences.ts +++ b/src/lib/table-preferences.ts @@ -1,24 +1,16 @@ import { createSignal, onMount } from "solid-js"; -export type TableDensity = "compact" | "normal" | "comfortable"; - -/** TanStack `columnSizing` shape: column id → width (px). */ -export type ColumnSizing = Record; /** TanStack `columnVisibility` shape: column id → visible. Absent = visible. */ export type ColumnVisibility = Record; export type TablePreferences = { - sizing: ColumnSizing; visibility: ColumnVisibility; - density: TableDensity; }; const STORAGE_PREFIX = "hezarfen.table."; export const defaultTablePreferences: TablePreferences = { - sizing: {}, visibility: {}, - density: "compact", }; export function readTablePreferences(storageKey: string): TablePreferences { @@ -28,14 +20,7 @@ export function readTablePreferences(storageKey: string): TablePreferences { if (!raw) return defaultTablePreferences; const parsed = JSON.parse(raw) as Partial; return { - sizing: typeof parsed.sizing === "object" && parsed.sizing ? parsed.sizing : {}, visibility: typeof parsed.visibility === "object" && parsed.visibility ? parsed.visibility : {}, - density: - parsed.density === "compact" || - parsed.density === "comfortable" || - parsed.density === "normal" - ? parsed.density - : defaultTablePreferences.density, }; } catch { return defaultTablePreferences; @@ -54,7 +39,7 @@ function writePreferences(storageKey: string | undefined, preferences: TablePref export type TablePreferencesController = ReturnType; /** - * Column widths, column visibility and row density persisted per table. + * Column visibility persisted per table. * When `storageKey` is omitted the preferences stay in memory only (ephemeral). * Preferences load in `onMount` so the first render matches the SSR-free default. */ @@ -75,9 +60,6 @@ export function createTablePreferences(storageKey?: string) { return { preferences, - setDensity: (density: TableDensity) => patch({ density }), - setSizing: (sizing: ColumnSizing) => patch({ sizing }), - resetSizing: () => patch({ sizing: {} }), setVisibility: (visibility: ColumnVisibility) => patch({ visibility }), }; }