@plitzi/sdk-authoring 0.38.6 → 0.38.8
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 +381 -0
- package/dist/index-src.js +26687 -0
- package/dist/index.d.ts +1174 -367
- package/dist/index.js +2 -24803
- package/dist/node.d.ts +2820 -0
- package/dist/node.js +610 -13
- package/package.json +7 -7
- package/skills/plitzi-authoring/CHEATSHEET.md +2 -2
- package/skills/plitzi-authoring/SKILL.md +34 -148
- package/skills/plitzi-authoring/recipes/plugin.ts +1 -1
- package/skills/plitzi-authoring/reference/accessibility.md +3 -4
- package/skills/plitzi-authoring/reference/auth.md +75 -0
- package/skills/plitzi-authoring/reference/authoring-errors.md +19 -4
- package/skills/plitzi-authoring/reference/colours-and-motion.md +3 -2
- package/skills/plitzi-authoring/reference/drawing.md +1 -1
- package/skills/plitzi-authoring/reference/efficiency.md +5 -2
- package/skills/plitzi-authoring/reference/elements-and-styles.md +23 -23
- package/skills/plitzi-authoring/reference/flows.md +15 -8
- package/skills/plitzi-authoring/reference/index.md +33 -0
- package/skills/plitzi-authoring/reference/layouts.md +15 -18
- package/skills/plitzi-authoring/reference/plugins.md +3 -3
- package/skills/plitzi-authoring/reference/recipes.md +25 -0
- package/skills/plitzi-authoring/reference/review-checklist.md +2 -1
- package/skills/plitzi-authoring/reference/rules.md +61 -0
- package/skills/plitzi-authoring/reference/snippets-and-export.md +2 -2
- package/skills/plitzi-authoring/reference/structure.md +4 -3
- package/skills/plitzi-authoring/reference/testing.md +1 -1
- package/skills/plitzi-authoring/reference/validation.md +1 -1
- package/dist/index-compactSvg.js +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-authoring",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.8",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/index.js",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@microsoft/api-extractor": "^7.59.3",
|
|
56
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
57
|
-
"@plitzi/sdk-elements": "0.38.
|
|
58
|
-
"@plitzi/sdk-interactions": "0.38.
|
|
59
|
-
"@plitzi/sdk-schema": "0.38.
|
|
60
|
-
"@plitzi/sdk-shared": "0.38.
|
|
61
|
-
"@plitzi/sdk-style": "0.38.
|
|
56
|
+
"@plitzi/plitzi-ui": "^1.6.32",
|
|
57
|
+
"@plitzi/sdk-elements": "0.38.8",
|
|
58
|
+
"@plitzi/sdk-interactions": "0.38.8",
|
|
59
|
+
"@plitzi/sdk-schema": "0.38.8",
|
|
60
|
+
"@plitzi/sdk-shared": "0.38.8",
|
|
61
|
+
"@plitzi/sdk-style": "0.38.8",
|
|
62
62
|
"@types/react": "^19.3.0",
|
|
63
63
|
"eslint": "^9.39.5",
|
|
64
64
|
"prettier": "^3.9.9",
|
|
@@ -13,7 +13,7 @@ const space: SpaceSpec = {
|
|
|
13
13
|
classes: { card }, // styles() declarations, by their own name; styles('card', tw('p-4 rounded-xl'))
|
|
14
14
|
computed: { total: '{{ … }}' }, // values read anywhere as computed.total
|
|
15
15
|
flags: { beta: { description, value: false, rules: [] } },
|
|
16
|
-
|
|
16
|
+
keyframes: { blink: { '50%': { opacity: 0 } } }, // a class plays them: animation: 'blink 1s infinite'
|
|
17
17
|
layouts: [{ id: 'shell', body }], // chrome shared by pages
|
|
18
18
|
components: [{ id, props, slots, root }], // a block placed many times with different content
|
|
19
19
|
pages: [{ id, name, slug: '', layout: { id: 'shell', slot: 'main' }, body: [] }] // slot: where the body goes
|
|
@@ -81,7 +81,7 @@ bind: { alt: 'p.data.title' } // other attribut
|
|
|
81
81
|
bind: [bindTemplate('content', 'p.data.items', '{{ source|length }} items')]
|
|
82
82
|
bind: [bindTemplate('items', 'p.data.rows', '{{ source|filter(r => r.on) }}', { returns: 'value' })]
|
|
83
83
|
bind: [variantFrom(pill, 'rows.item.status')] // a variant chosen by the data
|
|
84
|
-
|
|
84
|
+
current: 'section' // a link lit on its page and the pages under it
|
|
85
85
|
bind: [activeWhen(dot, '{{ list_dots.index == state.slide }}')] // a variant while a condition holds
|
|
86
86
|
visible: 'p.data.signedIn' // shown while true; '!p.data.signedIn' inverts
|
|
87
87
|
visible: { source: 'p.data.rows', template: '{{ source is defined and source|length == 0 }}' }
|
|
@@ -9,173 +9,59 @@ description: >-
|
|
|
9
9
|
|
|
10
10
|
# Authoring Plitzi spaces
|
|
11
11
|
|
|
12
|
-
A space is two JSON documents
|
|
13
|
-
|
|
14
|
-
declaration, and refuses a declaration that would not render.
|
|
12
|
+
A space is two JSON documents full of cross-referenced ids — **never write them by hand**. `@plitzi/sdk-authoring`
|
|
13
|
+
derives them from a small declaration, and refuses one that would not render.
|
|
15
14
|
|
|
16
15
|
```ts
|
|
17
|
-
import {
|
|
16
|
+
import { heading, styles, text } from '@plitzi/sdk-authoring';
|
|
18
17
|
|
|
19
|
-
const page = styles('page', { display: 'flex', 'flex-direction': 'column',
|
|
18
|
+
const page = styles('page', { display: 'flex', 'flex-direction': 'column', gap: '16px' });
|
|
20
19
|
|
|
21
20
|
export const space = {
|
|
22
21
|
name: 'My space',
|
|
23
22
|
permanentUrl: 'my-space',
|
|
24
23
|
pages: [{ name: 'Home', slug: '', class: page, body: [heading('Hello', { subType: 'h1' }), text('A paragraph.')] }]
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
const { schema, style, warnings } = authorSpace(space);
|
|
28
25
|
```
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
and open a reference below only when the task names its subject. What an element takes, a step's params, what a
|
|
32
|
-
trigger hands its flow: `npx @plitzi/cli explain <name>` answers in a few lines (over MCP, `plitzi://explain/<name>`).
|
|
33
|
-
The published `.d.ts` documents the rest — search it by name, never read it whole.
|
|
34
|
-
|
|
35
|
-
This skill writes a space that lives in code. One that lives on Plitzi — edited in the builder, published from there —
|
|
36
|
-
is edited through the Plitzi MCP server instead, never both on one space; `plitzi create --from <space>` turns the
|
|
37
|
-
second into the first. If the MCP asks for a sign-in nobody can give, a project in code needs no account.
|
|
27
|
+
A space on Plitzi — edited in the builder — is edited through the Plitzi MCP server instead, never both on one space.
|
|
38
28
|
|
|
39
29
|
## How to work
|
|
40
30
|
|
|
41
|
-
1. **
|
|
42
|
-
|
|
43
|
-
2. **
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
3. **Read every warning, then every suggestion.** A warning names something written that will not do what it says —
|
|
49
|
-
zero warnings is the bar. A suggestion (`[suggest]`) names a shorter way to the same page — a layout, a component,
|
|
50
|
-
a `list`, a button's own `content` — or what nothing uses. Take them, the ones that save the most first
|
|
51
|
-
([efficiency](reference/efficiency.md)). Then `npm run lint:space`: how the source is written — long files, rows of
|
|
52
|
-
data inline, colours that are not tokens — at file:line. Leave both clean.
|
|
53
|
-
4. **Look at it.** `npm run check -- /about --width 1440,390` says in text whether the page is whole — every element on
|
|
54
|
-
screen, nothing overflowing, a clean console; `npm run shot -- /about --width 390 --scheme dark` is the picture
|
|
55
|
-
(`--frames 4` shows what moves); `npm run visual` runs the checks. Look at desktop, tablet and mobile, light and dark, and the page while its data is still loading.
|
|
56
|
-
5. **Go through the [review checklist](reference/review-checklist.md) before saying it is done.** It is the feedback a
|
|
57
|
-
reviewer gives on every change, written down so you do not need to hear it.
|
|
31
|
+
1. **Find, then write.** `npx plitzi element where <id|class|words>` answers the file, the line and the call: edit there, and
|
|
32
|
+
extend what the space already has. People move files — never keep a note of where something is.
|
|
33
|
+
2. **Author.** `npm run author`. A refusal says what to write instead: do exactly that. Every problem comes at once —
|
|
34
|
+
fix them all before running again. Zero warnings; take the suggestions, the biggest first.
|
|
35
|
+
3. **Look.** `npm run check -- /path --width 1440,390` says in text whether the page is whole; `npm run shot` only
|
|
36
|
+
when the text is not enough.
|
|
37
|
+
4. **Before saying done:** `npm run lint:space` clean, and the [review checklist](reference/review-checklist.md).
|
|
58
38
|
|
|
59
|
-
|
|
39
|
+
What a name means — an element, a step, a trigger, a code, any export (`pageFamily`, `SpaceSpec`): `npx plitzi explain
|
|
40
|
+
<name>`, in a few lines. Never read the `.d.ts`.
|
|
60
41
|
|
|
61
|
-
|
|
62
|
-
namespace for the whole space — layouts and every page share it — so a helper that runs more than once builds inside
|
|
63
|
-
`scope('promos', ref => …)`: every id in it is prefixed (`promos-panel`), and `ref('slides')` names one in full. An `id` is the element's name in the
|
|
64
|
-
space (`data-plitzi-el` in the page); the DOM id a URL's `#fragment` lands on is its `anchor`.
|
|
65
|
-
2. **Share with classes, layouts and components, never with copies.** A look used twice is a `styles()` class.
|
|
66
|
-
Chrome shown on several pages — a header, a sidebar, a footer — is a **layout** the pages name, written once. A block
|
|
67
|
-
placed many times with different content — a product card, a testimonial — is a **component** placed with
|
|
68
|
-
`component(id, { props })`. A menu, a card grid, a list of steps is DATA, never a block pasted per item: a short
|
|
69
|
-
menu mapped in code is fine; rows — cards, dishes, tiles — are one `list` (`items: [ … ]`) whose row is written
|
|
70
|
-
once. A link or a button says its words as
|
|
71
|
-
its own `content`, not through a `text` inside it. Pages of one shape are one `pageFamily` over data. See
|
|
72
|
-
[layouts](reference/layouts.md), [components](reference/components.md), [structure](reference/structure.md) and
|
|
73
|
-
[efficiency](reference/efficiency.md).
|
|
74
|
-
3. **One element, one base selector.** An element takes a shared `class` OR its own `css`, never both — authoring
|
|
75
|
-
refuses the pair. "This class plus one thing" is the class with rules on top, last in the list:
|
|
76
|
-
`class: [cover, { opacity: '0.25' }]` (needs the element's `id`; it becomes the class `<id>--own`). A look that
|
|
77
|
-
never changes is its own class.
|
|
78
|
-
4. **Visible by default; decide which way the logic flips.** An element is on screen unless something hides it. When
|
|
79
|
-
the logic REVEALS it (hidden → shown: an empty state, a "get started" card, an admin-only panel), it starts hidden —
|
|
80
|
-
`visible: 'source'`, or `visible: false` plus a binding for a computed condition — so it never flashes while data
|
|
81
|
-
loads (`condition-starts-visible` warns). When a flag HIDES it (shown → hidden: a sidebar label until the sidebar
|
|
82
|
-
is folded), it keeps the default and an absent flag must leave it shown. See
|
|
83
|
-
[data and visibility](reference/data-and-visibility.md). What a PERSON switches on — a feature in beta, a rollout —
|
|
84
|
-
is a feature flag, not a visibility: gated off, it is not rendered at all. See [feature flags](reference/feature-flags.md).
|
|
85
|
-
5. **Know where a template is evaluated.** A binding's template (`bindTemplate`) and a step's params evaluate full
|
|
86
|
-
Twig. An ATTRIBUTE resolves a name with filters (`{{ list_games.item.slug }}`, `{{ post.slug|url_encode }}`) against
|
|
87
|
-
the sources around the element; a condition there is used as written. Inside any template a source is spelled in
|
|
88
|
-
full — `apiContainer_stats`, `list_rows` — and a query param is `navigation.queryParams.x`. A template that feeds a
|
|
89
|
-
list its `items` hands over its value (`returns: 'value'`). `authorSpace` refuses a template it cannot read and a
|
|
90
|
-
name nothing answers to. See [templates](reference/templates.md).
|
|
91
|
-
6. **Tokens, not colours.** Every colour is a variable of the space with a `light` and a `dark` value; both themes are
|
|
92
|
-
checked from the first commit.
|
|
93
|
-
7. **Times in UTC, and say so.** Format with an explicit zone (`|date('j M · H:i', 'UTC')`) and print "UTC" beside it:
|
|
94
|
-
a page rendered on a server and hydrated in a browser in another zone must agree on the hour.
|
|
95
|
-
8. **Breakpoints are ranges.** `tablet` (48–64rem) and `mobile` (up to 48rem) each inherit only from `desktop`; a rule
|
|
96
|
-
meant for both is written under `compact`.
|
|
97
|
-
9. **Never invent data.** Numbers, names and states on screen come from a source. A panel with nothing true to say is
|
|
98
|
-
an empty state, not a placeholder figure. With no backend, the data is JSON read by an `apiContainer`: a server
|
|
99
|
-
project's `src/data/*.json`, read on the server and never served; with no server, `public/data/*.json`, which is
|
|
100
|
-
public — see [data and visibility](reference/data-and-visibility.md).
|
|
101
|
-
10. **Never hand-write** `flat`, derived ids, `styleSelectors`, `beforeNode`/`afterNode`/`flowId`, or a
|
|
102
|
-
`styleVariant` binding's key — use the factories, `variantFrom` and `activeOn`.
|
|
103
|
-
11. **A switch is named for how it leaves its default.** `toggleState` turns a key nobody has set yet ON, so a key
|
|
104
|
-
named for the default (`showPlates`, on by default) takes a first click to do nothing: name it `platesOff`, and read
|
|
105
|
-
every switch through `computed` (`plates: '{{ state.platesOff ? false : true }}'`) so its default shows before
|
|
106
|
-
anybody touches it.
|
|
107
|
-
12. **Hand plugins over as their declarations**: `authorSpace(space, { plugins: [declaration] })` holds a plugin —
|
|
108
|
-
its own type, or a `custom({ renderType })` host — to the events, actions and attributes it declares. See
|
|
109
|
-
[plugins](reference/plugins.md).
|
|
110
|
-
13. **Usable without sight.** Screen readers and browser agents (Claude in Chrome) find a page's controls in its
|
|
111
|
-
accessibility tree: every button and link has words (an icon-only button a `title`), every field a `label`
|
|
112
|
-
(`hideLabel: true` hides it and keeps the name), every image an `alt` or `decorative: true`. Clicks go on a
|
|
113
|
-
`button` — it holds children, so a whole card can be one — or a `link`, never on a container. See
|
|
114
|
-
[accessibility](reference/accessibility.md).
|
|
115
|
-
14. **Motion that stays smooth.** Animate `opacity` and `transform` only; no animated blur, shadow or size. See
|
|
116
|
-
[motion](reference/colours-and-motion.md).
|
|
42
|
+
## Five rules authoring cannot check for you
|
|
117
43
|
|
|
118
|
-
|
|
44
|
+
1. **Name what is referred to.** An `id` for every element a binding, a flow or a test addresses; ids are one namespace,
|
|
45
|
+
so a helper that runs twice builds inside `scope('promos', ref => …)`.
|
|
46
|
+
2. **Share, never copy.** A look used twice is a class; chrome on several pages a layout; a block placed again with
|
|
47
|
+
other content a component; rows of data one `list`.
|
|
48
|
+
3. **What is revealed starts hidden** (`visible: 'source'`), so it never flashes while its data loads.
|
|
49
|
+
4. **Know where a template runs.** A binding and a step's params are full Twig; an attribute resolves a name with
|
|
50
|
+
filters. A source is spelled in full: `apiContainer_stats`.
|
|
51
|
+
5. **Tokens, not colours** — a variable with a `light` and a `dark` value.
|
|
119
52
|
|
|
120
|
-
|
|
53
|
+
The rest, and why: [rules](reference/rules.md).
|
|
121
54
|
|
|
122
|
-
|
|
123
|
-
| --- | --- |
|
|
124
|
-
| Show data with no backend: a JSON file, a card per row, a count, an empty state, a computed value | [recipes/show-data.ts](recipes/show-data.ts) |
|
|
125
|
-
| Data typed by a sample of it: completed and checked paths, typed rows | [recipes/typed-data.ts](recipes/typed-data.ts) |
|
|
126
|
-
| Data read by the page server (`--mode server`) | [recipes/server-data.ts](recipes/server-data.ts) |
|
|
127
|
-
| An accordion, one answer open at a time | [recipes/accordion.ts](recipes/accordion.ts) |
|
|
128
|
-
| Filter and sort a list from a select | [recipes/filter-a-list.ts](recipes/filter-a-list.ts) |
|
|
129
|
-
| A page per record (`/products/:slug`), and "not found" | [recipes/detail-page.ts](recipes/detail-page.ts) |
|
|
130
|
-
| Link to a section of a page (`/#plans`) | [recipes/link-to-a-section.ts](recipes/link-to-a-section.ts) |
|
|
131
|
-
| A carousel: slides with arrows, dots and autoplay; a marquee; a row that swipes | [recipes/carousel.ts](recipes/carousel.ts) |
|
|
132
|
-
| Do something every few seconds — a ticker, a poll, a slideshow by hand | [recipes/every-few-seconds.ts](recipes/every-few-seconds.ts) |
|
|
133
|
-
| A marquee that scrolls for ever and stops under the pointer | [recipes/marquee.ts](recipes/marquee.ts) |
|
|
134
|
-
| A row that scrolls sideways, with arrows that hide at its ends | [recipes/scroll-a-row.ts](recipes/scroll-a-row.ts) |
|
|
135
|
-
| A link built from a row: WhatsApp with the product's name, `mailto:` | [recipes/link-with-data.ts](recipes/link-with-data.ts) |
|
|
136
|
-
| React to a click or a submit; a modal; a switch | [recipes/forms-and-modals.ts](recipes/forms-and-modals.ts) |
|
|
137
|
-
| A feature behind a flag | [recipes/feature-flag.ts](recipes/feature-flag.ts) |
|
|
138
|
-
| An element of your own (a plugin), checked | [recipes/plugin.ts](recipes/plugin.ts) |
|
|
139
|
-
| Controls a screen reader and a browser agent can use | [recipes/usable-without-sight.ts](recipes/usable-without-sight.ts) |
|
|
140
|
-
| Tokens, a shared class, "the class plus one thing", tablet and phone at once | [recipes/style-a-page.ts](recipes/style-a-page.ts) |
|
|
141
|
-
| A design in Tailwind classes, kept as classes the builder edits | [recipes/from-tailwind.ts](recipes/from-tailwind.ts) |
|
|
142
|
-
| A page from elsewhere in a frame (`embed`: a map, a player) and a drawing of your own (`svg`) | [recipes/embed-and-svg.ts](recipes/embed-and-svg.ts) |
|
|
55
|
+
## What to read
|
|
143
56
|
|
|
144
|
-
|
|
57
|
+
Start with [the cheatsheet](CHEATSHEET.md), then only what the task names:
|
|
145
58
|
|
|
146
|
-
|
|
|
59
|
+
| The task | Read |
|
|
147
60
|
| --- | --- |
|
|
148
|
-
| [elements-and-styles
|
|
149
|
-
| [
|
|
150
|
-
|
|
|
151
|
-
| [
|
|
152
|
-
|
|
|
153
|
-
| [
|
|
154
|
-
| [
|
|
155
|
-
| [kept-state.md](reference/kept-state.md) | State that outlives a reload: `keepState`, transient and painted keys |
|
|
156
|
-
| [feature-flags.md](reference/feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships |
|
|
157
|
-
| [lists.md](reference/lists.md) | Rendering rows, filtering and sorting them, a detail page for one record, carousels |
|
|
158
|
-
| [typed-sources.md](reference/typed-sources.md) | Data typed by a sample of it: `source()`, typed rows, `twig` for templates |
|
|
159
|
-
| [validation.md](reference/validation.md) | How `authorSpace` checks, the loop that wastes no attempts, and what it cannot see |
|
|
160
|
-
| [authoring-errors.md](reference/authoring-errors.md) | What `authorSpace` refuses or warns about, and what to write instead |
|
|
161
|
-
| [templates.md](reference/templates.md) | Any `{{ … }}` or `{% … %}`: where it runs, naming sources, filters, tests, dates |
|
|
162
|
-
| [flows.md](reference/flows.md) | Clicks, submits, page loads, every few seconds, server actions, modals, state |
|
|
163
|
-
| [realtime.md](reference/realtime.md) | Pages that see each other: channels, presence, cursors, a shared board, who may hear a topic |
|
|
164
|
-
| [plugins.md](reference/plugins.md) | A component of your own: props, binding them, writing state, channels, registering, behaving in the builder |
|
|
165
|
-
| [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 |
|
|
166
|
-
| [structure.md](reference/structure.md) | A space bigger than one screen: files, helpers, naming, keeping it short |
|
|
167
|
-
| [testing.md](reference/testing.md) | Any test: `inspectPage` (one call, every problem), handles, fixtures, catching a flash from the first frame, shortcuts, counting renders |
|
|
168
|
-
| [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 |
|
|
169
|
-
| [snippets-and-export.md](reference/snippets-and-export.md) | Publishing a snippet; turning an exported JSON — or a server action — into code |
|
|
170
|
-
| [accessibility.md](reference/accessibility.md) | Icon buttons, fields, images, clickable cards, toggles, headings, landmarks, a canvas — anything a screen reader or a browser agent has to use |
|
|
171
|
-
| [review-checklist.md](reference/review-checklist.md) | Before you say it is done |
|
|
172
|
-
|
|
173
|
-
**What to read for a kind of task** — the cheatsheet, then only these:
|
|
174
|
-
|
|
175
|
-
- A site — landing, catalogue, blog: elements-and-styles, layouts, components, lists.
|
|
176
|
-
- An app with state and actions: data-and-visibility, templates, flows — realtime when pages see each other.
|
|
177
|
-
- A component of your own: plugins.
|
|
178
|
-
- A refusal or a warning: search authoring-errors.md for its code — never read it whole.
|
|
179
|
-
- Tests: testing.
|
|
180
|
-
|
|
181
|
-
Nothing else needs reading up front.
|
|
61
|
+
| 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) |
|
|
62
|
+
| An app with state and actions | [data-and-visibility](reference/data-and-visibility.md), [templates](reference/templates.md), [flows](reference/flows.md) |
|
|
63
|
+
| A component of your own | [plugins](reference/plugins.md) |
|
|
64
|
+
| A whole working file to copy | [recipes](reference/recipes.md) |
|
|
65
|
+
| A refusal or a warning | `npx plitzi explain <code>` |
|
|
66
|
+
| Tests | [testing](reference/testing.md) |
|
|
67
|
+
| Anything else | [the index](reference/index.md): every reference, and when |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An element of your own (a plugin): authored from its declaration — the one `plitzi add
|
|
2
|
+
* An element of your own (a plugin): authored from its declaration — the one `plitzi plugin add` writes — so a flow on
|
|
3
3
|
* its events, a step to its actions and its attributes are all checked. Hand the declaration to `authorSpace` too.
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
@@ -27,8 +27,8 @@ formControl({ name: 'q', label: 'Search the docs', hideLabel: true, placeholder:
|
|
|
27
27
|
formControl({ name: 'tint', subType: 'color', label: 'Highlight colour', hideLabel: true })
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
A `placeholder` names only a field you type into, and only until something is typed. A swatch, a date, a select
|
|
31
|
-
checkbox always needs its `label`.
|
|
30
|
+
A `placeholder` names only a field you type into, and only until something is typed. A swatch, a date, a select, a
|
|
31
|
+
checkbox or a switch always needs its `label`.
|
|
32
32
|
|
|
33
33
|
## Pictures say what they show, or that they only decorate
|
|
34
34
|
|
|
@@ -111,5 +111,4 @@ can't click something that only appears on focus.
|
|
|
111
111
|
- `authorSpace` warnings: zero, as always.
|
|
112
112
|
- In a test, `page.getByRole('button', { name: 'Close' })` fails when the name is missing.
|
|
113
113
|
`expect(locator).toMatchAriaSnapshot(…)` pins the whole outline.
|
|
114
|
-
- Through MCP, `
|
|
115
|
-
no name.
|
|
114
|
+
- Through MCP, `plitzi_look` returns the page's tree (its default view) and lists everything that has no name.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Signing people in
|
|
2
|
+
|
|
3
|
+
## Where they sign in
|
|
4
|
+
|
|
5
|
+
A page signs in with one provider: the space's `settings.userProvider`, or — when it declares none — the one the server
|
|
6
|
+
that rendered it serves.
|
|
7
|
+
|
|
8
|
+
| The space runs… | Declare |
|
|
9
|
+
| --- | --- |
|
|
10
|
+
| on the Plitzi platform, visitors signing in with their Plitzi account | `userProvider: 'server'` — and `visitorRoles` |
|
|
11
|
+
| on a self-hosted server with `auth` (`createServer({ auth })`; in a project, `src/config/serverOptions.ts`) | nothing: the server tells its pages where they sign in |
|
|
12
|
+
| against an API of your own over HTTP+JSON | `userProvider: 'basic'`, `loginUrl`, `userUrl`, `refreshUrl`, `logoutUrl`, and `sessionHintCookie` when it writes one |
|
|
13
|
+
|
|
14
|
+
What the space declares wins, setting by setting; a space naming another provider than the server's ignores the
|
|
15
|
+
server's altogether. A page with no provider at all offers no auth actions, and an `authLogin` there says why in the
|
|
16
|
+
console (`[plitzi] auth.login: …`) — read it before suspecting the form.
|
|
17
|
+
|
|
18
|
+
On the platform, `userProvider: 'server'` signs in by leaving the page: a `link` with `mode: 'external'` to
|
|
19
|
+
`/auth/sign-in?return=/` sends the visitor to sign in and back, signed in on the space's own host.
|
|
20
|
+
|
|
21
|
+
## The steps
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
form({
|
|
25
|
+
id: 'signIn',
|
|
26
|
+
managedByInteractions: true,
|
|
27
|
+
flows: [
|
|
28
|
+
[
|
|
29
|
+
named('sent', onSubmit()),
|
|
30
|
+
named('signedIn', authLogin({ username: '{{ sent.values.username }}', password: '{{ sent.values.password }}' })),
|
|
31
|
+
when({ field: 'signedIn.ok', operator: '=', value: true }, navigate({ urlType: 'page', url: 'dashboard' })),
|
|
32
|
+
when(
|
|
33
|
+
{ field: 'signedIn.reason', operator: '=', value: 'unverified' },
|
|
34
|
+
addNotification({ content: 'Confirm your address first — the link is in your inbox', appearance: 'warning' })
|
|
35
|
+
)
|
|
36
|
+
]
|
|
37
|
+
],
|
|
38
|
+
children: [
|
|
39
|
+
formControl({ name: 'username', label: 'Username' }),
|
|
40
|
+
formControl({ name: 'password', label: 'Password', subType: 'password' }),
|
|
41
|
+
button({ content: 'Sign in', subType: 'submit' })
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `authLogin(params)` — `{ username, password }`; `{ mode: 'token', token }` adopts a credential obtained elsewhere,
|
|
47
|
+
checked against `userUrl`; `{ mode: 'mfa', mfaToken, code }` completes a sign-in that owed a second factor.
|
|
48
|
+
- What it answers: `ok`; when not, `reason` (`unverified`, `inactive`, `network`, `missing`…) and, for `reason: 'mfa'`,
|
|
49
|
+
`mfaToken` — the challenge `mode: 'mfa'` completes. Test it on `<step>.ok` with `when`, never `whenSucceeded` /
|
|
50
|
+
`whenFailed`, which are a server action's ([flows](flows.md)).
|
|
51
|
+
- `authLogout()` ends the session; `authRefreshDetails()` reloads who is signed in.
|
|
52
|
+
|
|
53
|
+
## Who is signed in
|
|
54
|
+
|
|
55
|
+
The `auth` source: `{{ auth.isAuthenticated }}`, `{{ auth.status }}` (`init` … `authenticated` | `guest`, while it is
|
|
56
|
+
being found out), `{{ auth.details.username }}` — `details` carries `id`, `username`, `email`, `verified`, `roles` and
|
|
57
|
+
`permissions`. Show a signed-in part with `visible: 'auth.isAuthenticated'`; never bind a token into the page.
|
|
58
|
+
|
|
59
|
+
## Pages for one kind of visitor
|
|
60
|
+
|
|
61
|
+
A page's `accessLevel`: `'authenticated'` (signed in), `'public'` (signed OUT only — the sign-in page), or nothing
|
|
62
|
+
(everybody). A lone `public` page vanishes the moment anyone signs in, so leave it out unless the page has a signed-in
|
|
63
|
+
twin on the same slug. `unauthorizedRedirect` names where a visitor the page is not for goes — a page's id or slug
|
|
64
|
+
(`''` is the home page), or a URL; without it they are answered 403.
|
|
65
|
+
|
|
66
|
+
## What a visitor may do
|
|
67
|
+
|
|
68
|
+
`settings.visitorRoles` — `{ author: ['postPublish'] }` — is what each role gives. A visitor holds exactly the
|
|
69
|
+
permissions of their roles in this space; who holds a role is given by email in the builder, never written here. A page
|
|
70
|
+
reads them in `auth.details.permissions`, a plugin asks `can('postPublish')` of the auth context.
|
|
71
|
+
|
|
72
|
+
A server action's trigger says who may run it: `access: { mode: 'public' }`, `{ mode: 'session' }` (signed in) or
|
|
73
|
+
`{ mode: 'role', permissions: ['postPublish'] }`. The page hiding a button is not the check — the trigger is. Inside,
|
|
74
|
+
its steps read who asked as `{{ user.id }}`, and a function as `ctx.user` (`id`, `username`, `email`, `verified`,
|
|
75
|
+
`roles`, `permissions`) — never their session.
|
|
@@ -27,7 +27,7 @@ The space is not written until these are fixed.
|
|
|
27
27
|
| `action-without-entry` | an action with no way in, so nothing can start it | a `trigger` — `{ type: 'call', access }`, or `render`, `webhook`, `custom`, `schedule` |
|
|
28
28
|
| `action-without-steps` | an action with no steps | the steps it runs |
|
|
29
29
|
| `active-when-constant` | an `activeWhen` condition that reads nothing — always or never true | name what it depends on: `'{{ list_dots.index == state.slide }}'` |
|
|
30
|
-
| `ancestor-not-class` | an ancestor condition keyed by something that is
|
|
30
|
+
| `ancestor-not-class` | an ancestor condition keyed by something that is neither a class name nor `'>'` (the parent) | `[card.name]` for a `styles()` declaration, or `'>'` for the parent whatever it wears |
|
|
31
31
|
| `anchor-duplicate` | one anchor on two elements of the same page (layouts included) | rename all but one |
|
|
32
32
|
| `anchor-invalid` | an `anchor` or a link's `hash` that is not lowercase letters, digits and `-` | `anchor: 'plans'`, `hash: 'plans'` — no `#` |
|
|
33
33
|
| `anchor-missing` | a link whose `hash` no element on the page it goes to carries — it would land at the top | the anchor the message lists, or give the section that `anchor` |
|
|
@@ -59,20 +59,23 @@ The space is not written until these are fixed.
|
|
|
59
59
|
| `computed-not-template` | a computed value that is not a template | `'{{ state.x * 2 }}'` |
|
|
60
60
|
| `computed-reads-element` | a computed value reading an element's source — no element is around the whole space | compute it from the globals and the variables, or bind it on the element |
|
|
61
61
|
| `computed-unknown` | a computed value read before it is declared, or never declared | declare it in `computed`, above the one that reads it |
|
|
62
|
+
| `condition-field-unpublished` | a `when` asking a step of its flow for a key it never publishes — `whenSucceeded` / `whenFailed` on anything but `runServerAction` | a key the step publishes (`explain <step>`): after `authLogin`, `when({ field: 'signedIn.ok', operator: '=', value: true }, …)` |
|
|
62
63
|
| `controls-unknown` | a button's `controls` naming no element of the space | the id of the element it shows and hides: `controls: 'faq-answer'` |
|
|
63
64
|
| `css-property-twice` | one property written twice in a rule set — `paddingTop` beside `'padding-top'` — so one would silently win | keep one |
|
|
64
65
|
| `css-property-unknown` | a CSS property that does not exist | the property it suggests; a custom property starts with `--` |
|
|
65
66
|
| `css-value` | an empty CSS value, or one with `;` or `{}` | one value per property; leave a property out instead of writing it empty |
|
|
67
|
+
| `element-ids-target` | a step refreshing containers by id (`invalidateElements`, `invalidateQueries({ elements })`) naming one the space does not have, or one that is not an `apiContainer` | the id of the `apiContainer` whose data the step changes: `invalidateElements: ['posts']` |
|
|
66
68
|
| `element-load-strategy` | a `loadStrategy` the element does not take | one of the values the message lists |
|
|
67
69
|
| `element-rejected` | an element the schema refused to hold | the problem listed with it |
|
|
68
70
|
| `element-runtime` | a `runtime` the element does not run in | one of the values the message lists |
|
|
69
71
|
| `element-shape` | an element that is not an object with a `type`, `attributes` and a list of `children` | build elements with their factories — `text(…)`, `container(…)` |
|
|
72
|
+
| `element-slot-unknown` | a `slots` key the element type does not have — its class would dress nothing | one of the slots `plitzi explain <type>` lists; the element itself takes `class` |
|
|
70
73
|
| `flag-gate` | an element's or a page's `flag` that is not a flag name | `flag: 'newCheckout'`, or `flag: '!newCheckout'` for "only while off" |
|
|
71
74
|
| `flag-name` | a flag whose name a template cannot read as `flags.x` | letters, digits and `_` |
|
|
72
75
|
| `flag-rule-shape` | a flag rule that is not `{ when, value }`, or whose `value` is not `true` or `false` | `{ when: { … }, value: true }` |
|
|
73
76
|
| `flag-shape` | a flag whose `value` is not `true` or `false` | `{ value: false, rules: [] }` |
|
|
74
77
|
| `flag-undeclared` | a gate on a flag the space does not declare — it reads as off, so the element never (or always) renders | declare it in `flags`, or remove the gate |
|
|
75
|
-
| `flag-unknown` | a template reading a flag the space does not declare | the declared name it suggests, or declare it |
|
|
78
|
+
| `flag-unknown` | a template, a binding or a `when` reading a flag the space does not declare | the declared name it suggests, or declare it |
|
|
76
79
|
| `flow-empty` | a flow with no steps | `[onClick(), setState({ … })]` |
|
|
77
80
|
| `flow-without-trigger` | a flow whose first step is not the event that runs it | `[onClick(), setState(…)]` |
|
|
78
81
|
| `folder-cycle` | a page folder inside itself | a `parent` that leads to the top |
|
|
@@ -83,9 +86,11 @@ The space is not written until these are fixed.
|
|
|
83
86
|
| `from-without-attribute` | `from` on a type with no one attribute that shows its data (a container, a form) | bind the attribute you mean: `bind: { attribute: 'source' }` |
|
|
84
87
|
| `global-callback-module` | a global callback sent to a module other than the one that registers it | the step builder, which knows the module |
|
|
85
88
|
| `global-callback-undeclared` | a global-callback step builder naming an action no source declares | one of the actions it lists |
|
|
89
|
+
| `global-field-unknown` | a binding, a template or a `when` reading a field `navigation`, `auth` or `theme` never has — `auth.authenticated` | the field it suggests: `auth.isAuthenticated`, `auth.details.username`, `navigation.queryParams.next`, `theme.resolved` |
|
|
86
90
|
| `id-invalid` | an id a binding, a template or a test cannot name | a letter first, then letters, digits, `-` and `_`: `'hero-title'` |
|
|
87
91
|
| `id-shadows-global` | an element named like a global data source (`state`, `navigation`, `auth`…) | another id |
|
|
88
92
|
| `id-taken` | two elements with one id — ids are one namespace for the whole space | a name taken by a page or a layout: a name of its own; a helper called twice: `scope('promos', ref => …)`, every id inside prefixed |
|
|
93
|
+
| `keyframes-shape` | keyframes with a name CSS does not accept or the SDK keeps for itself, or a frame that is not an offset | a plain name (`slide-in`), frames keyed `from`, `to` or a percentage (`'50%'`, `'0%, 100%'`) |
|
|
89
94
|
| `layout-slot-unknown` | a layout `slot` that is not an element inside that layout | the id of the element in the shell where the body goes |
|
|
90
95
|
| `layout-undeclared` | a page or a layout inside a layout the space does not declare | the layout's id, or declare it in `layouts` |
|
|
91
96
|
| `list-items-ignored` | a list whose items nothing reads — `source: 'none'` renders its children once | `source: 'controlled'` |
|
|
@@ -96,7 +101,7 @@ The space is not written until these are fixed.
|
|
|
96
101
|
| `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 |
|
|
97
102
|
| `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 |
|
|
98
103
|
| `no-pages` | a space with no pages | `pages: [{ id: 'home', name: 'Home', slug: '', body: [] }]` |
|
|
99
|
-
| `notifications-shape` | `notifications` with a field it does not have, or a value that is not one CSS value | the
|
|
104
|
+
| `notifications-shape` | `notifications` with a field it does not have, or a value that is not one CSS value | the field it suggests, or one it lists; one CSS value, like 'var(--card)', '12px' or '500' |
|
|
100
105
|
| `outside-ancestor` | an element that reads the state of an element it is not inside | nest it in the element the message names |
|
|
101
106
|
| `page-access-level` | an `accessLevel` that is not one the router reads | one of the values the message lists |
|
|
102
107
|
| `page-route-reserved` | a page under `/fn`, where the space's functions answer | another slug |
|
|
@@ -107,6 +112,7 @@ The space is not written until these are fixed.
|
|
|
107
112
|
| `part-missing` | a compound element — a carousel, a tab container, a dropdown — without a part it renders through | the part the message names, inside it (`carousel()` writes its own track) |
|
|
108
113
|
| `prop-missing` | an instance without a prop its component requires | `component('card', { props: { name: … } })`, or bind it |
|
|
109
114
|
| `prop-name` | a prop whose name a template cannot read as `props.x` | letters, digits and `_` |
|
|
115
|
+
| `prop-type-unknown` | a prop declared with a type no editor offers and nothing checks a value against | one of text, textarea, select, boolean, number, scalar, json, elementIds — words are `text` |
|
|
110
116
|
| `prop-unknown` | a prop the component does not declare, handed in or read | the prop it suggests, or declare it: `props: { name: { type: 'text' } }` |
|
|
111
117
|
| `prop-value` | a prop handed in with a value its declaration does not take | a value of the declared type, or one of its options |
|
|
112
118
|
| `props-outside-component` | `props.x` read outside a component | read the source it would have come from |
|
|
@@ -131,6 +137,10 @@ The space is not written until these are fixed.
|
|
|
131
137
|
| `step-name` | a step name a later step cannot read as `{{ name.field }}` | a letter first, then letters, digits, `-` and `_` |
|
|
132
138
|
| `step-params` | a step param that does not exist, or a value outside its options | the params and values it lists |
|
|
133
139
|
| `step-type` | a step `type` that does not exist | the step builders — `setState(…)`, `navigate(…)` — write it |
|
|
140
|
+
| `style-condition-unknown` | a condition a class's rules cannot hold under | `motion-reduce`, `motion-safe`, or a container width — `container (max-width: 30rem)`, `container card (min-width: 480px)` |
|
|
141
|
+
| `style-pseudo-content` | a `content` CSS cannot read — text without its quotes draws nothing — or a `before`/`after` with no `content`, which is not there at all | the text in quotes inside the string — `content: '"→"'`, `'""'` for an empty box — or a function such as `counter(step)` |
|
|
142
|
+
| `style-pseudo-property` | a property the pseudo-element ignores — the browser drops it without a word | one it honours (`::selection` paints, `::marker` and `::placeholder` take text and font), or style the element |
|
|
143
|
+
| `style-pseudo-unknown` | a pseudo-element a class cannot dress | one of `before`, `after`, `marker`, `placeholder`, `first-letter`, `first-line`, `selection` — without the `::` |
|
|
134
144
|
| `style-state-unknown` | a state a selector does not react to | one of the states it lists (`hover`, `focus`, `active`…) |
|
|
135
145
|
| `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` |
|
|
136
146
|
| `template-short-source` | a source named without its prefix inside a template or a step | the full name: `apiContainer_stats`, `list_rows` |
|
|
@@ -161,6 +171,7 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
161
171
|
| Code | What was wrong | Write instead |
|
|
162
172
|
| --- | --- | --- |
|
|
163
173
|
| `action-output-path` | a read of `.data` on a provider fed by a server action — it publishes the action’s output at its root, and `.data` is a `query` provider’s answer | the output’s own field — `apiContainer_feed.stories`, not `apiContainer_feed.data.stories` |
|
|
174
|
+
| `animation-name-unknown` | `animation-name` naming keyframes the space does not declare — nothing plays | declare them in the space's `keyframes`, or name one it has |
|
|
164
175
|
| `click-on-static-element` | a click flow on a container, text, heading, image or list item — no keyboard reaches it | the flow on a `button` (it holds children) or a `link` |
|
|
165
176
|
| `colour-without-dark` | a colour token with no dark value | `{ light, dark, default }` |
|
|
166
177
|
| `condition-starts-visible` | a computed visibility that shows until its data answers | `visible: { source, template }` |
|
|
@@ -176,9 +187,11 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
176
187
|
| `form-control-name-taken` | two controls in one form with one name — one overwrites the other | a name each |
|
|
177
188
|
| `form-control-unnamed` | a control in a form with no `name` — its value never reaches `values` | `formControl({ name: 'email', … })` |
|
|
178
189
|
| `form-value-compared-to-blank` | a `when` comparing a submitted field to `""` — a field nobody typed in is not sent | `operator: 'empty'` / `'notEmpty'` |
|
|
190
|
+
| `heading-level-overridden` | a markdown's or richText's `heading` slot and a level's (`heading3`) both setting one property, the general class written later in the stylesheet — the level's value is lost | set the property on one of the two: the level slot for that level alone, `heading` for every heading |
|
|
179
191
|
| `heading-level-skipped` | an `h4` right after an `h2` — the outline misses a level | the next level down; size it with its class |
|
|
180
192
|
| `image-without-alt` | an image that is not `decorative` and has no `alt` | say what it shows, or `decorative: true` |
|
|
181
193
|
| `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`…) |
|
|
194
|
+
| `link-current-section` | `current: 'section'` on a link that is never current (an external one) or current everywhere (to `/`) | leave `current` out — `'section'` is for a link to a section's own page, `/automations/runs` |
|
|
182
195
|
| `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 |
|
|
183
196
|
| `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 |
|
|
184
197
|
| `overlay-never-opened` | a modal or a dialog that starts hidden and that no step opens | a flow with `openModal('id')` / `openDialog('id')` |
|
|
@@ -208,10 +221,12 @@ Nothing is wrong: the page renders as written. Each is a shorter way to the same
|
|
|
208
221
|
|
|
209
222
|
| Code | Written the long way | The short way |
|
|
210
223
|
| --- | --- | --- |
|
|
224
|
+
| `class-overrides-class` | one class's shorthand erasing the longhand another class on the same element writes out — `padding` over `padding-top` — because the stylesheet writes it later: classes in the order they are first met, a breakpoint's rules after the base, never the order of a class list | the longhands the shorthand means instead of it (`padding-left`, `padding-right`), so it leaves the other class's alone — or `quiet: ['class-overrides-class']` when the shorthand is meant to win |
|
|
211
225
|
| `content-attribute` | a button or a link whose children are only its words and an icon — a `text`, a `fontAwesome` — elements more than it needs | its own `content` and `icon` (`link({ href, content: 'Docs', icon: 'fa-solid fa-arrow-right', iconPlacement: 'after' })`); the icon's class goes on the `icon` slot, and what the text's class adds on the box's class, never the class itself |
|
|
212
226
|
| `custom-css-class` | a `customCss` rule a class can hold — `.card:hover`, `.panel .icon` | the class's own `states` or `ancestors`, where the style editor reads it back and a breakpoint can change it |
|
|
213
|
-
| `custom-css-notifications` | the toasts dressed with `.
|
|
227
|
+
| `custom-css-notifications` | the toasts or their icon, close button or progress bar dressed with `.Toastify__*` rules in `customCss` | `notifications: { font, fontSize, fontWeight, minHeight, iconSize, closeColor, progressHeight, … }` |
|
|
214
228
|
| `custom-css-sdk-default` | `customCss` repeating what the SDK already does for every space — less motion when asked, the theme toggle showing one icon | nothing: remove it |
|
|
229
|
+
| `custom-css-slot` | a part of a built-in element dressed in `customCss` by the SDK's markup — a form control's `<input>`, a pager's buttons, a heading inside a markdown | a class on the slot of that part — `slots: { field: input }`, `elements.<type>.slots` — with its states |
|
|
215
230
|
| `heavy-animation` | keyframes animating what the browser repaints or lays out again on every frame — a size, a position, a blur, a shadow, or a colour in a loop — which stutters whenever the page is busy, most of all while it loads | `opacity` and `transform`: a size or a position is `translate`/`scale`, a blur or a shadow is the `opacity` of a layer carrying it; a loop that must animate anything else starts `paused` and runs under `[data-hydrated]` |
|
|
216
231
|
| `literal-colour` | a colour written out in a class where the space has a token of that value — it stays put in the dark scheme | `var(--token)` when it should follow the scheme; a token of one value of its own when it must stay the same in both |
|
|
217
232
|
| `repeated-on-pages` | the same block — a header, a footer, a side panel — written into several pages | a layout holding it once (`layouts`, and `layout: { id, slot }` on each page) — a component when only some pages of a layout carry it; a link marks its own page with the `current` state |
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Animations
|
|
4
4
|
|
|
5
|
-
- **Keyframes go in the space's `
|
|
6
|
-
the class names them: `animation: 'marquee 30s linear infinite'`.
|
|
5
|
+
- **Keyframes go in the space's `keyframes`** (`keyframes: { marquee: { to: { transform: 'translateX(-50%)' } } }`)
|
|
6
|
+
and the class names them: `animation: 'marquee 30s linear infinite'`. A name no keyframes declare is warned
|
|
7
|
+
(`animation-name-unknown`).
|
|
7
8
|
- **An element hidden by `visible` is `display: none`**, so an animation in its class runs again every time it is
|
|
8
9
|
shown — the way to animate a slide in (see recipes/every-few-seconds.ts).
|
|
9
10
|
- **Pause on hover** from the element around it: `ancestors: { [band.name]: { states: { hover:
|
|
@@ -17,7 +17,7 @@ It sizes the canvas to the device (at most 2× — `maxPixelRatio`), follows its
|
|
|
17
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
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
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;
|
|
20
|
+
`[plugin <type> "<id>"] fragment shader failed: …` (`plitzi page check` lists it under the console) and `error` says it;
|
|
21
21
|
show the still image meanwhile, as above. `useAnimationFrame(onFrame, { target })` is the same loop for motion that
|
|
22
22
|
is not a canvas.
|
|
23
23
|
|
|
@@ -34,13 +34,13 @@ Only a suggestion's code: a problem is never quieted (`quiet-unknown`).
|
|
|
34
34
|
| Written the long way | The short way | Suggestion |
|
|
35
35
|
| --- | --- | --- |
|
|
36
36
|
| The same header, footer or sidebar in every page | A **layout** holding it once; each page names it (`layout: { id, slot }`) — [layouts](layouts.md) | `repeated-on-pages` |
|
|
37
|
-
| A header copied per page so one link can be styled "active" | The link marks its own page: `states: { current: { … } }` on its class; `
|
|
37
|
+
| A header copied per page so one link can be styled "active" | The link marks its own page: `states: { current: { … } }` on its class; `current: 'section'` for an entry lit on the pages under it | `repeated-on-pages` |
|
|
38
38
|
| The same card, row or tile written again with other words | A **component** with props, placed with `component(id, { props })` — [components](components.md) | `repeated-shape` |
|
|
39
39
|
| Rows of data written one by one, side by side | One `list` over the rows — `items: [ … ]` fixed, or bound to a source — with its row written once — [lists](lists.md). Data is the test: three cards a person rewords on the canvas read better as three cards. Copies that read different sources or write different state keys are controls written alike, and not offered | `repeated-shape` |
|
|
40
40
|
| `button({ children: [text('Save')] })`, `link({ children: [text('Docs'), fontAwesome({ icon })] })` | `button({ content: 'Save' })`, `link({ href, content: 'Docs', icon, iconPlacement: 'after' })` — the icon's class on the `icon` slot; what the text's class adds (`whiteSpace: 'nowrap'`) moves to the box's class — never the class itself, whose `inherit` would then point past the box and whose `pointerEvents: 'none'` would switch the box off | `content-attribute` |
|
|
41
41
|
| `.card:hover { … }`, `.card .icon { … }` in `customCss` | The class's own `states` and `ancestors` | `custom-css-class` |
|
|
42
42
|
| A reduced-motion reset, or rules showing one icon of the theme toggle, in `customCss` | Nothing: the SDK does both for every space | `custom-css-sdk-default` |
|
|
43
|
-
| `.Toastify__toast { font-family: …; border: … }` in `customCss` | `notifications: { font, fontSize, border,
|
|
43
|
+
| `.Toastify__toast { font-family: …; border: … }`, `.Toastify__toast-icon { width: … }` in `customCss` | `notifications: { font, fontSize, border, iconSize, closeColor, progressHeight, … }` | `custom-css-notifications` |
|
|
44
44
|
| Keyframes animating `width`, `top`, `filter: blur()`, `box-shadow`, a colour in a loop | `opacity` and `transform`; decoration held until `[data-hydrated]` — [motion](colours-and-motion.md) | `heavy-animation` |
|
|
45
45
|
|
|
46
46
|
## What it declares and never uses
|
|
@@ -63,6 +63,9 @@ And a few the suggestions do not count, because they cost styles rather than ele
|
|
|
63
63
|
|
|
64
64
|
- **A look used twice is a class**, written once with `styles()`; every element of a TYPE dressed the same way is the
|
|
65
65
|
space's `elements` defaults (`elements: { heading: { color: 'var(--fg)' } }`), not a class on each.
|
|
66
|
+
- **A shorthand in a class says every side.** On an element wearing two classes, one's `padding` erases the
|
|
67
|
+
`padding-top` the other writes out wherever the stylesheet writes it later; write the longhands it means
|
|
68
|
+
(`class-overrides-class` — a suggestion, quieted like the rest).
|
|
66
69
|
- **Inner parts are slots.** A form control's input, a modal's backdrop, a theme toggle's icons: style them with
|
|
67
70
|
`slots: { input: inputClass }` on the element, or the type's `slots` in `elements` — never a `customCss` rule reaching
|
|
68
71
|
into the element.
|