@plitzi/sdk-authoring 0.38.2 → 0.38.3

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/dist/index-compactSvg.js +13 -0
  3. package/dist/index.d.ts +162 -6
  4. package/dist/index.js +1410 -1020
  5. package/dist/node.d.ts +21 -0
  6. package/dist/node.js +35 -0
  7. package/package.json +14 -6
  8. package/skills/plitzi-authoring/CHEATSHEET.md +5 -3
  9. package/skills/plitzi-authoring/SKILL.md +1 -0
  10. package/skills/plitzi-authoring/recipes/carousel.ts +14 -9
  11. package/skills/plitzi-authoring/recipes/detail-page.ts +10 -6
  12. package/skills/plitzi-authoring/recipes/every-few-seconds.ts +13 -8
  13. package/skills/plitzi-authoring/recipes/filter-a-list.ts +2 -2
  14. package/skills/plitzi-authoring/recipes/forms-and-modals.ts +1 -2
  15. package/skills/plitzi-authoring/recipes/from-tailwind.ts +1 -1
  16. package/skills/plitzi-authoring/recipes/link-to-a-section.ts +2 -2
  17. package/skills/plitzi-authoring/recipes/link-with-data.ts +12 -7
  18. package/skills/plitzi-authoring/recipes/marquee.ts +2 -2
  19. package/skills/plitzi-authoring/recipes/scroll-a-row.ts +5 -6
  20. package/skills/plitzi-authoring/recipes/show-data.ts +12 -7
  21. package/skills/plitzi-authoring/recipes/typed-data.ts +9 -6
  22. package/skills/plitzi-authoring/recipes/usable-without-sight.ts +2 -2
  23. package/skills/plitzi-authoring/reference/accessibility.md +2 -2
  24. package/skills/plitzi-authoring/reference/authoring-errors.md +5 -0
  25. package/skills/plitzi-authoring/reference/colours-and-motion.md +3 -0
  26. package/skills/plitzi-authoring/reference/components.md +2 -1
  27. package/skills/plitzi-authoring/reference/drawing.md +22 -0
  28. package/skills/plitzi-authoring/reference/elements-and-styles.md +2 -2
  29. package/skills/plitzi-authoring/reference/lists.md +11 -6
  30. package/skills/plitzi-authoring/reference/plugins.md +5 -0
  31. package/skills/plitzi-authoring/reference/structure.md +1 -1
  32. package/skills/plitzi-authoring/reference/testing.md +9 -4
  33. package/skills/plitzi-authoring/reference/typed-sources.md +1 -1
  34. package/skills/plitzi-authoring/reference/validation.md +3 -2
package/dist/node.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * An SVG as it is worth carrying in a space: what a design tool wrote for itself taken out — the XML prolog and doctype,
3
+ * comments, `<metadata>`, an editor's own elements and attributes (Inkscape, Sodipodi, Sketch, Figma's `data-name`) —
4
+ * and the whitespace between tags. What draws, and its `<title>`, stay as they were.
5
+ *
6
+ * Every byte of an inline SVG is in the space's documents and in every page that shows it, so a logo exported from a
7
+ * design tool with half its size in notes to itself is that much heavier for nothing. `svg()` checks and sanitises
8
+ * what it is given; this only makes it smaller.
9
+ */
10
+ export declare const compactSvg: (markup: string) => string;
11
+
12
+ /** One SVG file, compacted (`compactSvg`) — what `svg()` takes. Refused, with its path, when it is not an SVG. */
13
+ export declare const svgFile: (file: string | URL) => string;
14
+
15
+ /**
16
+ * Every `.svg` in a folder, by its name without the extension — a set of logos or icons kept as files rather than as
17
+ * strings in the space's source, where they were most of its bytes and nothing an author reads.
18
+ */
19
+ export declare const svgFiles: (folder: string | URL) => Record<string, string>;
20
+
21
+ export { }
package/dist/node.js ADDED
@@ -0,0 +1,35 @@
1
+ import { t as compactSvg } from "./index-compactSvg.js";
2
+ import { readFileSync, readdirSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ //#region src/node.ts
6
+ /**
7
+ * What only an author running on Node can do: read the project's own files. A separate entry, so the package's main
8
+ * one stays what it is — data and functions over data, for a browser as much as a build script.
9
+ *
10
+ * ```ts
11
+ * import { svgFile, svgFiles } from '@plitzi/sdk-authoring/node';
12
+ *
13
+ * const logos = svgFiles(new URL('./logos/', import.meta.url)); // { stripe: '<svg…>', shopify: '<svg…>' }
14
+ * svg(logos.stripe, { label: 'Stripe' });
15
+ * svg(svgFile(new URL('./icons/arrow.svg', import.meta.url)));
16
+ * ```
17
+ */
18
+ var pathOf = (where) => where instanceof URL ? fileURLToPath(where) : where;
19
+ /** One SVG file, compacted (`compactSvg`) — what `svg()` takes. Refused, with its path, when it is not an SVG. */
20
+ var svgFile = (file) => {
21
+ const at = pathOf(file);
22
+ const markup = compactSvg(readFileSync(at, "utf-8"));
23
+ if (!/^<svg[\s>]/i.test(markup)) throw new Error(`${at} is not an SVG: it does not start with <svg> once its prolog and comments are taken out.`);
24
+ return markup;
25
+ };
26
+ /**
27
+ * Every `.svg` in a folder, by its name without the extension — a set of logos or icons kept as files rather than as
28
+ * strings in the space's source, where they were most of its bytes and nothing an author reads.
29
+ */
30
+ var svgFiles = (folder) => {
31
+ const at = pathOf(folder);
32
+ return Object.fromEntries(readdirSync(at).filter((name) => name.toLowerCase().endsWith(".svg")).sort().map((name) => [path.basename(name, path.extname(name)), svgFile(path.join(at, name))]));
33
+ };
34
+ //#endregion
35
+ export { compactSvg, svgFile, svgFiles };
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-authoring",
3
- "version": "0.38.2",
3
+ "version": "0.38.3",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist/index.js",
7
7
  "dist/index.d.ts",
8
+ "dist/index-*.js",
9
+ "dist/node.js",
10
+ "dist/node.d.ts",
8
11
  "skills"
9
12
  ],
