create-kywi-app 0.29.0 → 0.31.0
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/assets/agent-patterns.md
CHANGED
|
@@ -532,6 +532,16 @@ raw JSON textarea — developer territory. A "three stats" module with `stats: {
|
|
|
532
532
|
type: 'json' }` has taken the copy away from the owner; the same module with
|
|
533
533
|
`stat1Value` / `stat1Label` … as `text` props hasn't.
|
|
534
534
|
|
|
535
|
+
**Organize a long props panel.** Past ~6 props the panel is one long column,
|
|
536
|
+
so give repeated sets and secondary settings a `group: 'tile1'` (drawn as a
|
|
537
|
+
collapsible section where its first prop is declared), name the sections with
|
|
538
|
+
`propGroups: { tile1: { label: 'Tile 1', description?, collapsed? } }` on the
|
|
539
|
+
module, and move format hints out of labels into `help: '…'` (one line under
|
|
540
|
+
the field). Inside a group, drop the item prefix from labels (`'Image'`, not
|
|
541
|
+
`'Tile 2: Image'`). Keep primary copy ungrouped at the top; collapse
|
|
542
|
+
rarely-touched sections. Presentation only — storage and rendering are
|
|
543
|
+
unchanged.
|
|
544
|
+
|
|
535
545
|
**Anchor every copy prop in the component.** The front-of-site editor edits
|
|
536
546
|
one prop at a time, in the element that renders it. Mark that element with
|
|
537
547
|
`useInlinePropAnchor()` from `@kywi-software/core/layout` —
|
|
@@ -877,6 +887,67 @@ early, so ask at scoping time.
|
|
|
877
887
|
`Link` header. Never write a static `public/llms.txt` or a hand-made `.md`
|
|
878
888
|
file — the generated ones follow every publish.
|
|
879
889
|
|
|
890
|
+
## When the user pastes a `kywi:` reference
|
|
891
|
+
|
|
892
|
+
The editor's module and section chrome has **Copy reference**, which copies one
|
|
893
|
+
line like this for the owner to paste to you:
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
kywi:marketing/page/3f2a91c0-…/m/7c91e2… — Heading "Run the whole room" on /about
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
The token is the address; the text after ` — ` is what the owner was looking
|
|
900
|
+
at. Its grammar:
|
|
901
|
+
|
|
902
|
+
```
|
|
903
|
+
kywi:{site}/{contentType}/{contentId}/{m|s}/{nodeId}[@pv:{variantId} | @ab:{experimentId}:{variantId}]
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
`m` = module, `s` = section. `site` is the site's slug or UUID, or `_` when the
|
|
907
|
+
editor couldn't tell (the content id is unique across sites, so it still
|
|
908
|
+
resolves). The `@…` suffix appears only when the node was copied from a page
|
|
909
|
+
variant or a page A/B variant: those start as a copy of the default page and
|
|
910
|
+
reuse its node ids. A reference without it always means the default page.
|
|
911
|
+
|
|
912
|
+
1. **Call `resolve_ref` first** with the whole line. It returns the page, where
|
|
913
|
+
the node sits, its props and props schema, ready-made `next` arguments, a
|
|
914
|
+
`design` hint and `warnings`.
|
|
915
|
+
2. **Sanity-check against the description.** If the module type or text
|
|
916
|
+
doesn't match what the owner described, say so before editing.
|
|
917
|
+
3. **Content or settings change** ("change the heading", "make the button say
|
|
918
|
+
Book a demo"): use the site tools with the `next` arguments
|
|
919
|
+
(`update_module_props`, `remove_module`, `add_module`). When `next` says the
|
|
920
|
+
node isn't directly addressable (an arm, a page variant), read the page with
|
|
921
|
+
`get_layout`, change that node by id in the copy `location` names, and write
|
|
922
|
+
it back with `update_layout`.
|
|
923
|
+
4. **Design change** ("make this band tighter", "bigger image"): spacing and
|
|
924
|
+
colors live in the node's `style` (theme tokens). Markup and visual
|
|
925
|
+
behavior live in code: for a custom module, the component named by its
|
|
926
|
+
`defineModule` entry in `kywi.config.ts`; a built-in module's markup is not
|
|
927
|
+
yours to change, so use props/Style Overrides or propose a custom module.
|
|
928
|
+
5. **Linked component** (a warning names it; this includes a module inside a
|
|
929
|
+
linked section): `next` carries no edit arguments. The live page renders the
|
|
930
|
+
component definition (`resolvedProps` when the node can be matched in it,
|
|
931
|
+
otherwise a `resolvedNote` saying the stored copy may differ), and editing
|
|
932
|
+
the component changes
|
|
933
|
+
every page that uses it. Check its reach (`list_components` with
|
|
934
|
+
`withUsage`) and confirm with the owner first. Never patch the placement
|
|
935
|
+
with `update_module_props`: that silently forks it into a page-local
|
|
936
|
+
override. If they want only this page changed, the instance has to be
|
|
937
|
+
detached first (the editor's Detach).
|
|
938
|
+
6. **Inside a personalization or A/B arm** (`location.container`): the change
|
|
939
|
+
only reaches visitors in that arm. Confirm that's what the owner meant, and
|
|
940
|
+
edit the arm with `get_layout` + `update_layout`.
|
|
941
|
+
7. **Ambiguous or not on the default page** (`ambiguous: true`, or
|
|
942
|
+
`notOnDefaultPage: true`, with several `locations` and no edit arguments):
|
|
943
|
+
the id occurs more than once in the copy the reference names, or the
|
|
944
|
+
reference has no variant suffix but the id is now only in page variants.
|
|
945
|
+
Ask the owner which one they meant (or to copy the reference again from
|
|
946
|
+
what's on screen); don't guess.
|
|
947
|
+
8. **Stale reference** (the node or the variant was removed): `resolve_ref`
|
|
948
|
+
lists the page's current modules and sections. Match the owner's
|
|
949
|
+
description, then confirm the match with them before changing anything.
|
|
950
|
+
|
|
880
951
|
## Other capabilities worth knowing
|
|
881
952
|
|
|
882
953
|
- **Comments:** a moderated Comments module (submissions land pending) for
|
|
@@ -69,6 +69,30 @@ Two rules that decide whether the module is really editable:
|
|
|
69
69
|
falls back to the props rail. (Unanchored, only a module with a single text
|
|
70
70
|
prop, declared first, edits in place.)
|
|
71
71
|
|
|
72
|
+
**Organize the panel when a module has more than ~6 props.** The props panel
|
|
73
|
+
draws fields top to bottom in declaration order; past a handful it becomes one
|
|
74
|
+
long, undifferentiated column. Three presentation-only tools (storage,
|
|
75
|
+
rendering and the API are unaffected):
|
|
76
|
+
|
|
77
|
+
- **`group: 'key'`** on a prop puts it in a collapsible section headed by that
|
|
78
|
+
group. A section sits where its first prop is declared. Group every repeated
|
|
79
|
+
set (`tile1*` → `'tile1'`, `stat2*` → `'stat2'`) and secondary settings
|
|
80
|
+
(`'layout'`, `'advanced'`). Leave the module's primary copy (heading, body)
|
|
81
|
+
ungrouped at the top — that is what the owner opens the panel to change.
|
|
82
|
+
- **`propGroups: { key: { label, description?, collapsed? } }`** on the module
|
|
83
|
+
names each section. Start rarely-touched sections (`advanced`, layout knobs,
|
|
84
|
+
the 2nd and later repeated items when there are many) `collapsed: true`, and
|
|
85
|
+
keep the first repeated item open so the owner sees the shape.
|
|
86
|
+
- **`help: '…'`** on a prop is one line of guidance under the field. Keep
|
|
87
|
+
`label` short — `'Crop'`, not `'Crop (CSS object-position, e.g. top left)'` —
|
|
88
|
+
and move the format hint to `help`. Inside a group the section heading
|
|
89
|
+
already says which item it is, so labels drop the prefix: `'Image'`, not
|
|
90
|
+
`'Tile 2: Image'`.
|
|
91
|
+
|
|
92
|
+
Rules of thumb: no group for a module with ≤ 6 props; never a group of one;
|
|
93
|
+
group names are nouns the owner recognizes on the page (`Tile 1`, `Pricing
|
|
94
|
+
card`), never prop-name jargon.
|
|
95
|
+
|
|
72
96
|
### 3. Register it — `defineModule` in `kywi.config.ts`
|
|
73
97
|
|
|
74
98
|
```ts
|
|
@@ -97,7 +121,15 @@ export default defineKywiConfig({
|
|
|
97
121
|
defaultValue: 'split',
|
|
98
122
|
}, // closed choice = real dropdown
|
|
99
123
|
reverse: { type: 'boolean', label: 'Image on the left', defaultValue: false },
|
|
124
|
+
// Secondary knobs in their own section, collapsed (see step 2).
|
|
125
|
+
imageCrop: {
|
|
126
|
+
type: 'text',
|
|
127
|
+
label: 'Image crop',
|
|
128
|
+
help: 'CSS object-position, e.g. "top left" or "50% 30%"',
|
|
129
|
+
group: 'advanced',
|
|
130
|
+
},
|
|
100
131
|
},
|
|
132
|
+
propGroups: { advanced: { label: 'Advanced', collapsed: true } },
|
|
101
133
|
}),
|
|
102
134
|
],
|
|
103
135
|
})
|
|
@@ -178,11 +210,13 @@ entry named after a built-in replaces it.
|
|
|
178
210
|
1. Restart the dev server (config changes need a restart).
|
|
179
211
|
2. Open the layout editor: the module appears in the palette under its
|
|
180
212
|
`category`, with its `label`.
|
|
181
|
-
3.
|
|
213
|
+
3. Select it: the props panel shows the primary copy first, then one section
|
|
214
|
+
per `group`, with the headings and collapsed state you declared.
|
|
215
|
+
4. Fill every prop from the props panel, save — it renders in the
|
|
182
216
|
canvas (not "Unknown module") and on the public page.
|
|
183
|
-
|
|
217
|
+
5. Open the public page as a signed-in admin → **Edit this page**: the first
|
|
184
218
|
text prop is editable by typing on the page.
|
|
185
|
-
|
|
219
|
+
6. Load the page with JavaScript disabled: the content is all there.
|
|
186
220
|
|
|
187
221
|
### 8. Handover note
|
|
188
222
|
|
package/package.json
CHANGED