diff --git a/docs/guides/renderer-kit-components.md b/docs/guides/renderer-kit-components.md index 4f12f635..e02aa768 100644 --- a/docs/guides/renderer-kit-components.md +++ b/docs/guides/renderer-kit-components.md @@ -294,7 +294,10 @@ accept token scale steps rather than raw lengths or colors—this is how `emphasis` render status text in a reserved `--pk-status-width` cell, and in diff mode `mark` styles the group and strikes through removed titles. Passing `id`, `selected`, and `onSelect` turns the group itself into a selectable ring - unit whose title acts as the select button. + unit whose title acts as the select button. Set `padded` for a body that isn't + a table (prose, chips, a short list): it is inset by the header band's own + inset, so it lines up with the title. Tables stay unpadded, so their rows run + edge to edge. - `CardGrid` lays cards out in as many columns as fit, collapsing to one column on phones. - `EntityCard` renders a single entity as a ring unit with `data-entity-id`, a diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 5934bb18..5695622a 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -4105,6 +4105,7 @@ band holds the subject's `icon`, if any, the title (`titleFont="code"` when the its title through. With `id` the group presents a selectable item, ringed by the SDK over its own edge, and its title is the button that selects it. The body is flush with the group's sides, so a table's rows run edge to edge; the group clips them to its corners. +`padded` insets it instead, by the header band's inset, for content that isn't a table. ### `GroupProps` @@ -4128,6 +4129,7 @@ Props of `Group`: only `title` and `children` are required. | `mark` | `"mark"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| { "renamed"?: false \| true \| undefined; "status": "added" \| "modified" \| "removed" \| "unchanged" }` | In diff mode: the change the group marks (`changeMark`); a removed group's title is struck through and muted. | | `meta` | `"meta"?: 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` | Secondary text after the title, muted: a qualifier such as a source or a kind. | | `onSelect` | `"onSelect"?: { (id: string): void }` | Selects the item (the renderer's `onSelect`), when its title is activated. | +| `padded` | `"padded"?: false \| true` | Inset the body by the kit's standard inset, the header band's own, so prose, chips or a list line up with the title. By default the body is flush with the group's sides, as a table's rows are. | | `selected` | `"selected"?: false \| true` | Whether the item is the host's selection: its title is pressed. | | `style` | `"style"?: CSSProperties` | Inline style, such as custom properties the body reads. | | `title` | `"title": 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 the group holds, in a few words or as a code name. | diff --git a/packages/renderers/kit/src/react/layout-components.tsx b/packages/renderers/kit/src/react/layout-components.tsx index 5f3bf5ac..6c6d0a51 100644 --- a/packages/renderers/kit/src/react/layout-components.tsx +++ b/packages/renderers/kit/src/react/layout-components.tsx @@ -74,6 +74,11 @@ export interface GroupProps { className?: string /** Inline style, such as custom properties the body reads. */ style?: CSSProperties + /** + * Inset the body by the kit's standard inset, the header band's own, so prose, chips or a list line up with the title. + * By default the body is flush with the group's sides, as a table's rows are. + */ + padded?: boolean /** The body: a table, list or rows, which reach the group's sides under its header band; a card grid keeps its inset. */ children: ReactNode } @@ -85,6 +90,7 @@ export interface GroupProps { * its title through. With `id` the group presents a selectable item, ringed by the SDK over its own edge, and its title * is the button that selects it. * The body is flush with the group's sides, so a table's rows run edge to edge; the group clips them to its corners. + * `padded` insets it instead, by the header band's inset, for content that isn't a table. */ export function Group({ title, @@ -102,6 +108,7 @@ export function Group({ holdsChanges = false, className, style, + padded = false, children, }: GroupProps) { const heading = useId() @@ -141,7 +148,7 @@ export function Group({ {actions !== undefined &&
{actions}
} {change && } - {children} + {padded ?
{children}
: children} ) } diff --git a/packages/renderers/kit/styles/layout.css b/packages/renderers/kit/styles/layout.css index 7f0f1579..ce6a2df8 100644 --- a/packages/renderers/kit/styles/layout.css +++ b/packages/renderers/kit/styles/layout.css @@ -165,8 +165,9 @@ .pk .pk-group-actions + .pk-group-status { margin-inline-start: 0; } -/* A body that isn't a table, such as a card grid, keeps the band's inset from the group's edge. */ -.pk .pk-group > .pk-card-grid { +/* A body that isn't a table, such as a card grid or a padded group's body (`padded`), keeps the band's inset from the + group's edge. */ +.pk .pk-group > :is(.pk-card-grid, .pk-group-body) { padding: var(--projections-space-3); } .pk .pk-card-grid { diff --git a/packages/renderers/kit/test/group.test.mjs b/packages/renderers/kit/test/group.test.mjs index 7ee76641..95cd1371 100644 --- a/packages/renderers/kit/test/group.test.mjs +++ b/packages/renderers/kit/test/group.test.mjs @@ -85,3 +85,14 @@ test('a group that presents an item is its unit, and its title is the button tha // Without onSelect the title is not a button. assert.doesNotMatch(html({title: 'Policies', id: 'policies'}), /