import { Badge, Card, CardContent, CardDescription, CardHeader, CardTitle, DataTable, type ColumnDef, } from "@godxjp/ui/data-display"; import { Checkbox, Field, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, } from "@godxjp/ui/data-entry"; import { Button, Text } from "@godxjp/ui/general"; import { Flex, PageContainer } from "@godxjp/ui/layout"; /** * Density · design-token foundation. One knob (``) swaps a * single CSS class (`.ui-density-compact|default|comfortable`) that retunes * --control-height, --control-padding-x, --checkbox-size, --switch-* and the φ * unit. The first card renders the SAME real controls inside each density-scoped * subtree so the retune is visible at rest. The DataTable owns a separate density * prop (--table-row-height / --table-cell-padding-y), shown in its own card. * Composed only from real @godxjp/ui components. */ type Line = { id: string; item: string; qty: string }; const lines: Line[] = [ { id: "L-01", item: "ライセンス", qty: "12" }, { id: "L-02", item: "保守費", qty: "1" }, { id: "L-03", item: "初期構築", qty: "1" }, ]; const columns: ColumnDef[] = [ { key: "id", header: "明細", width: "w-20" }, { key: "item", header: "品目" }, { key: "qty", header: "数量", align: "right", render: (row) => {row.qty}, }, ]; /** The same real controls, rendered once per density column. */ function DensitySample({ idPrefix }: { idPrefix: string }) { return ( ); } const density = [ { cls: "ui-density-compact", label: "compact", role: "kintone 風の密なテーブル", }, { cls: "ui-density-default", label: "default", role: "標準アプリ画面", }, { cls: "ui-density-comfortable", label: "comfortable", role: "公開 / モバイル · WCAG タッチ floor", }, ]; export default function Demo() { return ( Same UI, three densities Set density once per page via {""} · never the .ui-density-* classes directly. Flip the one prop and Input, Select, Checkbox, Switch and Button all re-tune their height, padding and the φ rhythm together. 44px (comfortable) is the WCAG / Digital Agency touch floor. {/* A STACK ON A PHONE, said with `direction` rather than left to `wrap`. `wrap` never fired here: each column carries `min-w-0 flex-1`, and an item that may shrink to nothing never reaches the wrap threshold — so at 375px this was three 92px columns, and the unbreakable `density="comfortable"` label painted 36px over its neighbour with no scrollport to reach it. */} {density.map((d) => ( density="{d.label}" {d.label === "default" && default} {d.role}
))}
Table row density (DataTable density) The DataTable owns its own density axis: density="compact" vs density="comfortable" swaps --table-row-height and --table-cell-padding-y. The density toggle in the table toolbar drives the same prop at runtime. {/* A STACK ON A PHONE, said with `direction` rather than left to `wrap`. `wrap` never fired here: each column carries `min-w-0 flex-1`, and an item that may shrink to nothing never reaches the wrap threshold — so at 375px this was three 92px columns, and the unbreakable `density="comfortable"` label painted 36px over its neighbour with no scrollport to reach it. */} density="compact" row.id} density="compact" /> density="comfortable" row.id} density="comfortable" /> Page-level knob (PageContainer density) In a real screen you pass density to the page shell once; this nested PageContainer is the comfortable knob applied to a whole form. Note the taller controls and looser φ rhythm versus the compact column above.
); }