10
13
  "main": "dist/index.js",
@@ -16,6 +19,11 @@
16
19
  "import": "./dist/index.js",
17
20
  "default": "./dist/index.js"
18
21
  },
22
+ "./node": {
23
+ "types": "./dist/node.d.ts",
24
+ "import": "./dist/node.js",
25
+ "default": "./dist/node.js"
26
+ },
19
27
  "./skills/*": "./skills/*",
20
28
  "./package.json": "./package.json"
21
29
  },
@@ -46,11 +54,11 @@
46
54
  "devDependencies": {
47
55
  "@microsoft/api-extractor": "^7.59.3",
48
56
  "@plitzi/plitzi-ui": "^1.6.29",
49
- "@plitzi/sdk-elements": "0.38.2",
50
- "@plitzi/sdk-interactions": "0.38.2",
51
- "@plitzi/sdk-schema": "0.38.2",
52
- "@plitzi/sdk-shared": "0.38.2",
53
- "@plitzi/sdk-style": "0.38.2",
57
+ "@plitzi/sdk-elements": "0.38.3",
58
+ "@plitzi/sdk-interactions": "0.38.3",
59
+ "@plitzi/sdk-schema": "0.38.3",
60
+ "@plitzi/sdk-shared": "0.38.3",
61
+ "@plitzi/sdk-style": "0.38.3",
54
62
  "@types/react": "^19.3.0",
55
63
  "eslint": "^9.39.5",
56
64
  "typescript": "^6.0.3",
@@ -31,15 +31,17 @@ text('Words', { class }) // also text({ content }); a <div
31
31
  heading('Title', { subType: 'h2' }) // h1–h6; holds no children
32
32
  paragraph('A paragraph.')
33
33
  container([children], { subType: 'section' }) // div, section, nav, header, footer, main, article, li, h1–h6, span…
34
- link({ href: 'about', children }) // a page id, a '/path', or a URL — the mode follows from the href
34
+ link({ href: 'about', content: 'About' }) // a page id, a '/path', or a URL — the mode follows from the href
35
35
  link({ href: 'home', hash: 'plans' }) // → /#plans, onto the element with anchor: 'plans'
36
+ container({ motion: { enter: 'fade-up', on: 'view' }, children }) // arrives as it scrolls in; stagger, loop too
36
37
  button({ content: 'Save', flows }) // holds children too: then content: ''
37
38
  image({ src, alt }) // or decorative: true
38
39
  embed({ src, title }) // a map, a player: another page in a frame
39
40
  svg('<svg …>…</svg>', { label }) // checked, sanitised; currentColor follows the class
41
+ svg(svgFile(new URL('./logo.svg', import.meta.url))) // a file, compacted: svgFile/svgFiles from '@plitzi/sdk-authoring/node'
40
42
  fontAwesome({ icon: 'fa-solid fa-xmark' })
41
- list({ id: 'rows', items: 'p.data.rows', row: 'row-card' }) // a <ul>; a component per row (its `item` prop)
42
- list({ id: 'rows', items: 'p.data.rows', row: r => text({ from: `${r.item}.title` }) }) // or a tree per row
43
+ list({ id: 'rows', items: 'p.data.rows', row: 'row-card' }) // a <ul>; a component per row, its root an <li>
44
+ list({ id: 'rows', items: 'p.data.rows', row: r => listItem({ children: [text({ from: `${r.item}.title` })] }) })
43
45
  carousel({ id: 'hero', items: 'p.data.slides', autoplay: 5000, row: 'slide-card', children: [/* carouselNext('hero') arrows */] })
44
46
  // rows follow their item's `id`, or `itemKey: 'slug'`
45
47
  apiContainer({ id: 'p', query: '/data/x.json', cache: true, children }) // publishes p.data; no box of its own
@@ -158,6 +158,7 @@ Each is a whole file that authors with no warning — CI holds it to that. Copy
158
158
  | [flows.md](reference/flows.md) | Clicks, submits, page loads, every few seconds, server actions, modals, state |
159
159
  | [realtime.md](reference/realtime.md) | Pages that see each other: channels, presence, cursors, a shared board, who may hear a topic |
160
160
  | [plugins.md](reference/plugins.md) | A component of your own: props, binding them, writing state, channels, registering, behaving in the builder |
161
+ | [drawing.md](reference/drawing.md) | A plugin that draws or animates: a canvas sized to the device, WebGL shaders that say why they failed, a loop that stops when nobody sees it |
161
162
  | [structure.md](reference/structure.md) | A space bigger than one screen: files, helpers, naming, keeping it short |
162
163
  | [testing.md](reference/testing.md) | Any test: `inspectPage` (one call, every problem), handles, fixtures, catching a flash from the first frame, shortcuts, counting renders |
163
164
  | [performance.md](reference/performance.md) | A page with many elements, a busy flow, something that feels slow: what renders, what it costs, how to measure it |
@@ -16,7 +16,8 @@ import {
16
16
  list,
17
17
  onClick,
18
18
  styles,
19
- text
19
+ text,
20
+ listItem
20
21
  } from '@plitzi/sdk-authoring';
21
22
 
22
23
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
@@ -74,14 +75,18 @@ export const recipe: SpaceSpec = {
74
75
  class: dots,
75
76
  items: 'hero.items',
76
77
  row: r =>
77
- button({
78
- content: '',
79
- class: dot,
80
- bind: [
81
- bindTemplate('title', r.index, 'Slide {{ source + 1 }}'),
82
- activeWhen(dot, `{{ ${r.inTemplate.index} == carousel_hero.index }}`)
83
- ],
84
- flows: [[onClick(), carouselGoTo('hero', `{{ ${r.inTemplate.index} }}`)]]
78
+ listItem({
79
+ children: [
80
+ button({
81
+ content: '',
82
+ class: dot,
83
+ bind: [
84
+ bindTemplate('title', r.index, 'Slide {{ source + 1 }}'),
85
+ activeWhen(dot, `{{ ${r.inTemplate.index} == carousel_hero.index }}`)
86
+ ],
87
+ flows: [[onClick(), carouselGoTo('hero', `{{ ${r.inTemplate.index} }}`)]]
88
+ })
89
+ ]
85
90
  })
86
91
  })
87
92
  ]
@@ -3,7 +3,7 @@
3
3
  * A page per record: a card links to `/products/<slug>`, and the detail page narrows the same file to the product its
4
4
  * address names — with a message, not an empty page, when no product has that name.
5
5
  */
6
- import { apiContainer, heading, link, list, text } from '@plitzi/sdk-authoring';
6
+ import { apiContainer, heading, link, list, text, listItem } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
@@ -25,10 +25,14 @@ export const recipe: SpaceSpec = {
25
25
  id: 'products',
26
26
  items: 'catalog.data.products',
27
27
  children: [
28
- // An attribute reads a name with filters, spelled in full.
29
- link({
30
- href: '/products/{{ list_products.item.slug|url_encode }}',
31
- children: [text({ from: 'products.item.title' })]
28
+ listItem({
29
+ children: [
30
+ // An attribute reads a name with filters, spelled in full.
31
+ link({
32
+ href: '/products/{{ list_products.item.slug|url_encode }}',
33
+ children: [text({ from: 'products.item.title' })]
34
+ })
35
+ ]
32
36
  })
33
37
  ]
34
38
  })
@@ -54,7 +58,7 @@ export const recipe: SpaceSpec = {
54
58
  source: 'catalog-one.data.products',
55
59
  template: "{{ source|find('slug', navigation.routeParams.slug) }}"
56
60
  },
57
- children: [heading({ subType: 'h1', from: 'this-product.item.title' })]
61
+ children: [listItem({ children: [heading({ subType: 'h1', from: 'this-product.item.title' })] })]
58
62
  }),
