Modules have owned their own UI since ADR 0021, but the platform has never said what that UI should look like. Every screen here — the Dashboard shell, the display host, the module template — invented its own hex colours, font stack, spacing, and radii, and they already disagreed. A module author had no vocabulary for "the ordinary panel background", so the only available answer was to invent one, and two modules would invent two. Add `@ekklesia/design-tokens`: one validated, enumerable registry of semantic tokens. A token declares a name, label, description, and default value; its category and `--ekklesia-*` identifier are derived from the name, so it can never claim one category while being named for another. Construction rejects duplicates, malformed names, unknown categories, empty or overlong text, and any value that is not a bounded literal — no declaration terminator, rule block, comment, at-rule, `url(`, `!important`, escape, control character, or markup. A registry that constructs can therefore be emitted as CSS without escaping, because nothing needing escaping can be in it. That validation is also what makes a future theme editor implementable rather than aspirational. Add `@ekklesia/ui`: button, icon button, text input, select, checkbox, field wrapper, panel, dialog, tabs, table and list primitives, badge, toast, and empty/error/loading states — every value a token reference, with real `:focus-visible` treatment and status that never depends on colour alone. Deliberately small: an element earns its place when two consumers need it. The stylesheet is a string rather than a `.css` file so the identical bytes install into a document or an isolated artifact root, and so hover, disabled, and focus-visible are real CSS rather than JavaScript approximations of them. `pnpm boundaries` opens exactly two shared roles to modules, by name — every other role stays rejected — and pins both design packages to the bottom of the presentation stack. Both are browser-safe by construction, proven by a real compile of module-shaped source in which `process.env` must fail to typecheck. The shell installs the defaults at its document root for the Dashboard and the display; custom properties inherit into module artifacts, so a module reads `var(--ekklesia-…)` with nothing to import at run time and nothing for a host to forget to pass. Co-Authored-By: Claude Opus 5 <[email protected]>
92 lines
2.5 KiB
TypeScript
92 lines
2.5 KiB
TypeScript
import type { ReactElement, ReactNode } from "react";
|
|
import { classNames } from "./class-names.js";
|
|
|
|
/**
|
|
* Table and list primitives.
|
|
*
|
|
* These are primitives rather than a data grid on purpose: sorting, filtering, pagination, selection
|
|
* models, and virtualisation are product decisions a module owns, and a "smart" table forces every
|
|
* consumer into one answer for all of them. What the platform owns is that two modules' tables look
|
|
* and behave like one product.
|
|
*/
|
|
|
|
export interface TableProps {
|
|
/** Names the table for assistive technology when no visible caption is rendered. */
|
|
readonly label: string;
|
|
readonly className?: string;
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function Table(props: TableProps): ReactElement {
|
|
return (
|
|
<table aria-label={props.label} className={classNames("ek-table", props.className)}>
|
|
{props.children}
|
|
</table>
|
|
);
|
|
}
|
|
|
|
export interface TableSectionProps {
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function TableHead(props: TableSectionProps): ReactElement {
|
|
return <thead>{props.children}</thead>;
|
|
}
|
|
|
|
export function TableBody(props: TableSectionProps): ReactElement {
|
|
return <tbody>{props.children}</tbody>;
|
|
}
|
|
|
|
export interface TableRowProps {
|
|
readonly selected?: boolean;
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function TableRow(props: TableRowProps): ReactElement {
|
|
return (
|
|
<tr {...(props.selected === undefined ? {} : { "aria-selected": props.selected })}>
|
|
{props.children}
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
export interface TableCellProps {
|
|
readonly header?: boolean;
|
|
/** `col` for a column header, `row` for a row header. Ignored unless `header` is set. */
|
|
readonly scope?: "col" | "row";
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function TableCell(props: TableCellProps): ReactElement {
|
|
if (props.header === true) {
|
|
return <th scope={props.scope ?? "col"}>{props.children}</th>;
|
|
}
|
|
return <td>{props.children}</td>;
|
|
}
|
|
|
|
export interface ListProps {
|
|
readonly label?: string;
|
|
readonly className?: string;
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function List(props: ListProps): ReactElement {
|
|
return (
|
|
<ul
|
|
{...(props.label === undefined ? {} : { "aria-label": props.label })}
|
|
className={classNames("ek-list", props.className)}
|
|
>
|
|
{props.children}
|
|
</ul>
|
|
);
|
|
}
|
|
|
|
export interface ListItemProps {
|
|
readonly className?: string;
|
|
readonly children?: ReactNode;
|
|
}
|
|
|
|
export function ListItem(props: ListItemProps): ReactElement {
|
|
return <li className={classNames("ek-list__item", props.className)}>{props.children}</li>;
|
|
}
|