From d175484085a6e9a0d65e066cf66755e65edf8ec4 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 14:14:02 -0800 Subject: [PATCH 1/4] kit: type roles, quiet text pieces and card header slots Text variant takes a type role (title, heading, kind, label, value, code, meta, figure) carrying size, weight, font and tone; pk-type- sets one without React. EntityCard names are titles, Group bands headings and Facts labels labels. Code, Slot and Tag are quiet text pieces. EntityCard gains kind, subtitle, aside and titleFont, so a card leads with one title. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- changelog.d/type-roles.md | 6 ++ docs/README.md | 3 +- docs/agents/create-projection.md | 3 +- docs/guides/renderer-kit-components.md | 22 ++++- docs/guides/renderer-kit-type.md | 39 ++++++++ docs/reference/renderer-kit.md | 63 ++++++++++-- packages/cli/templates/SKILL.md | 3 +- packages/renderers/kit/base.css | 1 + packages/renderers/kit/src/react.ts | 1 + packages/renderers/kit/src/react/facts.tsx | 2 +- .../kit/src/react/layout-components.tsx | 99 ++++++++----------- packages/renderers/kit/src/react/type.tsx | 96 ++++++++++++++++++ packages/renderers/kit/styles/layout.css | 26 +++++ packages/renderers/kit/styles/type.css | 58 +++++++++++ packages/renderers/kit/test/facts.test.mjs | 7 +- packages/renderers/kit/test/group.test.mjs | 6 +- packages/renderers/kit/test/layout.test.mjs | 48 +++++++++ .../test/runtime-policy.test.mjs | 4 +- .../renderers/text-diff/test/view.test.mjs | 4 +- 19 files changed, 409 insertions(+), 82 deletions(-) create mode 100644 changelog.d/type-roles.md create mode 100644 docs/guides/renderer-kit-type.md create mode 100644 packages/renderers/kit/src/react/type.tsx create mode 100644 packages/renderers/kit/styles/type.css diff --git a/changelog.d/type-roles.md b/changelog.d/type-roles.md new file mode 100644 index 000000000..d8f48f317 --- /dev/null +++ b/changelog.d/type-roles.md @@ -0,0 +1,6 @@ +--- +section: kit +--- + +- **Type roles style text by purpose instead of size**. `Text variant` takes a role (`title`, `heading`, `kind`, `label`, `value`, `code`, `meta`, or `figure`) with its size, weight, font, and tone from the theme; without React, use the `pk-type-` class. Kit components apply them automatically (`EntityCard` names use `title`, `Group` header bands use `heading`, and `Facts` labels use `label`). The kit also adds three quiet text pieces: `Code` for inline code, `Slot` for a named placeholder in a template, and `Tag` for a category label without a border. See [Renderer kit: type and values](docs/guides/renderer-kit-type.md). +- **`EntityCard` adds header slots around its title**. Optional muted slots place `kind` above the title ("Job", "Service"), a single-line `subtitle` below it, and `aside` at the end of the first line (such as a timeout); `titleFont="code"` renders code identifiers in monospace. `Facts` placed directly inside a card align with the title. See [Layout components](docs/guides/renderer-kit-components.md#layout-components). diff --git a/docs/README.md b/docs/README.md index 86aeab4ac..787662b21 100644 --- a/docs/README.md +++ b/docs/README.md @@ -55,7 +55,8 @@ the same tasks: [explore](agents/explore.md), [install](agents/install.md), [develop a renderer](guides/develop-a-renderer.md), the [renderer kit guide](guides/renderer-kit.md) (including [graphs](guides/renderer-kit-graphs.md) and - [components](guides/renderer-kit-components.md) and + [components](guides/renderer-kit-components.md), + [type and values](guides/renderer-kit-type.md), and [change emphasis](guides/change-emphasis.md)), and the [renderer SDK guide](guides/renderer-sdk.md). When you need API details, check the [renderer kit API](reference/renderer-kit.md), the diff --git a/docs/agents/create-projection.md b/docs/agents/create-projection.md index 8cfcfc998..12970e3b7 100644 --- a/docs/agents/create-projection.md +++ b/docs/agents/create-projection.md @@ -574,7 +574,8 @@ kit already meets the checks the host holds every renderer to. The starter has no stylesheet: compose views from the kit's components (`ContentView`, `Group`, `CardGrid`, `EntityCard`, `Facts`, `ValueList`, `Fields`, `Stack`, `Inline`, `Text`, `Chip`, `Chips`) and their props (`Facts` for properties and settings, -`ValueList` for value lists with inline change marks instead of pills), +`ValueList` for value lists with inline change marks instead of pills, and +`Text variant` for type roles like `title`, `label` or `meta` instead of sizes), and for an inline style they don't cover use `token` (`token.space(2)`). For items with comparable properties (a row per item, a column per property), use the kit's `DataTable` rather than hand-built table markup: sortable headings diff --git a/docs/guides/renderer-kit-components.md b/docs/guides/renderer-kit-components.md index af2ff2dd0..b36cd1a49 100644 --- a/docs/guides/renderer-kit-components.md +++ b/docs/guides/renderer-kit-components.md @@ -312,7 +312,12 @@ accept token scale steps rather than raw lengths or colors—this is how select button, `label`, `identifier`, `children`, and worded change status. In progress modes, its leading edge picks up the change hue as `emphasis` rises while `presence` fades it in or out; in diff mode, `mark={change}` applies - standard kit change-region styling. + standard kit change-region styling. Its header gives the card one title: + `label` uses the `title` role (`titleFont="code"` for code identifiers), with + optional muted slots for `kind` above it ("Job", "Service"), a one-line + `subtitle` below it ("6 runs · fail-fast off"), and `aside` at the end of the + first line (such as a timeout). `Facts` placed directly inside a card align + with its title. - `RelationshipList` and `RelationshipItem` list a card's relationships, each a selectable unit with its own ID, `presence`, and (in diff mode) `mark` and `changeText`. @@ -333,9 +338,18 @@ accept token scale steps rather than raw lengths or colors—this is how without pills. - `Stack` and `Inline` arrange children in a vertical column or wrapping row with `gap={1…8}` steps from the spacing scale. -- `Text` renders typography using `size` (`xs`, `sm`, `md`, `lg`, `xl`), - `weight`, and `tone` (`default`, `muted`, `subtle`, or one of the kit's tones, - `quiet` and `flag`; see [Tones](#tones)). +- `Text` renders text using a [type role](#type-roles) (`variant`), or `size` + (`xs`, `sm`, `md`, `lg`, `xl`) and `weight` when no role fits, along with + `tone` (`default`, `muted`, `subtle`, or one of the kit's tones, `quiet` and + `flag`; see [Tones](#tones)). +- `Code`, `Slot`, and `Tag` are quiet text pieces; see + [Renderer kit: type and values](renderer-kit-type.md). + +## Type roles + +Text in kit components uses a type role (`title`, `heading`, `kind`, `label`, +`value`, `code`, `meta`, or `figure`) instead of a raw size; see +[Renderer kit: type and values](renderer-kit-type.md). ## Tones diff --git a/docs/guides/renderer-kit-type.md b/docs/guides/renderer-kit-type.md new file mode 100644 index 000000000..fde90f271 --- /dev/null +++ b/docs/guides/renderer-kit-type.md @@ -0,0 +1,39 @@ +# Renderer kit: type and values + +Readers scan a projection in seconds, so its text hierarchy needs to be clear at +a glance. The kit's type roles and quiet text pieces keep that hierarchy +consistent across renderers; the authoring guide's +[visual craft](../agents/create-projection.md#visual-craft) rules cover when to +use each one. + +## Type roles + +A type role describes what a piece of text is and sets its size, weight, font, +and tone from the theme so cards read consistently across views. Use a role +instead of a raw size: + + +| Role | Use | Style | +|---|---|---| +| `title` | Card name | Body size, semibold | +| `heading` | Section inside a card or group header band | One step smaller, semibold | +| `kind` | Category word above a title ("Job", "Service") | Smallest step, muted | +| `label` | Key beside a value ("Runs on") | Muted, matching the value's size | +| `value` | Body text | Matches surrounding text | +| `code` | Identifier, path, version, or expression | Monospace, one pixel smaller | +| `meta` | Secondary detail ("40 min") | Smallest step, muted | +| `figure` | Count or number in a column | Tabular figures | + +Pass `Text variant="title"` (or any other role) in React, or add the +`pk-type-` class (`typeRoleClass(role)`) to any element without React. Kit +components apply these roles themselves: an `EntityCard` name uses `title`, +`Facts` labels use `label`, and a `Group` header band uses `heading`. Unmuted +roles inherit the surrounding text color, so removed items stay muted. + +## Quiet text pieces + +`Code` renders inline code in prose or a value (an expression, path, or version) +in monospace, inheriting the surrounding text color with no fill or border. +`Slot` renders a named placeholder in a template (`Build on os`) as muted +monospace without brackets. `Tag` renders a quiet category label (such as a +lifetime or mode) with a recessed fill and no border. diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 8e1469306..30fc524c3 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -4062,6 +4062,15 @@ Chips(__0: { "children": Iterable | Promise | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "className"?: string }): Element +``` + +Code inside running text or a value: an expression, a path, a version. Set in the monospace font in the color of the +text around it, with no fill or edge, so it adds one treatment, not three. `Identifier` is the same for names. + ### `ContentView` ```ts @@ -4215,17 +4224,21 @@ Props of `EntityCard`: one entity's card, its selection and its change. | Member | Signature | Description | |---|---|---| +| `aside` | `"aside"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | A muted fact at the end of the card's first line (the `meta` role), such as a timeout ("40 min"). | | `change` | `"change"?: { "renamed"?: false \| true \| undefined; "status": "added" \| "modified" \| "removed" \| "unchanged" }` | The row, for its change status: stated in words in the footer, in proportion to `emphasis`. | | `children` | `"children"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | Relationships and fields, below the name. | | `emphasis` | `"emphasis"?: number` | The host's emphasis for this change (`props.emphasis(row)`): 0 at both endpoints and before its step. | | `holdsChanges` | `"holdsChanges"?: false \| true` | Changes are drawn inside it that no `data-change` marks (a nested renderer's frame): the card is drawn neutral (`pk-holds-changes`), so change colors never nest. | | `id` | `"id": string` | The selection ID: the card's `data-entity-id`. | | `identifier` | `"identifier"?: string` | A code name shown under the label in the monospace font, usually the entity's ID. | -| `label` | `"label": Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | The entity's name, as text or as a `ValueChange` in the diff. | +| `kind` | `"kind"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What kind of thing it is, a muted word above the name ("Job", "Matrix job", "Service"): the `kind` role. | +| `label` | `"label": Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | The entity's name, as text or as a `ValueChange` in the diff: the card's `title`, which leads it. | | `mark` | `"mark"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| { "renamed"?: false \| true \| undefined; "status": "added" \| "modified" \| "removed" \| "unchanged" }` | In diff mode: the change this card marks, filled and edged in its hue (`changeMark`). | | `onSelect` | `"onSelect": { (id: string): void }` | Selects the entity (the renderer's `onSelect`) with `id`, when the card's button is activated. | | `presence` | `"presence"?: number` | Presence 0..1 while an entity is added or removed by the playing step (`timeline.presence`); 1 by default. | | `selected` | `"selected": false \| true` | Whether the entity is the host's selection (`props.selectedId === id`): the card's button is pressed. | +| `subtitle` | `"subtitle"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | One muted line under the name (the `meta` role): its most telling secondary facts ("6 runs · fail-fast off"). | +| `titleFont` | `"titleFont"?: "code" \| "text"` | The name's font: `code` for a name that is an identifier (a job, a function), in monospace; `text` by default. | ### `Fact` @@ -4717,6 +4730,15 @@ with the class `pk-slanted-column`), and call `useSlantedHeadings` with the tabl tall as the longest heading needs. A heading's tail runs over the columns to its right, so the table needs room on its right for the last one's: its following columns, or the space beside it. +### `Slot` + +```ts +Slot(__0: { "children": Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "title"?: string }): Element +``` + +A named blank in a template, such as a matrix value a run's name is spelled from (`Build on os`): its name as code, +muted, with no brackets or accent color. `title` says what fills it, for a pointer. + ### `Stack` ```ts @@ -4830,16 +4852,45 @@ What `useTableProps` reads from a kit renderer's props. | `selectedId` | `"selectedId": null \| string` | The host's selection (`RendererProps.selectedId`). | | `setControl` | `"setControl": { (id: string, value: false \| number \| string \| true): void }` | Sets a control from the content, as a heading does the sort (`RendererProps.setControl`). | +### `Tag` + +```ts +Tag(__0: { "children": Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "code"?: false | true; "title"?: string }): Element +``` + +A quiet categorical label (a lifetime, a kind, a mode): a recessed fill with no edge, in the `label` role. Unlike a +`Chip` it isn't selectable and carries no change of its own; use it for a word that classifies the item around it. + ### `Text` ```ts -Text(__0: { "as"?: "a" | "abbr" | "address" | "animate" | "animateMotion" | "animateTransform" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "circle" | "cite" | "clipPath" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "defs" | "del" | "desc" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "ellipse" | "em" | "embed" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "fieldset" | "figcaption" | "figure" | "filter" | "footer" | "foreignObject" | "form" | "g" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "image" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "line" | "linearGradient" | "link" | "main" | "map" | "mark" | "marker" | "mask" | "menu" | "menuitem" | "meta" | "metadata" | "meter" | "mpath" | "nav" | "noindex" | "noscript" | "object" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "path" | "pattern" | "picture" | "polygon" | "polyline" | "pre" | "progress" | "q" | "radialGradient" | "rect" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "search" | "section" | "select" | "set" | "slot" | "small" | "source" | "span" | "stop" | "strong" | "style" | "sub" | "summary" | "sup" | "svg" | "switch" | "symbol" | "table" | "tbody" | "td" | "template" | "text" | "textPath" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "tspan" | "u" | "ul" | "use" | "var" | "video" | "view" | "wbr" | "webview" | ComponentClass | FunctionComponent; "children": Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "size"?: "lg" | "md" | "sm" | "xl" | "xs"; "tone"?: "default" | "flag" | "muted" | "quiet" | "subtle"; "weight"?: "bold" | "medium" | "normal" | "semibold" }): Element +Text(__0: { "as"?: "a" | "abbr" | "address" | "animate" | "animateMotion" | "animateTransform" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "circle" | "cite" | "clipPath" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "defs" | "del" | "desc" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "ellipse" | "em" | "embed" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "fieldset" | "figcaption" | "figure" | "filter" | "footer" | "foreignObject" | "form" | "g" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "image" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "line" | "linearGradient" | "link" | "main" | "map" | "mark" | "marker" | "mask" | "menu" | "menuitem" | "meta" | "metadata" | "meter" | "mpath" | "nav" | "noindex" | "noscript" | "object" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "path" | "pattern" | "picture" | "polygon" | "polyline" | "pre" | "progress" | "q" | "radialGradient" | "rect" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "search" | "section" | "select" | "set" | "slot" | "small" | "source" | "span" | "stop" | "strong" | "style" | "sub" | "summary" | "sup" | "svg" | "switch" | "symbol" | "table" | "tbody" | "td" | "template" | "text" | "textPath" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "tspan" | "u" | "ul" | "use" | "var" | "video" | "view" | "wbr" | "webview" | ComponentClass | FunctionComponent; "children": Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "size"?: "lg" | "md" | "sm" | "xl" | "xs"; "tone"?: "default" | "flag" | "muted" | "quiet" | "subtle"; "variant"?: "code" | "figure" | "heading" | "kind" | "label" | "meta" | "title" | "value"; "weight"?: "bold" | "medium" | "normal" | "semibold" }): Element +``` + +Text in the theme's type. Prefer a role (`variant`: `title`, `heading`, `kind`, `label`, `value`, `code`, `meta`, +`figure`; see `TypeRole`), which carries its size, weight, font and tone; `size` and `weight` are for the rare text +no role fits, and override the role's. `muted` and `subtle` are for secondary text. The kit's tones (`Tone`) say how +much the text asks for attention: `quiet` for a lesser item, `flag` for a domain flag that isn't a change (semibold, +whatever `weight` says). Change colors are never a tone (use the kit's status components). + +### `TypeRole` + +```ts +type TypeRole = "code" | "figure" | "heading" | "kind" | "label" | "meta" | "title" | "value" +``` + +The kit's type roles: what a piece of text is, each with its size, weight, font and tone from the theme, so text +in every card reads the same way. `title` names a card; `heading` a section inside one, or a group's band; `kind` +is the muted word above a title ("Job", "Service"); `label` a key beside its value; `value` the body; `code` an +identifier, path or expression; `meta` a secondary fact ("40 min"); `figure` a number set in tabular figures. + +### `typeRoleClass` + +```ts +typeRoleClass(role: "code" | "figure" | "heading" | "kind" | "label" | "meta" | "title" | "value"): string ``` -Text in the theme's type: a step of the type scale, a weight and a tone. `muted` and `subtle` are for secondary -text. The kit's tones (`Tone`) say how much the text asks for attention: `quiet` for a lesser item, `flag` for a -domain flag that isn't a change (semibold, whatever `weight` says). Change colors are never a -tone (use the kit's status components). +The class that sets a type role on any element (`pk-type-`), for markup without the kit's `Text`. ### `useBorderWidths` diff --git a/packages/cli/templates/SKILL.md b/packages/cli/templates/SKILL.md index 31911e701..c73eeb482 100644 --- a/packages/cli/templates/SKILL.md +++ b/packages/cli/templates/SKILL.md @@ -538,7 +538,8 @@ kit already meets the checks the host holds every renderer to. The starter has no stylesheet: compose views from the kit's components (`ContentView`, `Group`, `CardGrid`, `EntityCard`, `Facts`, `ValueList`, `Fields`, `Stack`, `Inline`, `Text`, `Chip`, `Chips`) and their props (`Facts` for properties and settings, -`ValueList` for value lists with inline change marks instead of pills), +`ValueList` for value lists with inline change marks instead of pills, and +`Text variant` for type roles like `title`, `label` or `meta` instead of sizes), and for an inline style they don't cover use `token` (`token.space(2)`). For items with comparable properties (a row per item, a column per property), use the kit's `DataTable` rather than hand-built table markup: sortable headings diff --git a/packages/renderers/kit/base.css b/packages/renderers/kit/base.css index b3a480be0..afc092837 100644 --- a/packages/renderers/kit/base.css +++ b/packages/renderers/kit/base.css @@ -20,4 +20,5 @@ @import './styles/controls.css'; @import './styles/status.css'; @import './styles/text.css'; +@import './styles/type.css'; @import './styles/nesting.css'; diff --git a/packages/renderers/kit/src/react.ts b/packages/renderers/kit/src/react.ts index 4c7b940c3..8551f309d 100644 --- a/packages/renderers/kit/src/react.ts +++ b/packages/renderers/kit/src/react.ts @@ -29,6 +29,7 @@ export * from './react/icons.js' export {Fold, useFolds} from './react/fold.js' export {IdentifierText} from './react/identifiers.js' export * from './react/layout-components.js' +export * from './react/type.js' export {SlantedHeading, useSlantedHeadings} from './react/slanted-headings.js' export {DataTable, useTableProps} from './react/data-table.js' export type {DataTableColumn, DataTableProps, TablePropsSource} from './react/data-table.js' diff --git a/packages/renderers/kit/src/react/facts.tsx b/packages/renderers/kit/src/react/facts.tsx index f11559fbd..b058c0fd5 100644 --- a/packages/renderers/kit/src/react/facts.tsx +++ b/packages/renderers/kit/src/react/facts.tsx @@ -61,7 +61,7 @@ export function Fact({ const Label = change === 'removed' ? 'del' : change === 'added' ? 'ins' : 'span' return (
-
+
{changed ? (