@plitzi/sdk-authoring 0.39.14 → 0.39.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index-src.js +468 -297
- package/dist/index.d.ts +190 -20
- package/dist/index.js +2 -2
- package/dist/node.d.ts +7 -7
- package/dist/node.js +2 -2
- package/package.json +6 -6
- package/skills/plitzi-authoring/CHEATSHEET.md +46 -43
- package/skills/plitzi-authoring/SKILL.md +3 -3
- package/skills/plitzi-authoring/recipes/carousel.ts +2 -2
- package/skills/plitzi-authoring/recipes/forms-and-modals.ts +1 -1
- package/skills/plitzi-authoring/recipes/table.ts +60 -0
- package/skills/plitzi-authoring/reference/accessibility.md +6 -4
- package/skills/plitzi-authoring/reference/authoring-errors.md +5 -5
- package/skills/plitzi-authoring/reference/flows.md +1 -0
- package/skills/plitzi-authoring/reference/lists.md +8 -5
- package/skills/plitzi-authoring/reference/recipes.md +1 -0
- package/skills/plitzi-authoring/reference/rules.md +2 -1
- package/skills/plitzi-authoring/reference/typed-sources.md +1 -1
|
@@ -8,18 +8,18 @@ of a kind — rather than reading its `.d.ts`.
|
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const space: SpaceSpec = {
|
|
11
|
-
name, permanentUrl,
|
|
12
|
-
variables: { color: { card: { light, dark, default } } },
|
|
13
|
-
classes: { card },
|
|
14
|
-
computed: { total: '{{ … }}' },
|
|
11
|
+
name, permanentUrl, // permanentUrl: lowercase, digits, `-`
|
|
12
|
+
variables: { color: { card: { light, dark, default } } }, // every colour a token, both themes; tokens(variables).card
|
|
13
|
+
classes: { card }, // styles() declarations, by their own name; styles('card', tw('p-4 rounded-xl'))
|
|
14
|
+
computed: { total: '{{ … }}' }, // values read anywhere as computed.total
|
|
15
15
|
flags: { beta: { description, value: false, rules: [] } },
|
|
16
|
-
keyframes: { blink: { '50%': { opacity: 0 } } },
|
|
17
|
-
layouts: [{ id: 'shell', body }],
|
|
18
|
-
components: [{ id, props, slots, root }],
|
|
19
|
-
pages: [{ id, name, slug: '', layout: { id: 'shell', slot: 'main' }, body: [] }]
|
|
20
|
-
};
|
|
21
|
-
pageFamily({ folder, layout, seoTitle, body: entry => [...] }, ENTRIES)
|
|
22
|
-
pageFolders: [{ id: 'docs', name: 'Docs' }]
|
|
16
|
+
keyframes: { blink: { '50%': { opacity: 0 } } }, // a class plays them: animation: 'blink 1s infinite'
|
|
17
|
+
layouts: [{ id: 'shell', body }], // chrome shared by pages
|
|
18
|
+
components: [{ id, props, slots, root }], // a block placed many times with different content
|
|
19
|
+
pages: [{ id, name, slug: '', layout: { id: 'shell', slot: 'main' }, body: [] }] // slot: where the body goes
|
|
20
|
+
}; // slug '' is home; 'products/:slug' takes a param
|
|
21
|
+
pageFamily({ folder, layout, seoTitle, body: entry => [...] }, ENTRIES) // pages of one shape, from data; ids scoped per page
|
|
22
|
+
pageFolders: [{ id: 'docs', name: 'Docs' }] // on the space: a `folder` is declared here, /docs/…
|
|
23
23
|
const { schema, style, warnings, suggestions } = authorSpace(space, { plugins: [declaration] });
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -29,30 +29,32 @@ Every factory takes the element's attributes and these fields: `id`, `class`, `c
|
|
|
29
29
|
`visible`, `flows`, `anchor`, `flag`, `runtime`, `loadStrategy`, `children`.
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
text('Words', { class })
|
|
33
|
-
heading('Title', { subType: 'h2' })
|
|
32
|
+
text('Words', { class }) // also text({ content }); a <div> — `display: inline` to flow
|
|
33
|
+
heading('Title', { subType: 'h2' }) // h1–h6; holds no children
|
|
34
34
|
paragraph('A paragraph.')
|
|
35
35
|
container([children], { subType: 'section' }) // div, section, nav, header, footer, main, article, li, h1–h6, span…
|
|
36
|
-
link({ href: 'about', content: 'About' })
|
|
37
|
-
link({ href: 'home', hash: 'plans' })
|
|
36
|
+
link({ href: 'about', content: 'About' }) // a page id, a '/path', or a URL — the mode follows from the href
|
|
37
|
+
link({ href: 'home', hash: 'plans' }) // → /#plans, onto the element with anchor: 'plans'
|
|
38
38
|
container({ motion: { enter: 'fade-up', on: 'view' }, children }) // arrives once as it comes into view; stagger, loop too
|
|
39
|
-
button({ content: 'Save', flows })
|
|
40
|
-
image({ src, alt })
|
|
41
|
-
embed({ src, title })
|
|
42
|
-
svg('<svg …>…</svg>', { label })
|
|
39
|
+
button({ content: 'Save', flows }) // holds children too: then content: ''
|
|
40
|
+
image({ src, alt }) // or decorative: true
|
|
41
|
+
embed({ src, title }) // a map, a player: another page in a frame
|
|
42
|
+
svg('<svg …>…</svg>', { label }) // checked, sanitised; currentColor follows the class
|
|
43
43
|
svg(svgFile(new URL('./logo.svg', import.meta.url))) // a file, compacted: svgFile/svgFiles from '@plitzi/sdk-authoring/node'
|
|
44
44
|
fontAwesome({ icon: 'fa-solid fa-xmark' })
|
|
45
|
-
list({ id: 'rows', items: 'p.data.rows', row: 'row-card' })
|
|
45
|
+
list({ id: 'rows', items: 'p.data.rows', row: 'row-card' }) // a <ul>; a component per row, its root an <li>
|
|
46
46
|
list({ id: 'rows', items: 'p.data.rows', row: r => listItem({ children: [text({ from: `${r.item}.title` })] }) })
|
|
47
47
|
// typed items (site.data.rows): r.item is a path — from: r.item.title
|
|
48
|
+
// r.item / r.index in a template too: `{{ ${r.item}.slug }}` (completed to list_rows.item)
|
|
48
49
|
carousel({ id: 'hero', items: 'p.data.slides', autoplay: 5000, row: 'slide-card', children: [/* carouselNext('hero') arrows */] })
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
// rows follow their item's `id`, or `itemKey: 'slug'`
|
|
51
|
+
table({ id: 'plans', items, row: r => [tableColumn({ header: 'Plan', children: [text({ from: `${r.item}.name` })] })] }) // a <table>
|
|
52
|
+
apiContainer({ id: 'p', query: '/data/x.json', cache: true, children }) // publishes p.data; no box of its own
|
|
51
53
|
apiContainer({ id: 'p', query: '/data/x.json', runtime: 'server', children }) // read by the page server: still p.data
|
|
52
|
-
apiContainer({ id: 'p', action: 'report', runtime: 'server', children })
|
|
53
|
-
|
|
54
|
+
apiContainer({ id: 'p', action: 'report', runtime: 'server', children }) // its output at p's root: p.rows
|
|
55
|
+
// loadingSlot: 'p-skeleton' — a child shown until it answers
|
|
54
56
|
form({ id, managedByInteractions: true, flows, children })
|
|
55
|
-
formControl({ name: 'email', label: 'Email', subType: 'email', required: true })
|
|
57
|
+
formControl({ name: 'email', label: 'Email', subType: 'email', required: true }) // optional without required; select: options: [{ label, value }]; number: min, max
|
|
56
58
|
modalContainer({ id, visible: false, title, children })
|
|
57
59
|
component('card', { props: { title }, children: { body: [ … ] } })
|
|
58
60
|
const seats = defineElement(seatsDeclaration); seats({ id }) // a plugin
|
|
@@ -61,12 +63,12 @@ const seats = defineElement(seatsDeclaration); seats({ id }) // a plugin
|
|
|
61
63
|
## Styles
|
|
62
64
|
|
|
63
65
|
```ts
|
|
64
|
-
const card = styles('card', { padding: 24, borderRadius: 16 });
|
|
65
|
-
styles('title', { fontSize: { desktop: '48px', compact: '32px' }, fontWeight: 700 });
|
|
66
|
+
const card = styles('card', { padding: 24, borderRadius: 16 }); // shorthands, camelCase, numbers as px
|
|
67
|
+
styles('title', { fontSize: { desktop: '48px', compact: '32px' }, fontWeight: 700 }); // one property per breakpoint
|
|
66
68
|
styles('card', { css: { desktop: { … }, compact: { … } }, states: { hover: { … } }, variants: { active: { … } } });
|
|
67
|
-
container({ class: card });
|
|
68
|
-
container({ class: [card, { opacity: '0.5' }] });
|
|
69
|
-
container({ css: { padding: '8px' } });
|
|
69
|
+
container({ class: card }); // a shared class…
|
|
70
|
+
container({ class: [card, { opacity: '0.5' }] }); // …plus one thing
|
|
71
|
+
container({ css: { padding: '8px' } }); // rules of its own — never with `class`
|
|
70
72
|
```
|
|
71
73
|
|
|
72
74
|
Breakpoints: `desktop` (base), `tablet` (48–64rem), `mobile` (≤48rem), `compact` (tablet AND mobile). Each inherits
|
|
@@ -76,18 +78,19 @@ from `desktop` alone. States: `hover`, `focus`, `focus-visible`, `active`, `disa
|
|
|
76
78
|
## Data, bindings, visibility
|
|
77
79
|
|
|
78
80
|
```ts
|
|
79
|
-
from: 'p.data.title'
|
|
80
|
-
from: 'rows.item.price', as: 'price'
|
|
81
|
-
from: site.data.title
|
|
82
|
-
bind: { alt: 'p.data.title' }
|
|
81
|
+
from: 'p.data.title' // the main attribute: content, src, href, items
|
|
82
|
+
from: 'rows.item.price', as: 'price' // shown as a format (space `formats`) or a template
|
|
83
|
+
from: site.data.title // const site = source('p', sampleJson): typed, checked
|
|
84
|
+
bind: { alt: 'p.data.title' } // other attributes; short source names
|
|
83
85
|
bind: [bindTemplate('content', 'p.data.items', '{{ source|length }} items')]
|
|
84
86
|
bind: [bindTemplate('items', 'p.data.rows', '{{ source|filter(r => r.on) }}', { returns: 'value' })]
|
|
85
|
-
bind: [variantFrom(pill, 'rows.item.status')]
|
|
86
|
-
current: 'section'
|
|
87
|
+
bind: [variantFrom(pill, 'rows.item.status')] // a variant chosen by the data
|
|
88
|
+
current: 'section' // a link lit on its page and the pages under it
|
|
87
89
|
bind: [activeWhen(dot, '{{ list_dots.index == state.slide }}')] // a variant while a condition holds
|
|
88
|
-
visible: 'p.data.signedIn'
|
|
90
|
+
visible: 'p.data.signedIn' // shown while true; '!p.data.signedIn' inverts
|
|
89
91
|
visible: { source: 'p.data.rows', template: '{{ source is defined and source|length == 0 }}' }
|
|
90
|
-
visible:
|
|
92
|
+
visible: visibleIf('state.step', '>=', 2) // compared; hidden while it has no value
|
|
93
|
+
visible: false // hidden until a step shows it
|
|
91
94
|
```
|
|
92
95
|
|
|
93
96
|
Inside a list row: `rows.item` in a binding, `{{ list_rows.item.x }}` in a template or an attribute,
|
|
@@ -104,16 +107,16 @@ A flow is `[trigger, …steps]`, in an element's `flows`.
|
|
|
104
107
|
[onClick(), setState({ key: 'saved', type: 'boolean', value: true })] // types: boolean, number, text, json
|
|
105
108
|
[named('sent', onSubmit()), setState({ key: 'email', type: 'text', value: '{{ sent.values.email }}' })]
|
|
106
109
|
[on('onChange'), …]; [on('onMouseEnter'), …]; [onPageLoad(), …]; [onKey('mod+k, escape'), …]
|
|
107
|
-
[onInterval(5000), …]
|
|
110
|
+
[onInterval(5000), …] // every 5 s, the tab in view
|
|
108
111
|
[onClick(), scrollBy('cards', { x: '80%' })]; scrollTo('cards', { x: 'end' }); scrollIntoView('answer'); focus('field')
|
|
109
|
-
[named('row', onScroll()), …]
|
|
112
|
+
[named('row', onScroll()), …] // { x, y, atStart, atEnd } of its own box
|
|
110
113
|
[onClick(), toggleState({ key: 'menuOpen' })]
|
|
111
|
-
[onClick(), cycleState({ key: 'slide', length: 3, by: -1 })]
|
|
114
|
+
[onClick(), cycleState({ key: 'slide', length: 3, by: -1 })] // goes round; stepState({ key, by, min, max }) stops
|
|
112
115
|
[onClick(), openModal('details')]; closeModal('details')
|
|
113
116
|
[onClick(), navigate({ urlType: 'page', url: 'about' })]
|
|
114
117
|
[onClick(), runServerAction({ actionId: 'checkout', input: { id: '{{ list_rows.item.id }}' } })]
|
|
115
118
|
[onClick(), when({ field: 'state.step', operator: '=', value: '2' }, setState({ … }))]
|
|
116
|
-
[whileRunning('queue', onClick()), delay(1000), …]
|
|
119
|
+
[whileRunning('queue', onClick()), delay(1000), …] // 'latest': a new firing stops the running one
|
|
117
120
|
[named('picked', declaredTrigger(declaration, 'onPick')), …]; declaredCallback(declaration, 'reset', { on: 'seats' })
|
|
118
121
|
```
|
|
119
122
|
|
|
@@ -135,7 +138,7 @@ Each comes with its code in brackets; reference/authoring-errors.md has a row fo
|
|
|
135
138
|
| `tablet-rule-skips-mobile` | the rule under `compact` |
|
|
136
139
|
| `colour-without-dark` | `{ light, dark, default }` |
|
|
137
140
|
| `click-on-static-element` | the flow on a `button` (it holds children) or a `link` |
|
|
138
|
-
| `image-without-alt` / `control-without-name` | `alt` or `decorative: true`; `
|
|
141
|
+
| `image-without-alt` / `control-without-name` | `alt` or `decorative: true`; `label` on an icon button |
|
|
139
142
|
| `anchor-missing` | the `anchor` on the section the `hash` names |
|
|
140
143
|
|
|
141
144
|
## Recipes
|
|
@@ -38,8 +38,8 @@ A change to a space on Plitzi itself — the builder's — is the Plitzi MCP ser
|
|
|
38
38
|
4. **Before saying done:** `npm run lint:space` clean, and the [review checklist](reference/review-checklist.md).
|
|
39
39
|
|
|
40
40
|
What a name means — an element, a step, a trigger, a code, any `@plitzi` export (`pageFamily`, `createServer`): `npx plitzi explain
|
|
41
|
-
<name>`, in a few lines; whether there is a way at all — a field an element publishes, a state —
|
|
42
|
-
|
|
41
|
+
<name>`, in a few lines; whether there is a way at all — a field an element publishes, a state — the words themselves,
|
|
42
|
+
quoted: `npx plitzi explain "<words>"`. Never read the `.d.ts`.
|
|
43
43
|
|
|
44
44
|
## Five rules authoring cannot check for you
|
|
45
45
|
|
|
@@ -60,7 +60,7 @@ Start with [the cheatsheet](CHEATSHEET.md), then only what the task names:
|
|
|
60
60
|
|
|
61
61
|
| The task | Read |
|
|
62
62
|
| --- | --- |
|
|
63
|
-
| A site — landing, catalogue, blog | [elements-and-styles](reference/elements-and-styles.md), [layouts](reference/layouts.md), [components](reference/components.md), [lists](reference/lists.md) |
|
|
63
|
+
| A site — landing, catalogue, blog | [elements-and-styles](reference/elements-and-styles.md), [structure](reference/structure.md), [layouts](reference/layouts.md), [components](reference/components.md), [lists](reference/lists.md), [colours-and-motion](reference/colours-and-motion.md) |
|
|
64
64
|
| An app with state and actions | [data-and-visibility](reference/data-and-visibility.md), [templates](reference/templates.md), [flows](reference/flows.md) |
|
|
65
65
|
| A component of your own | [plugins](reference/plugins.md) |
|
|
66
66
|
| A whole working file to copy | [recipes](reference/recipes.md) |
|
|
@@ -92,9 +92,9 @@ export const recipe: SpaceSpec = {
|
|
|
92
92
|
class: dot,
|
|
93
93
|
bind: [
|
|
94
94
|
bindTemplate('title', r.index, 'Slide {{ source + 1 }}'),
|
|
95
|
-
activeWhen(dot, `{{ ${r.
|
|
95
|
+
activeWhen(dot, `{{ ${r.index} == carousel_hero.index }}`)
|
|
96
96
|
],
|
|
97
|
-
flows: [[onClick(), carouselGoTo('hero', `{{ ${r.
|
|
97
|
+
flows: [[onClick(), carouselGoTo('hero', `{{ ${r.index} }}`)]]
|
|
98
98
|
})
|
|
99
99
|
]
|
|
100
100
|
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A table of data — plans compared — whose rows come from its items and whose columns are `tableColumn`s: a `<table>`
|
|
3
|
+
* with its head, read as a table by a screen reader and a search engine. The plan's name names its row (`rowHeader`);
|
|
4
|
+
* the seats column shows once a button asks for it (`visibleIf` over the state), gone from the head and every row at
|
|
5
|
+
* once; a row's link reads the row in its template with `r.item`, as a binding does.
|
|
6
|
+
*/
|
|
7
|
+
import {
|
|
8
|
+
button,
|
|
9
|
+
container,
|
|
10
|
+
link,
|
|
11
|
+
styles,
|
|
12
|
+
table,
|
|
13
|
+
tableColumn,
|
|
14
|
+
text,
|
|
15
|
+
toggleState,
|
|
16
|
+
onClick,
|
|
17
|
+
visibleIf
|
|
18
|
+
} from '@plitzi/sdk-authoring';
|
|
19
|
+
|
|
20
|
+
import type { ElementSpec, SpaceSpec } from '@plitzi/sdk-authoring';
|
|
21
|
+
|
|
22
|
+
const PLANS = [
|
|
23
|
+
{ slug: 'site', name: 'Site', price: '9 €', seats: '1' },
|
|
24
|
+
{ slug: 'team', name: 'Team', price: '29 €', seats: '5' },
|
|
25
|
+
{ slug: 'business', name: 'Business', price: '79 €', seats: '25' }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const plansTable = styles('plans-table', { 'max-width': '720px' });
|
|
29
|
+
|
|
30
|
+
/** The plans, a row each: the plan names its row, its price, its seats while asked for, and a link to its page. */
|
|
31
|
+
const plans: ElementSpec = table({
|
|
32
|
+
id: 'plans',
|
|
33
|
+
caption: 'Plans compared',
|
|
34
|
+
class: plansTable,
|
|
35
|
+
items: PLANS,
|
|
36
|
+
itemKey: 'slug',
|
|
37
|
+
row: r => [
|
|
38
|
+
tableColumn({ header: 'Plan', rowHeader: true, children: [text({ from: `${r.item}.name` })] }),
|
|
39
|
+
tableColumn({ header: 'Price', children: [text({ from: `${r.item}.price` })] }),
|
|
40
|
+
tableColumn({
|
|
41
|
+
header: 'Seats',
|
|
42
|
+
visible: visibleIf('state.showSeats', '==', true),
|
|
43
|
+
children: [text({ from: `${r.item}.seats` })]
|
|
44
|
+
}),
|
|
45
|
+
tableColumn({
|
|
46
|
+
header: 'Details',
|
|
47
|
+
children: [
|
|
48
|
+
link({ href: `/plans/{{ ${r.item}.slug }}`, mode: 'external', label: 'The plan’s page', content: 'More' })
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const showSeats = button('Show seats', { id: 'show-seats', flows: [[onClick(), toggleState({ key: 'showSeats' })]] });
|
|
55
|
+
|
|
56
|
+
export const recipe: SpaceSpec = {
|
|
57
|
+
name: 'Plans',
|
|
58
|
+
permanentUrl: 'plans',
|
|
59
|
+
pages: [{ id: 'home', name: 'Home', slug: '', body: [container({ subType: 'main', children: [showSeats, plans] })] }]
|
|
60
|
+
};
|
|
@@ -13,8 +13,9 @@ them the same way you fix any other warning. A page's heading outline is a sugge
|
|
|
13
13
|
// Words of its own: nothing to add.
|
|
14
14
|
button({ content: 'Save' })
|
|
15
15
|
|
|
16
|
-
// An icon only: `
|
|
17
|
-
|
|
16
|
+
// An icon only: `label` is its name — the one every control takes, a link's and a summary's too. `title` adds the
|
|
17
|
+
// tooltip. The icon is hidden from the tree by itself.
|
|
18
|
+
button({ content: '', label: 'Close', icon: 'fa-solid fa-xmark' })
|
|
18
19
|
|
|
19
20
|
// Words that do not say what it does — a key hint, a count: `label` is read in their place.
|
|
20
21
|
button({ content: 'V', label: 'Select (V)', title: 'Select — V', icon: 'fa-solid fa-arrow-pointer' })
|
|
@@ -70,7 +71,7 @@ A dropdown opens from a button too: put one among its children, outside the popu
|
|
|
70
71
|
(`aria-haspopup`, `aria-expanded`) and moves the focus into the menu and back out.
|
|
71
72
|
|
|
72
73
|
```ts
|
|
73
|
-
dropdown({ children: [dropdownPopup({ children: [ /* menu entries: buttons or links */ ] }), button({ content: '',
|
|
74
|
+
dropdown({ children: [dropdownPopup({ children: [ /* menu entries: buttons or links */ ] }), button({ content: '', label: 'Account', children: [avatar] })] })
|
|
74
75
|
```
|
|
75
76
|
|
|
76
77
|
## State is said, not only styled
|
|
@@ -88,7 +89,8 @@ row's panel is drawn as `<id>-<row>`, and the row's button points at its own. Wo
|
|
|
88
89
|
A part that opens and closes — a question and its answer, a menu, "show more" — is a `disclosure`, and needs no state
|
|
89
90
|
nor `ariaExpanded`: `disclosure({ children: [disclosureSummary([text({ content: 'Question' })]), …what it shows] })`.
|
|
90
91
|
It is the browser's own `<details>`, announced as one; the summary is the control and its name (words in it, never a
|
|
91
|
-
button)
|
|
92
|
+
button) — a menu's burger, an icon alone, names it with `label`: `disclosureSummary({ label: 'Menu', marker: false,
|
|
93
|
+
children: [svg(BURGER)] })`. It lights the `expanded` state while open. One `name` for several makes them an accordion, one open at a time
|
|
92
94
|
([recipes/accordion.ts](../recipes/accordion.ts)); Escape closes it, and so does a press outside with
|
|
93
95
|
`closeOnClickOutside` (a menu).
|
|
94
96
|
Results, a menu or a set of options someone goes through with the keyboard sit in `focusGroup({ label, children })`:
|
|
@@ -141,10 +141,10 @@ The space is not written until these are fixed.
|
|
|
141
141
|
| `redirect-target-unknown` | a page that sends visitors it is not for to a page the space does not have | a page's id or slug (`''` is the home page), or a full URL |
|
|
142
142
|
| `robots-txt-line` | a line of the space's `settings.robotsTxt` that no crawler reads, or one with no `User-agent` | `User-agent: *` then `Allow: /`, `Disallow: /overlay` — each line `Field: value`, or a comment |
|
|
143
143
|
| `robots-unknown` | a page's `robots` with a directive no search engine reads, or none | `robots: 'noindex'`, `'noindex, nofollow'` — or leave it out, and the page is indexed |
|
|
144
|
-
| `row-and-children` | a list with a `row` and `children` — the row is what it renders | one of the two |
|
|
144
|
+
| `row-and-children` | a list or a table with a `row` and `children` — the row is what it renders, a table’s its columns | one of the two |
|
|
145
145
|
| `row-component` | a list's `row` naming a component the space does not declare, or one with no prop to take the row | a declared component with an `item` prop — or a single prop — for the row |
|
|
146
|
-
| `row-outside-list` | `row` on an element that is not a list | a `list` around it |
|
|
147
|
-
| `row-without-id` | a list whose `row` is a function, with no `id` — the row's sources are named after it | `list({ id: 'products', items, row: r => … })` |
|
|
146
|
+
| `row-outside-list` | `row` on an element that is not a list, a carousel or a table | a `list` (or a `table`) around it |
|
|
147
|
+
| `row-without-id` | a list, a carousel or a table whose `row` is a function, with no `id` — the row's sources are named after it | `list({ id: 'products', items, row: r => … })` |
|
|
148
148
|
| `rule-set-mixed` | a style that writes its rules beside `states`, `variants` or `ancestors` instead of under `css` | `{ css: { desktop: { … } }, states: { hover: { … } } }` — the rules under `css`, each of the others beside it |
|
|
149
149
|
| `selector-invalid` | a `selector` that is not a CSS class name | letters, digits, `-` and `_` |
|
|
150
150
|
| `selector-taken` | a `selector` that is a declared class, or another element's | `class` to share rules; a selector of an element's own is its alone |
|
|
@@ -182,7 +182,7 @@ The space is not written until these are fixed.
|
|
|
182
182
|
| `style-state-unknown` | a state a selector does not react to | one of the states it lists (`hover`, `focus`, `active`…) |
|
|
183
183
|
| `svg-not-svg` | an `svg` whose `content` is not one `<svg>…</svg>` — it draws nothing | the SVG markup alone; HTML around it goes in a `blockHtml` |
|
|
184
184
|
| `template-in-value` | a `{{ }}` inside an attribute that is an object or a list — a provider's `input`, a list's `items`, a plugin's settings: only an attribute that is text is evaluated | a binding on the attribute (`bindTemplate(name, source, template, { returns: 'value' })`); for a provider's `input`, nothing for a route or query param — the action is already handed them as `input.<name>` |
|
|
185
|
-
| `template-short-source` | a source named without its prefix inside a template or a step | the full name: `apiContainer_stats`, `list_rows` — a list's row
|
|
185
|
+
| `template-short-source` | a source named without its prefix inside a template or a step | the full name: `apiContainer_stats`, `list_rows` — a list's row is `r.item`, completed in a template too |
|
|
186
186
|
| `template-source-out-of-scope` | a template reading the source of an element it is not inside | move the element inside it, or share the value through `state` |
|
|
187
187
|
| `template-text-into-value` | a template, which renders text, feeding an attribute that holds a list or an object | `bindTemplate('items', source, '{{ … }}', { returns: 'value' })` |
|
|
188
188
|
| `template-unknown-name` | a name in a template that is not a source, a variable or a route param | the full source name (`list_rows.item`), `navigation.queryParams.x`, or `source` for the bound value |
|
|
@@ -225,7 +225,7 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
225
225
|
| `colour-without-dark` | a colour token with no dark value | `{ light, dark, default }` |
|
|
226
226
|
| `condition-starts-visible` | a computed visibility that shows until its data answers | `visible: { source, template }` |
|
|
227
227
|
| `control-in-decorative` | a control inside a `decorative` container — Tab lands on something nothing announces | move it out of the illustration |
|
|
228
|
-
| `control-without-name` | a button or a
|
|
228
|
+
| `control-without-name` | a button, a link or a disclosure’s summary with no words, or a field nothing names | `label` on the control (a button’s `title` adds the tooltip), `label` (with `hideLabel: true`) on the field |
|
|
229
229
|
| `controls-no-anchor` | a button's `controls` naming no anchor — `aria-controls` points at nothing | an `anchor` on the element it shows and hides, and `controls` naming it |
|
|
230
230
|
| `countdown-units` | a `countdown` whose `smallest` unit is larger than its `largest` — it says the `largest` alone | `largest` the larger: `largest: 'days', smallest: 'minutes'` |
|
|
231
231
|
| `countdown-without-end` | a `countdown` with no `to` and no `timeWindow` around it with an `endsAt` — it shows zeros | `to: '2026-12-01T09:00:00Z'`, or the countdown inside the `timeWindow` whose end it counts to |
|
|
@@ -37,6 +37,7 @@ same flags, decided on the server. Use the step builders — they fill in where
|
|
|
37
37
|
- **Each step reads the page as it is when it runs.** A `when` or a `{{ state.x }}` after a `setState` sees the new
|
|
38
38
|
value, and one after a `delay` or a server action sees whatever changed meanwhile. To act on the value from BEFORE
|
|
39
39
|
a write, put the step that reads it first.
|
|
40
|
+
- **Shared flow:** one `StepSpec[]`.
|
|
40
41
|
- **Keys are flat names.** A dotted key (`docsClosed.start`) is split into a path; use `docsClosedStart`.
|
|
41
42
|
- **Back skips a replaced address.** `navigate({ urlType: 'internal', url, replace: true })` takes the place of the one
|
|
42
43
|
the visitor is on: a sheet a query opened (`?stats=1`), closed, is not reopened by Back.
|
|
@@ -16,8 +16,8 @@ list({ id: 'steps', subType: 'ol', children: [listItem({ children: [text('Mix')]
|
|
|
16
16
|
|
|
17
17
|
`items` (or `from`) makes a list controlled: an array of its own, or the source its rows come from. `row` is what it renders once
|
|
18
18
|
per item — a component's id (placed with the row bound to its `item` prop, or its only prop), or a function handed the
|
|
19
|
-
row's names: `r.item` and `r.index
|
|
20
|
-
(`` `/games/{{ ${r.
|
|
19
|
+
row's names: `r.item` and `r.index`, in a binding, `from` and a template alike
|
|
20
|
+
(`` `/games/{{ ${r.item}.slug }}` ``). A function needs the list's `id`, which names those sources. With
|
|
21
21
|
`items` a typed source's path (`items: site.data.games`, see typed-sources.md), the row is typed too:
|
|
22
22
|
`row: g => listItem({ children: [text({ from: g.item.title })] })`, and a field the sample's games lack is a type error.
|
|
23
23
|
|
|
@@ -41,9 +41,12 @@ row's names: `r.item` and `r.index` for a binding or `from`, `r.inTemplate.item`
|
|
|
41
41
|
reordered, a row's state (an open detail, a field's text) follows its item. Items named by another field say so —
|
|
42
42
|
`itemKey: 'slug'` (`list-item-key-missing` warns when fixed items lack it). A row whose item changes mounts again,
|
|
43
43
|
so a one-row list showing "the current slide" replays the slide's entrance animation.
|
|
44
|
-
- **A data table**
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
- **A data table** — a comparison, leads, a product's specs — is a `table`, fed like a list, its `row` writing its
|
|
45
|
+
columns: `table({ id: 'plans', caption: 'Plans compared', items, row: r => [tableColumn({ header: 'Plan', rowHeader:
|
|
46
|
+
true, children: [text({ from: \`${r.item}.name\` })] }), tableColumn({ header: 'Seats', visible: visibleIf('state.showSeats',
|
|
47
|
+
'==', true), children: […] })] })`. A `<table>` with its head (`<th scope="col">`), read as one by a screen reader and a
|
|
48
|
+
search engine, which a grid of boxes is not; a column's `visible` takes it from the head and every row. Its slots:
|
|
49
|
+
`caption`, `head`, `row`; a column's `header`. Fixed words are still a `markdown` table (slots `table`, `tableHead`…).
|
|
47
50
|
|
|
48
51
|
## Filtering and sorting
|
|
49
52
|
|
|
@@ -8,6 +8,7 @@ Each is a whole file that authors with no warning — CI holds it to that. Copy
|
|
|
8
8
|
| Data typed by a sample of it: completed and checked paths, typed rows | [recipes/typed-data.ts](../recipes/typed-data.ts) |
|
|
9
9
|
| Data read by the page server (`--mode server`) | [recipes/server-data.ts](../recipes/server-data.ts) |
|
|
10
10
|
| An accordion, one answer open at a time | [recipes/accordion.ts](../recipes/accordion.ts) |
|
|
11
|
+
| A table of data: a row per item, a column shown from the state, a row's link built from it | [recipes/table.ts](../recipes/table.ts) |
|
|
11
12
|
| Filter and sort a list from a select | [recipes/filter-a-list.ts](../recipes/filter-a-list.ts) |
|
|
12
13
|
| A page per record (`/products/:slug`), and "not found" sent with 404 | [recipes/detail-page.ts](../recipes/detail-page.ts) |
|
|
13
14
|
| Link to a section of a page (`/#plans`) | [recipes/link-to-a-section.ts](../recipes/link-to-a-section.ts) |
|
|
@@ -53,7 +53,8 @@ refuses or warns of, with the fix.
|
|
|
53
53
|
placed with `defineElement(declaration)` — to the events, actions and attributes it declares. See
|
|
54
54
|
[plugins](plugins.md).
|
|
55
55
|
13. **Usable without sight.** Screen readers and browser agents (Claude in Chrome) find a page's controls in its
|
|
56
|
-
accessibility tree: every button and
|
|
56
|
+
accessibility tree: every button, link and disclosure summary has words — an icon alone, a `label`, the one name
|
|
57
|
+
every control takes (a button's `title` only adds the tooltip) — every field a `label`
|
|
57
58
|
(`hideLabel: true` hides it and keeps the name), every image an `alt` or `decorative: true`. Clicks go on a
|
|
58
59
|
`button` — it holds children, so a whole card can be one — or a `link`, never on a container. See
|
|
59
60
|
[accessibility](accessibility.md).
|
|
@@ -18,7 +18,7 @@ apiContainer({ id: site.id, query: '/data/home.json', children: [
|
|
|
18
18
|
template through `twig` (a plain template literal writes the same text, but a type-checked lint refuses an object in
|
|
19
19
|
one).
|
|
20
20
|
- A list fed by a path hands its `row` the item typed: every field any item of the sample has — `p.item`, `p.index`,
|
|
21
|
-
|
|
21
|
+
as an untyped row's are, so turning a list typed changes none of its templates.
|
|
22
22
|
- **Only `items: <path>` types the row.** A list whose `items` are `from` + `as` (sorted, filtered — `as: '{{ source|sort(e
|
|
23
23
|
=> e.date)|reverse }}'`) or written out (`items: CATEGORIES`) hands an untyped row: its names are text, so a field is
|
|
24
24
|
`` `${r.item}.date` ``, never `r.item.date` (undefined — refused `source-name-missing`). Need a sorted list typed? Sort
|