create-kywi-app 0.29.0 → 0.30.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` —
|
|
@@ -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