59
63
  text('No product by that name.', {
60
64
  visible: {
@@ -18,7 +18,8 @@ import {
18
18
  styles,
19
19
  text,
20
20
  activeWhen,
21
- when
21
+ when,
22
+ listItem
22
23
  } from '@plitzi/sdk-authoring';
23
24
 
24
25
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
@@ -81,7 +82,7 @@ export const recipe: SpaceSpec = {
81
82
  id: 'slides',
82
83
  items: SLIDES,
83
84
  children: [
84
- container({
85
+ listItem({
85
86
  class: slide,
86
87
  visible: { source: 'slides.index', template: '{{ source == (state.slide ?? 0) }}' },
87
88
  children: [heading({ subType: 'h2', from: 'slides.item.title' }), text({ from: 'slides.item.body' })]
@@ -101,12 +102,16 @@ export const recipe: SpaceSpec = {
101
102
  class: dots,
102
103
  items: SLIDES,
103
104
  children: [
104
- button({
105
- content: '',
106
- title: 'Show this offer',
107
- class: dot,
108
- bind: [activeWhen(dot, '{{ list_dots.index == (state.slide ?? 0) }}')],
109
- flows: [[onClick(), setState({ key: 'slide', type: 'number', value: '{{ list_dots.index }}' })]]
105
+ listItem({
106
+ children: [
107
+ button({
108
+ content: '',
109
+ title: 'Show this offer',
110
+ class: dot,
111
+ bind: [activeWhen(dot, '{{ list_dots.index == (state.slide ?? 0) }}')],
112
+ flows: [[onClick(), setState({ key: 'slide', type: 'number', value: '{{ list_dots.index }}' })]]
113
+ })
114
+ ]
110
115
  })
111
116
  ]
112
117
  }),
@@ -3,7 +3,7 @@
3
3
  * Filter and sort a list: a select writes the chosen category to `state`, and the list is bound through a template
4
4
  * that hands over its VALUE — only the matching rows are rendered, with a count and an empty state over the same rows.
5
5
  */
6
- import { apiContainer, formControl, list, named, on, setState, text } from '@plitzi/sdk-authoring';
6
+ import { apiContainer, formControl, list, named, on, setState, text, listItem } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
@@ -47,7 +47,7 @@ export const recipe: SpaceSpec = {
47
47
  id: 'shown',
48
48
  from: 'catalog.data.products',
49
49
  as: `{{ ${shown} }}`,
50
- children: [text({ from: 'shown.item.title' })]
50
+ children: [listItem({ children: [text({ from: 'shown.item.title' })] })]
51
51
  }),
52
52
  text('Nothing in that category.', {
53
53
  visible: {
@@ -5,7 +5,6 @@
5
5
  import {
6
6
  button,
7
7
  closeModal,
8
- fontAwesome,
9
8
  form,
10
9
  formControl,
11
10
  modalContainer,
@@ -52,7 +51,7 @@ export const recipe: SpaceSpec = {
52
51
  button({
53
52
  content: '',
54
53
  title: 'Close',
55
- children: [fontAwesome({ icon: 'fa-solid fa-xmark' })],
54
+ icon: 'fa-solid fa-xmark',
56
55
  flows: [[onClick(), closeModal('details')]]
57
56
  })
58
57
  ]
@@ -45,7 +45,7 @@ export const recipe: SpaceSpec = {
45
45
  container({ class: card, children: [heading(name, { subType: 'h3', class: title }), text('…')] })
46
46
  )
47
47
  }),
48
- link({ href: '/start', class: cta, children: [text('Get started')] })
48
+ link({ href: '/start', class: cta, content: 'Get started' })
49
49
  ]
50
50
  }
51
51
  ]
@@ -15,7 +15,7 @@ export const recipe: SpaceSpec = {
15
15
  name: 'Home',
16
16
  slug: '',
17
17
  body: [
18
- link({ href: 'home', hash: 'plans', children: [text('See the plans')] }),
18
+ link({ href: 'home', hash: 'plans', content: 'See the plans' }),
19
19
  container({
20
20
  id: 'plans-section',
21
21
  subType: 'section',
@@ -29,7 +29,7 @@ export const recipe: SpaceSpec = {
29
29
  name: 'About',
30
30
  slug: 'about',
31
31
  // → /#plans
32
- body: [link({ href: 'home', hash: 'plans', children: [text('Plans')] })]
32
+ body: [link({ href: 'home', hash: 'plans', content: 'Plans' })]
33
33
  }
34
34
  ]
35
35
  };
@@ -2,7 +2,7 @@
2
2
  * A link built from the row it is in — here "ask about this product" on WhatsApp, with the product's name in the
3
3
  * message. An attribute resolves a name with filters, so the text is encoded with `url_encode`.
4
4
  */
5
- import { apiContainer, fontAwesome, link, list, text } from '@plitzi/sdk-authoring';
5
+ import { apiContainer, link, list, listItem } from '@plitzi/sdk-authoring';
6
6
 
7
7
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
8
8
 
@@ -24,12 +24,17 @@ export const recipe: SpaceSpec = {
24
24
  id: 'products',
25
25
  items: 'catalog.data.products',
26
26
  children: [
27
- link({
28
- target: 'blank',
29
- href: 'https://wa.me/34600000000?text={{ list_products.item.title|url_encode }}',
30
- children: [fontAwesome({ icon: 'fa-brands fa-whatsapp' }), text('Ask about it')]
31
- }),
32
- link({ href: 'mailto:shop@example.com', children: [text('Write to us')] })
27
+ listItem({
28
+ children: [
29
+ link({
30
+ target: 'blank',
31
+ href: 'https://wa.me/34600000000?text={{ list_products.item.title|url_encode }}',
32
+ icon: 'fa-brands fa-whatsapp',
33
+ content: 'Ask about it'
34
+ }),
35
+ link({ href: 'mailto:shop@example.com', content: 'Write to us' })
36
+ ]
37
+ })
33
38
  ]
34
39
  })
35
40
  ]
@@ -2,7 +2,7 @@
2
2
  * A marquee: a row of names that scrolls for ever and stops under the pointer. The items are rendered three times
3
3
  * and the keyframe moves the track by a third, so the end meets the start with no jump.
4
4
  */
5
- import { apiContainer, container, list, styles, text } from '@plitzi/sdk-authoring';
5
+ import { apiContainer, container, list, styles, text, listItem } from '@plitzi/sdk-authoring';
6
6
 
7
7
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
8
8
 
@@ -45,7 +45,7 @@ export const recipe: SpaceSpec = {
45
45
  class: track,
46
46
  from: 'catalog.data.brands',
47
47
  as: '{{ source|merge(source)|merge(source) }}',
48
- children: [text({ from: 'brands.item' })]
48
+ children: [listItem({ children: [text({ from: 'brands.item' })] })]
49
49
  })
50
50
  ]
51
51
  })
@@ -12,7 +12,8 @@ import {
12
12
  scrollBy,
13
13
  setState,
14
14
  styles,
15
- text
15
+ text,
16
+ listItem
16
17
  } from '@plitzi/sdk-authoring';
17
18
 
18
19
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
@@ -45,10 +46,9 @@ export const recipe: SpaceSpec = {
45
46
  children: [
46
47
  // Shown until the row says it is at that end: the arrows are there before anybody scrolls.
47
48
  button({
48
- content: '',
49
+ content: '‹',
49
50
  title: 'Previous categories',
50
51
  visible: '!state.rowAtStart',
51
- children: [text('‹')],
52
52
  flows: [[onClick(), scrollBy('categories', { x: '-80%' })]]
53
53
  }),
54
54
  list({
@@ -62,13 +62,12 @@ export const recipe: SpaceSpec = {
62
62
  setState({ key: 'rowAtEnd', type: 'boolean', value: '{{ moved.atEnd }}' })
63
63
  ]
64
64
  ],
65
- children: [text({ class: card, from: 'categories.item' })]
65
+ children: [listItem({ class: card, children: [text({ from: 'categories.item' })] })]
66
66
  }),
67
67
  button({
68
- content: '',
68
+ content: '›',
69
69
  title: 'More categories',
70
70
  visible: '!state.rowAtEnd',
71
- children: [text('›')],
72
71
  flows: [[onClick(), scrollBy('categories', { x: '80%' })]]
73
72
  })
74
73
  ]
@@ -3,18 +3,17 @@
3
3
  * Show data with no backend: a JSON file the project serves (`public/data/products.json`), read by a provider — one
4
4
  * card per product, a skeleton while it loads, a count, a computed value, and an empty state that never flashes.
5
5
  */
6
- import { apiContainer, container, heading, list, styles, text } from '@plitzi/sdk-authoring';
6
+ import { apiContainer, container, heading, list, styles, text, listItem } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
10
- // A list is a `<ul>`: a grid of cards takes the bullets and the indent off.
10
+ // A list is a `<ul>`, its rows `<li>`s straight inside: the grid is all its class says, the indent taken off.
11
11
  const grid = styles('product-grid', {
12
12
  display: 'grid',
13
13
  'grid-template-columns': 'repeat(auto-fill, minmax(220px, 1fr))',
14
14
  gap: '16px',
15
15
  margin: '0px',
16
- padding: '0px',
17
- 'list-style-type': 'none'
16
+ padding: '0px'
18
17
  });
19
18
 
20
19
  const card = styles('product-card', { padding: '16px', 'border-radius': '12px', 'background-color': 'var(--card)' });
@@ -56,9 +55,15 @@ export const recipe: SpaceSpec = {
56
55
  class: grid,
57
56
  items: 'catalog.data.products',
58
57
  children: [
59
- // Inside a row, a binding names the row short (`products.item`), a template in full (`list_products`).
60
- heading({ subType: 'h3', class: card, from: 'products.item.title' }),
61
- text({ from: 'products.item.price', as: 'price' })
58
+ // One `<li>` per product. Inside a row, a binding names the row short (`products.item`), a template in
59
+ // full (`list_products`).
60
+ listItem({
61
+ class: card,
62
+ children: [
63
+ heading({ subType: 'h3', from: 'products.item.title' }),
64
+ text({ from: 'products.item.price', as: 'price' })
65
+ ]
66
+ })
62
67
  ]
63
68
  }),
64
69
  // Revealed by the data, so it starts hidden: nothing flashes while the file loads.
@@ -4,7 +4,7 @@
4
4
  * `site.data.hero.titel` is a type error, not an empty heading. In a project the sample is the file itself:
5
5
  * `import home from '../../public/data/home.json' with { type: 'json' }`.
6
6
  */
7
- import { apiContainer, heading, list, source, styles, text, twig } from '@plitzi/sdk-authoring';
7
+ import { apiContainer, heading, list, source, styles, text, twig, listItem } from '@plitzi/sdk-authoring';
8
8
 
9
9
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
10
10
 
@@ -50,11 +50,14 @@ export const recipe: SpaceSpec = {
50
50
  class: grid,
51
51
  items: site.data.products,
52
52
  // The row's item is typed as the sample's: every field any product has.
53
- row: product => [
54
- text({ from: product.item.title }),
55
- text({ from: product.item.price, as: 'price' }),
56
- text({ from: product.item.badge, visible: product.item.badge })
57
- ]
53
+ row: product =>
54
+ listItem({
55
+ children: [
56
+ text({ from: product.item.title }),
57
+ text({ from: product.item.price, as: 'price' }),
58
+ text({ from: product.item.badge, visible: product.item.badge })
59
+ ]
60
+ })
58
61
  })
59
62
  ]
60
63
  })
