Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/guides/renderer-kit-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/renderer-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise \| Promise<ReactNode> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise<ReactNode> \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| 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<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise \| Promise<ReactNode> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement<unknown, string \| { (props: any): Iterable<ReactNode, any, any> \| Promise<Iterable<ReactNode, any, any> \| ReactElement<unknown, recursive> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise<ReactNode> \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component<any, any, any> }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What the group holds, in a few words or as a code name. |
Expand Down
9 changes: 8 additions & 1 deletion packages/renderers/kit/src/react/layout-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand All @@ -102,6 +108,7 @@ export function Group({
holdsChanges = false,
className,
style,
padded = false,
children,
}: GroupProps) {
const heading = useId()
Expand Down Expand Up @@ -141,7 +148,7 @@ export function Group({
{actions !== undefined && <div className="pk-group-actions">{actions}</div>}
{change && <ChangeStatus className="pk-group-status" change={change} emphasis={emphasis} />}
</header>
{children}
{padded ? <div className="pk-group-body">{children}</div> : children}
</section>
)
}
Expand Down
5 changes: 3 additions & 2 deletions packages/renderers/kit/styles/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions packages/renderers/kit/test/group.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'}), /<button/u)
})

test("a padded group insets its body by the band's inset; by default the body is flush", () => {
assert.match(
html({title: 'Notes', padded: true}),
/<\/header><div class="pk-group-body"><table class="body"><\/table><\/div><\/section>$/u,
)
assert.match(html({title: 'Notes'}), /<\/header><table class="body"><\/table><\/section>$/u)
const css = readFileSync(new URL('../styles/layout.css', import.meta.url), 'utf8')
assert.match(css, /\.pk \.pk-group > :is\(\.pk-card-grid, \.pk-group-body\) \{\n {2}padding: var\(--projections-space-3\);/u)
assert.match(css, /\.pk \.pk-group-header \{[^}]*padding: var\(--projections-space-1\) var\(--projections-space-3\);/u)
})
Loading