@@ -3,7 +3,7 @@
3
3
  * button, a field keeps its label out of sight rather than dropping it, a picture says what it shows or that it only
4
4
  * decorates.
5
5
  */
6
- import { button, fontAwesome, formControl, image, setState, styles, text, onClick } from '@plitzi/sdk-authoring';
6
+ import { button, formControl, image, setState, styles, text, onClick } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
@@ -23,7 +23,7 @@ export const recipe: SpaceSpec = {
23
23
  name: 'Home',
24
24
  slug: '',
25
25
  body: [
26
- button({ content: '', title: 'Search', children: [fontAwesome({ icon: 'fa-solid fa-magnifying-glass' })] }),
26
+ button({ content: '', title: 'Search', icon: 'fa-solid fa-magnifying-glass' }),
27
27
  button({
28
28
  content: '',
29
29
  class: card,
@@ -13,10 +13,10 @@ warns about each case below (`control-without-name`, `image-without-alt`, `click
13
13
  button({ content: 'Save' })
14
14
 
15
15
  // An icon only: `title` is its name, and also its tooltip. The icon is hidden from the tree by itself.
16
- button({ content: '', title: 'Close', children: [fontAwesome({ icon: 'fa-solid fa-xmark' })] })
16
+ button({ content: '', title: 'Close', icon: 'fa-solid fa-xmark' })
17
17
 
18
18
  // Words that do not say what it does — a key hint, a count: `label` is read in their place.
19
- button({ content: '', label: 'Select (V)', title: 'Select — V', children: [fontAwesome({ icon: 'fa-solid fa-arrow-pointer' }), text('V')] })
19
+ button({ content: 'V', label: 'Select (V)', title: 'Select — V', icon: 'fa-solid fa-arrow-pointer' })
20
20
 
21
21
  // A link around a whole card: without `label` it is announced as every word inside the card.
22
22
  link({ href: '/posts/field-notes', label: 'Read “Field notes”', children: [ /* cover, topic, title, byline */ ] })
@@ -92,6 +92,8 @@ The space is not written until these are fixed.
92
92
  | `loading-slot-unknown` | an `apiContainer`'s `loadingSlot` that is not the id of one of its children | the id of the child to show until the first answer — `loadingSlot: 'catalog-skeleton'` beside that child |
93
93
  | `modifier-count` | more than one set of rules in a class list | one set, after the classes: `class: [card, { opacity: '0.5', 'margin-top': '8px' }]` |
94
94
  | `modifier-without-id` | rules on top of a class on an element with no `id` — the id names the class they become | `id: 'hero-bg'` |
95
+ | `motion-invalid` | a `motion` with a preset, a trigger or a timing the page cannot play | `motion: { enter: 'fade-up', on: 'view' }` — the message lists the presets |
96
+ | `motion-no-tag` | a `motion` on an element with no tag of its own — nothing to move | the motion on what it wraps, or a `subType` on it |
95
97
  | `no-pages` | a space with no pages | `pages: [{ id: 'home', name: 'Home', slug: '', body: [] }]` |
96
98
  | `notifications-shape` | `notifications` with a field it does not have, or a value that is not one CSS value | the fields it lists; a colour or a length, like 'var(--card)' or '12px' |
97
99
  | `outside-ancestor` | an element that reads the state of an element it is not inside | nest it in the element the message names |
@@ -172,9 +174,11 @@ The space renders, and renders something you probably did not mean. Fix every on
172
174
  | `image-without-alt` | an image that is not `decorative` and has no `alt` | say what it shows, or `decorative: true` |
173
175
  | `label-ignored` | a `label` on a container whose tag is named by what it holds (`li`, a heading) | the words inside, or a landmark tag (`nav`, `section`…) |
174
176
  | `list-item-key-missing` | a list's `itemKey` that some of its items lack, or two of them share — the rows fall back to `id`, then position | a field every item has, once each |
177
+ | `list-row-not-li` | a row of a list with `items` that is not an `<li>` — that list is a `<ul>` (or `<ol>`), so the row is a box inside a list, no item to a screen reader | `container({ subType: 'li' })` — or the component's root one, or a wrapper for a link or a button |
175
178
  | `overlay-never-opened` | a modal or a dialog that starts hidden and that no step opens | a flow with `openModal('id')` / `openDialog('id')` |
176
179
  | `overlay-starts-open` | a modal or a dialog open when the page loads | `visible: false`, opened by `openModal` |
177
180
  | `painted-state-without-keep-state` | `paintedState` without `keepState` — nothing is kept for the server to draw with | `settings.keepState: true`, or remove `paintedState` |
181
+ | `plugin-attribute-reserved` | a plugin attribute named as one of the element’s own fields — a factory never hands it to the plugin | rename it in the plugin (`variant` → `kind`) |
178
182
  | `provider-without-source` | an `apiContainer` that asks nothing | a `query` (or `action`, `connector`, `resource`) |
179
183
  | `route-param-undeclared` | `navigation.routeParams.x` read on a page whose slug has no `:x` — always empty | add `:x` to the slug, or read `navigation.queryParams.x` |
180
184
  | `server-data-without-rsc` | a `runtime: 'server'` provider with a `connector` or `action` in a space that does not turn server data on | `rsc: { enabled: true }` on the space |
@@ -189,6 +193,7 @@ The space renders, and renders something you probably did not mean. Fix every on
189
193
  | `unknown-global-callback` | a global callback no built-in source declares — it runs only if something registers it | the built-in it suggests, or make sure a plugin or module of the space registers it |
190
194
  | `unknown-utility` | a utility that is not one of the built-in ones | one of the built-in utilities |
191
195
  | `unknown-variable` | a `var(--x)` nothing in the space declares — the property it is in is dropped | declare it under `variables`, fix the name, or give it a fallback: `var(--x, …)` |
196
+ | `unknown-variant` | a variant no class of the element and no style of its type declares — nothing applies | declare it (`styles(name, { variants: { … } })`), or name one that is |
192
197
 
193
198
  ## Suggested
194
199
 
@@ -19,6 +19,9 @@
19
19
  Only `opacity` and `transform` (`translate`, `scale`, `rotate`) animate off the main thread: they stay smooth while
20
20
  the page hydrates and on a slow phone. Everything else repaints, or lays the page out again, on every frame.
21
21
 
22
+ - **A preset first:** `motion: { enter: 'fade-up', on: 'view' }` on any element, `stagger: 60` for children one by one,
23
+ `loop: 'float'` — played by the SDK, cheap and stilled for reduced motion by construction (motion.md lists them).
24
+
22
25
  - **Slide, grow, fade** with `transform` and `opacity` — never `left`, `top`, `width`, `height` or `margin`. Something
23
26
  that travels across a box is `transform: translate(%)` on an element as large as the box.
24
27
  - **No animated blur:** no `filter: blur()` in an entrance or a loop, no `backdrop-filter` over moving content. A soft
@@ -56,7 +56,8 @@ pages: [{ name: 'Shop', slug: 'shop', body: [
56
56
  a `json` prop `item`, read as `{{ props.item.name }}`.
57
57
  - **Slots** are elements of the component's tree that an instance fills. `children: [ … ]` fills a component with one
58
58
  slot; `children: { '<slot>': [ … ] }` names the slot for each. What fills a slot is the instance's, not the
59
- component's: it is authored on the page and sees the page's sources.
59
+ component's: it is authored on the page and sees the page's sources. A prop's value is read as a template on the
60
+ instance, so words that show `{{ … }}` as text (docs, a tutorial) go in a slot — a `markdown` child — not in a prop.
60
61
  - **Closed.** Inside, nothing but `props` and the globals (`state`, `auth`, `navigation`, `theme`, `variables`,
61
62
  `computed`). A binding inside a component onto a provider of the page is refused — "nothing in this component answers
62
63
  to …" — because the component would render differently wherever it was placed. Put the provider inside the component,
@@ -0,0 +1,22 @@
1
+ # Drawing and animating in a plugin
2
+
3
+ A plugin that draws on a canvas — a WebGL hero, a field of particles — takes the canvas from `useCanvas2d`, `useWebGL`
4
+ or `useWebGL2`, and writes only `setup` (once per context) and `draw` (each frame, in CSS pixels):
5
+
6
+ ```tsx
7
+ import { createShaderProgram, RootElement, useWebGL } from '@plitzi/plitzi-sdk';
8
+
9
+ const { ref, ready, error } = useWebGL({
10
+ setup: gl => ({ program: createShaderProgram(gl, { vertex: VERTEX, fragment: FRAGMENT }) }),
11
+ draw: (gl, { time, state }) => { gl.useProgram(state.program); /* uniforms, drawArrays */ }
12
+ });
13
+ return <RootElement className={className}>{!ready && <img src={still} alt="" />}<canvas ref={ref} /></RootElement>;
14
+ ```
15
+
16
+ It sizes the canvas to the device (at most 2× — `maxPixelRatio`), follows its size, and animates only while somebody
17
+ can see it move: on a live page (in the builder it draws one still frame), for a visitor who did not ask for less
18
+ motion, with the tab in front and the canvas on screen; `paused` holds it (bind it to a hover). A shader that does not
19
+ compile — GLSL ES 1.0 wants `196.0`, not `196` — throws a `ShaderError` with the driver's log, printed as
20
+ `[plugin <type> "<id>"] fragment shader failed: …` (`plitzi check` lists it under the console) and `error` says it;
21
+ show the still image meanwhile, as above. `useAnimationFrame(onFrame, { target })` is the same loop for motion that
22
+ is not a canvas.
@@ -66,8 +66,8 @@ says `content: ''` (`default-content-beside-children` warns otherwise). Its acce
66
66
  keeps its own value and fires `onChange` with `{ value, name }` on every change — a search box or a select that
67
67
  filters a screen needs no form. Bind `defaultValue` to the state it writes and a reset of that state reaches it.
68
68
 
69
- **A `list` is a `<ul>`.** The browser indents it and puts bullets on it; a list of cards needs
70
- `{ margin: '0px', padding: '0px', 'list-style-type': 'none' }` in its class.
69
+ **A `list` is a `<ul>`, its rows `<li>`s straight inside** — `listItem({ … })`, or `list-row-not-li` warns. It is
70
+ indented with space below it: `{ margin: '0px', padding: '0px' }` on its class takes that off.
71
71
 
72
72
  **A provider has no box unless you give it a tag.** An `apiContainer` renders no element of its own by default, so its
73
73
  children sit in the parent's layout and a `class` on it styles nothing (`STYLE_WITHOUT_TAG`). Put the layout on the