@adieyal/catalogue-cli 0.1.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/dist/bin.d.ts +5 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +53 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/new.d.ts +11 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/preview.d.ts +9 -0
- package/dist/commands/preview.d.ts.map +1 -0
- package/dist/commands/test.d.ts +10 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/validate.d.ts +8 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/loader.d.ts +17 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/schema.d.ts +229 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/init-CI0WzrG1.js +2702 -0
- package/dist/init-CI0WzrG1.js.map +1 -0
- package/dist/registry/file-loader.d.ts +21 -0
- package/dist/registry/file-loader.d.ts.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/vite/entry.d.ts +6 -0
- package/dist/vite/entry.d.ts.map +1 -0
- package/dist/vite/index.d.ts +4 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +15 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/server.d.ts +15 -0
- package/dist/vite/server.d.ts.map +1 -0
- package/package.json +59 -0
- package/skills/document-component.md +83 -0
- package/skills/migrate-library.md +193 -0
- package/skills/new-component.md +98 -0
- package/skills/new-scenario.md +56 -0
- package/skills/setup-tokens.md +148 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Document Component
|
|
2
|
+
|
|
3
|
+
Generate or improve documentation for a component by analyzing its source code.
|
|
4
|
+
|
|
5
|
+
## Arguments
|
|
6
|
+
|
|
7
|
+
- `$ARGUMENTS` - Component ID (e.g., `button`)
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
1. Parse component ID from `$ARGUMENTS`. If empty, list components in `registry/components/` and ask user to choose.
|
|
12
|
+
|
|
13
|
+
2. Read the component source file at `src/components/<id>.ts` (or `.js`).
|
|
14
|
+
|
|
15
|
+
3. Analyze the source code to extract:
|
|
16
|
+
- `static observedAttributes` → Properties
|
|
17
|
+
- Getter/setter pairs → Properties with types
|
|
18
|
+
- `<slot>` elements → Available slots
|
|
19
|
+
- `this.dispatchEvent()` calls → Events
|
|
20
|
+
- Any JSDoc comments
|
|
21
|
+
|
|
22
|
+
4. Read existing docs at `registry/components/<id>/docs.md`.
|
|
23
|
+
|
|
24
|
+
5. Read `registry/components/<id>/component.json` for title and description.
|
|
25
|
+
|
|
26
|
+
6. Generate improved documentation:
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
# <Component Title>
|
|
30
|
+
|
|
31
|
+
<description from component.json>
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
\`\`\`html
|
|
36
|
+
<<component-id> [key-attributes]>
|
|
37
|
+
[typical slot content]
|
|
38
|
+
</<component-id>>
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
## Properties
|
|
42
|
+
|
|
43
|
+
| Property | Type | Default | Description |
|
|
44
|
+
|----------|------|---------|-------------|
|
|
45
|
+
| <attr> | <type> | <default> | <description> |
|
|
46
|
+
|
|
47
|
+
## Slots
|
|
48
|
+
|
|
49
|
+
| Slot | Description |
|
|
50
|
+
|------|-------------|
|
|
51
|
+
| <name> | <description> |
|
|
52
|
+
|
|
53
|
+
## Events
|
|
54
|
+
|
|
55
|
+
| Event | Detail | Description |
|
|
56
|
+
|-------|--------|-------------|
|
|
57
|
+
| <name> | <type> | <description> |
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
### <Example Name>
|
|
62
|
+
|
|
63
|
+
\`\`\`html
|
|
64
|
+
<example code>
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
## Accessibility
|
|
68
|
+
|
|
69
|
+
<accessibility notes based on component type>
|
|
70
|
+
|
|
71
|
+
## See Also
|
|
72
|
+
|
|
73
|
+
- [Related Component](./related.md)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
7. Show the user the generated docs and ask if they want to:
|
|
77
|
+
- Replace existing docs entirely
|
|
78
|
+
- Merge with existing docs
|
|
79
|
+
- Just see the output without saving
|
|
80
|
+
|
|
81
|
+
8. If saving, write to `registry/components/<id>/docs.md`.
|
|
82
|
+
|
|
83
|
+
9. Suggest creating scenarios for any documented states/variants not yet covered.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Migrate Existing Component Library
|
|
2
|
+
|
|
3
|
+
Guide migration of an existing component library to use the catalogue.
|
|
4
|
+
|
|
5
|
+
## Arguments
|
|
6
|
+
|
|
7
|
+
- `$ARGUMENTS` - Optional: path to components directory (e.g., `src/components`)
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
Follow this phased approach. Do NOT try to "port everything" at once.
|
|
12
|
+
|
|
13
|
+
### Phase 1: Assess the Library
|
|
14
|
+
|
|
15
|
+
1. If `$ARGUMENTS` provided, scan that directory. Otherwise, look for common patterns:
|
|
16
|
+
- `src/components/`
|
|
17
|
+
- `lib/components/`
|
|
18
|
+
- `packages/*/src/`
|
|
19
|
+
|
|
20
|
+
2. List all components found (custom elements, web components, or framework components).
|
|
21
|
+
|
|
22
|
+
3. Check how components are currently registered:
|
|
23
|
+
- Side-effect registration on import?
|
|
24
|
+
- Manual `customElements.define()` calls?
|
|
25
|
+
- Framework-specific registration?
|
|
26
|
+
|
|
27
|
+
4. Check for existing:
|
|
28
|
+
- Design tokens (CSS variables, JSON tokens, SCSS)
|
|
29
|
+
- Theme support (light/dark)
|
|
30
|
+
- Documentation (README, Storybook, etc.)
|
|
31
|
+
- Demo pages
|
|
32
|
+
|
|
33
|
+
5. Report findings to user before proceeding.
|
|
34
|
+
|
|
35
|
+
### Phase 2: Create Registration Entrypoint
|
|
36
|
+
|
|
37
|
+
Create `src/register-all.ts` (or similar) that imports all components:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// Auto-generated component registration
|
|
41
|
+
import './components/button/button';
|
|
42
|
+
import './components/card/card';
|
|
43
|
+
// ... etc
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If components are already side-effect registered:
|
|
47
|
+
```typescript
|
|
48
|
+
export * from './components/button';
|
|
49
|
+
export * from './components/card';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Update `catalogue.config.ts` to point to this entrypoint.
|
|
53
|
+
|
|
54
|
+
### Phase 3: Generate Seed Registry
|
|
55
|
+
|
|
56
|
+
For EACH component, create minimal registry files:
|
|
57
|
+
|
|
58
|
+
1. `registry/components/<id>/component.json`:
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"id": "<kebab-case-id>",
|
|
62
|
+
"title": "<Title Case>",
|
|
63
|
+
"status": "beta",
|
|
64
|
+
"kind": "standalone",
|
|
65
|
+
"description": "<from existing docs or infer from code>",
|
|
66
|
+
"tags": [],
|
|
67
|
+
"playground": {
|
|
68
|
+
"primaryScenarioId": "<id>-default"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. `registry/components/<id>/scenarios/default.json`:
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"id": "<id>-default",
|
|
77
|
+
"componentId": "<id>",
|
|
78
|
+
"title": "Default",
|
|
79
|
+
"description": "Primary appearance",
|
|
80
|
+
"render": {
|
|
81
|
+
"element": "<element-tag-name>",
|
|
82
|
+
"slots": {
|
|
83
|
+
"default": "Content"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. `registry/components/<id>/docs.md`:
|
|
90
|
+
```markdown
|
|
91
|
+
# <Title>
|
|
92
|
+
|
|
93
|
+
<existing description or TODO>
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
\`\`\`html
|
|
98
|
+
<<element-tag>></<element-tag>>
|
|
99
|
+
\`\`\`
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Phase 4: Wire Up Design Tokens
|
|
103
|
+
|
|
104
|
+
Ask user about their token setup:
|
|
105
|
+
- CSS variables in a .css file?
|
|
106
|
+
- JSON/YAML tokens compiled to CSS?
|
|
107
|
+
- SCSS variables?
|
|
108
|
+
- Multiple themes (light/dark)?
|
|
109
|
+
|
|
110
|
+
Update `catalogue.config.ts`:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
export default {
|
|
114
|
+
// ...existing config
|
|
115
|
+
themes: {
|
|
116
|
+
default: 'light',
|
|
117
|
+
available: ['light', 'dark'],
|
|
118
|
+
tokenCss: {
|
|
119
|
+
light: './src/tokens/tokens-light.css',
|
|
120
|
+
dark: './src/tokens/tokens-dark.css',
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Ensure the catalogue shell loads tokens at the root level so components inherit CSS variables.
|
|
127
|
+
|
|
128
|
+
### Phase 5: Add Critical Variants
|
|
129
|
+
|
|
130
|
+
For each component, add 2-5 scenarios max covering:
|
|
131
|
+
- Default/primary state
|
|
132
|
+
- Disabled/loading (if applicable)
|
|
133
|
+
- Dense case (long labels, overflow)
|
|
134
|
+
- Responsive stress (narrow container)
|
|
135
|
+
- Dark mode variant
|
|
136
|
+
|
|
137
|
+
Do NOT create scenarios for every prop combination.
|
|
138
|
+
|
|
139
|
+
### Phase 6: Establish Hierarchy
|
|
140
|
+
|
|
141
|
+
Review components and set appropriate `kind`:
|
|
142
|
+
- `standalone` - User-facing, top-level components
|
|
143
|
+
- `subcomponent` - Internal pieces (add `parentId`)
|
|
144
|
+
- `feature` - Complex composites (or use Examples instead)
|
|
145
|
+
|
|
146
|
+
### Phase 7: Validate and Test
|
|
147
|
+
|
|
148
|
+
Run:
|
|
149
|
+
```bash
|
|
150
|
+
npx catalogue validate
|
|
151
|
+
npx catalogue dev
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Verify:
|
|
155
|
+
- All components render in harness
|
|
156
|
+
- Tokens apply correctly
|
|
157
|
+
- No console errors
|
|
158
|
+
|
|
159
|
+
### Migration Tips
|
|
160
|
+
|
|
161
|
+
**Components requiring app context (stores/router/i18n):**
|
|
162
|
+
- Create wrapper scenarios that provide context
|
|
163
|
+
- Keep wrappers shared and few
|
|
164
|
+
|
|
165
|
+
**Components that fetch data:**
|
|
166
|
+
- Add prop to accept data directly
|
|
167
|
+
- Or create "static mode" scenarios
|
|
168
|
+
- Scenarios must NOT make network calls
|
|
169
|
+
|
|
170
|
+
**CSS/theme dependencies:**
|
|
171
|
+
- Load same global CSS the app uses
|
|
172
|
+
- Otherwise screenshots won't match reality
|
|
173
|
+
|
|
174
|
+
**Container queries vs media queries:**
|
|
175
|
+
- Recommend container queries for component internals
|
|
176
|
+
- The catalogue resizer tests container width, not viewport
|
|
177
|
+
- Set `container-type: inline-size` on preview frame
|
|
178
|
+
|
|
179
|
+
### What "Done" Looks Like
|
|
180
|
+
|
|
181
|
+
- [ ] Every component has a primary scenario
|
|
182
|
+
- [ ] Key components have 3-5 variants
|
|
183
|
+
- [ ] Playground works for top 20% of components
|
|
184
|
+
- [ ] CI catches visual regressions
|
|
185
|
+
- [ ] Old demo pages can be deleted
|
|
186
|
+
|
|
187
|
+
### Report to User
|
|
188
|
+
|
|
189
|
+
After migration, summarize:
|
|
190
|
+
- Components migrated: X
|
|
191
|
+
- Scenarios created: Y
|
|
192
|
+
- Components needing manual attention (complex setup, network deps, etc.)
|
|
193
|
+
- Suggested next steps
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Create New Component
|
|
2
|
+
|
|
3
|
+
Create a new component entry in the catalogue registry.
|
|
4
|
+
|
|
5
|
+
## Arguments
|
|
6
|
+
|
|
7
|
+
- `$ARGUMENTS` - Component ID (kebab-case, e.g., `user-avatar`)
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
1. Parse the component ID from `$ARGUMENTS`. If empty, ask the user for a component ID (must be kebab-case).
|
|
12
|
+
|
|
13
|
+
2. Derive the component title by converting kebab-case to Title Case (e.g., `user-avatar` → `User Avatar`).
|
|
14
|
+
|
|
15
|
+
3. Ask the user:
|
|
16
|
+
- What is the component's purpose/description?
|
|
17
|
+
- What status? (stable, beta, deprecated) - default: beta
|
|
18
|
+
- What kind? (standalone, subcomponent, feature) - default: standalone
|
|
19
|
+
- What tags apply? (e.g., form, layout, navigation, feedback)
|
|
20
|
+
|
|
21
|
+
4. Create the directory structure:
|
|
22
|
+
- `registry/components/<id>/`
|
|
23
|
+
- `registry/components/<id>/scenarios/`
|
|
24
|
+
|
|
25
|
+
5. Create `registry/components/<id>/component.json`:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"id": "<component-id>",
|
|
30
|
+
"title": "<Component Title>",
|
|
31
|
+
"status": "<status>",
|
|
32
|
+
"kind": "<kind>",
|
|
33
|
+
"description": "<description>",
|
|
34
|
+
"tags": [<tags>],
|
|
35
|
+
"playground": {
|
|
36
|
+
"primaryScenarioId": "<component-id>-default"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
6. Create `registry/components/<id>/docs.md`:
|
|
42
|
+
|
|
43
|
+
```markdown
|
|
44
|
+
# <Component Title>
|
|
45
|
+
|
|
46
|
+
<description>
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
\`\`\`html
|
|
51
|
+
<<component-id>></<component-id>>
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
## Properties
|
|
55
|
+
|
|
56
|
+
| Property | Type | Default | Description |
|
|
57
|
+
|----------|------|---------|-------------|
|
|
58
|
+
|
|
59
|
+
## Slots
|
|
60
|
+
|
|
61
|
+
| Slot | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| default | Main content |
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
7. Create `registry/components/<id>/scenarios/default.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"id": "<component-id>-default",
|
|
71
|
+
"componentId": "<component-id>",
|
|
72
|
+
"title": "Default",
|
|
73
|
+
"description": "Default appearance",
|
|
74
|
+
"render": {
|
|
75
|
+
"element": "<component-id>",
|
|
76
|
+
"slots": {
|
|
77
|
+
"default": "Content"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
8. Create `src/components/<id>.ts` with a Web Component class:
|
|
84
|
+
- Class name: PascalCase version of the ID (e.g., `user-avatar` → `UserAvatar`)
|
|
85
|
+
- Use Shadow DOM with `mode: 'open'`
|
|
86
|
+
- Include basic styles and a slot
|
|
87
|
+
|
|
88
|
+
9. Update `src/components/index.ts` to add:
|
|
89
|
+
```typescript
|
|
90
|
+
export * from './<component-id>.js';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
10. Run `npx catalogue validate` to verify.
|
|
94
|
+
|
|
95
|
+
11. Tell the user what was created and suggest:
|
|
96
|
+
- Adding properties to the component
|
|
97
|
+
- Creating more scenarios
|
|
98
|
+
- Updating the docs
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Create New Scenario
|
|
2
|
+
|
|
3
|
+
Add a new scenario to an existing component.
|
|
4
|
+
|
|
5
|
+
## Arguments
|
|
6
|
+
|
|
7
|
+
- `$ARGUMENTS` - Format: `<component-id> <scenario-name>` (e.g., `button disabled`)
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
1. Parse arguments from `$ARGUMENTS`:
|
|
12
|
+
- First word: component ID
|
|
13
|
+
- Remaining words: scenario name
|
|
14
|
+
- If missing, ask the user for component ID and scenario name
|
|
15
|
+
|
|
16
|
+
2. Verify the component exists at `registry/components/<component-id>/component.json`. If not, list available components and ask user to choose.
|
|
17
|
+
|
|
18
|
+
3. Generate scenario ID: `<component-id>-<scenario-name-kebab>` (e.g., `button-disabled`)
|
|
19
|
+
|
|
20
|
+
4. Ask the user:
|
|
21
|
+
- Brief description of this scenario
|
|
22
|
+
- What attributes/properties should be set?
|
|
23
|
+
- What slot content should be shown?
|
|
24
|
+
- Any custom viewport size? (optional)
|
|
25
|
+
- Any custom background color? (optional)
|
|
26
|
+
|
|
27
|
+
5. Create `registry/components/<component-id>/scenarios/<scenario-name-kebab>.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"id": "<scenario-id>",
|
|
32
|
+
"componentId": "<component-id>",
|
|
33
|
+
"title": "<Scenario Title>",
|
|
34
|
+
"description": "<description>",
|
|
35
|
+
"render": {
|
|
36
|
+
"element": "<component-id>",
|
|
37
|
+
"attributes": {
|
|
38
|
+
// based on user input
|
|
39
|
+
},
|
|
40
|
+
"slots": {
|
|
41
|
+
"default": "<slot content>"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Include optional fields only if provided:
|
|
48
|
+
- `"viewport": { "width": <w>, "height": <h> }`
|
|
49
|
+
- `"background": "<color>"`
|
|
50
|
+
|
|
51
|
+
6. Run `npx catalogue validate` to verify.
|
|
52
|
+
|
|
53
|
+
7. Tell the user:
|
|
54
|
+
- Scenario created at `registry/components/<id>/scenarios/<name>.json`
|
|
55
|
+
- View it at `http://localhost:5173/#/harness/<scenario-id>`
|
|
56
|
+
- Suggest running `npm run catalogue` to see it
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Setup Design Tokens
|
|
2
|
+
|
|
3
|
+
Configure design tokens for the catalogue so components render with correct styling.
|
|
4
|
+
|
|
5
|
+
## Arguments
|
|
6
|
+
|
|
7
|
+
- `$ARGUMENTS` - Optional: path to tokens file (e.g., `src/tokens/tokens.css`)
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
### Step 1: Identify Token Source
|
|
12
|
+
|
|
13
|
+
If `$ARGUMENTS` provided, use that path. Otherwise, search for:
|
|
14
|
+
- `**/tokens.css`, `**/tokens*.css`
|
|
15
|
+
- `**/variables.css`, `**/vars.css`
|
|
16
|
+
- `**/theme.css`, `**/themes/*.css`
|
|
17
|
+
- `**/design-tokens.json`, `**/tokens.json`
|
|
18
|
+
|
|
19
|
+
Ask user to confirm or provide the correct path.
|
|
20
|
+
|
|
21
|
+
### Step 2: Determine Token Format
|
|
22
|
+
|
|
23
|
+
Identify the format:
|
|
24
|
+
- **CSS Variables**: `:root { --color-primary: #3b82f6; }`
|
|
25
|
+
- **JSON Tokens**: `{ "color": { "primary": { "value": "#3b82f6" } } }`
|
|
26
|
+
- **SCSS Variables**: `$color-primary: #3b82f6;`
|
|
27
|
+
|
|
28
|
+
For JSON/SCSS, ask if there's a build step that compiles to CSS.
|
|
29
|
+
|
|
30
|
+
### Step 3: Identify Themes
|
|
31
|
+
|
|
32
|
+
Check for multiple theme files or theme selectors:
|
|
33
|
+
- Separate files: `tokens-light.css`, `tokens-dark.css`
|
|
34
|
+
- Selectors: `[data-theme="dark"]`, `.dark-theme`, `:root.dark`
|
|
35
|
+
- Media query: `@media (prefers-color-scheme: dark)`
|
|
36
|
+
|
|
37
|
+
List discovered themes to user.
|
|
38
|
+
|
|
39
|
+
### Step 4: Update Configuration
|
|
40
|
+
|
|
41
|
+
Update `catalogue.config.ts` with token configuration:
|
|
42
|
+
|
|
43
|
+
**Single theme (light only):**
|
|
44
|
+
```typescript
|
|
45
|
+
export default {
|
|
46
|
+
// ...
|
|
47
|
+
themes: {
|
|
48
|
+
tokenCss: './src/tokens/tokens.css',
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Multiple themes:**
|
|
54
|
+
```typescript
|
|
55
|
+
export default {
|
|
56
|
+
// ...
|
|
57
|
+
themes: {
|
|
58
|
+
default: 'light',
|
|
59
|
+
available: ['light', 'dark'],
|
|
60
|
+
tokenCss: {
|
|
61
|
+
light: './src/tokens/tokens-light.css',
|
|
62
|
+
dark: './src/tokens/tokens-dark.css',
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Multiple token sets (brands/projects):**
|
|
69
|
+
```typescript
|
|
70
|
+
export default {
|
|
71
|
+
// ...
|
|
72
|
+
themes: {
|
|
73
|
+
tokenSets: {
|
|
74
|
+
brandA: { light: './tokens/brand-a-light.css', dark: './tokens/brand-a-dark.css' },
|
|
75
|
+
brandB: { light: './tokens/brand-b-light.css', dark: './tokens/brand-b-dark.css' },
|
|
76
|
+
},
|
|
77
|
+
defaultTokenSet: 'brandA',
|
|
78
|
+
defaultTheme: 'light',
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Step 5: Scope Decision
|
|
84
|
+
|
|
85
|
+
Ask user which model to use:
|
|
86
|
+
|
|
87
|
+
**Model A - Global tokens (recommended for most):**
|
|
88
|
+
- Tokens apply to entire document
|
|
89
|
+
- Catalogue chrome and components share variables
|
|
90
|
+
- Simplest setup
|
|
91
|
+
|
|
92
|
+
**Model B - Scoped tokens:**
|
|
93
|
+
- Tokens apply only inside preview frame
|
|
94
|
+
- Prevents token names from affecting catalogue UI
|
|
95
|
+
- Better if tokens use generic names (`--text`, `--bg`)
|
|
96
|
+
|
|
97
|
+
For Model B, ensure preview frame has isolation:
|
|
98
|
+
```css
|
|
99
|
+
.preview-frame {
|
|
100
|
+
container-type: inline-size;
|
|
101
|
+
/* tokens scoped here */
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 6: Container Query Setup
|
|
106
|
+
|
|
107
|
+
Since the catalogue resizes the preview container (not viewport), recommend:
|
|
108
|
+
|
|
109
|
+
```css
|
|
110
|
+
.preview-frame {
|
|
111
|
+
container-type: inline-size;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Tell user: "Components should use `@container` queries for internal responsiveness, not `@media` queries. Media queries test viewport; container queries test the actual embedding context."
|
|
116
|
+
|
|
117
|
+
Suggest semantic container breakpoints:
|
|
118
|
+
```css
|
|
119
|
+
/* Document these in your design system */
|
|
120
|
+
/* --cq-sm: 420px */
|
|
121
|
+
/* --cq-md: 640px */
|
|
122
|
+
/* --cq-lg: 960px */
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Step 7: Verify Setup
|
|
126
|
+
|
|
127
|
+
1. Run `npx catalogue dev`
|
|
128
|
+
2. Check that components render with correct colors, typography, spacing
|
|
129
|
+
3. Toggle themes (if multiple) and verify switching works
|
|
130
|
+
4. Resize preview frame and verify container queries respond
|
|
131
|
+
|
|
132
|
+
### Step 8: Document Tokens (Optional)
|
|
133
|
+
|
|
134
|
+
If user wants a tokens documentation page, suggest:
|
|
135
|
+
- Generate from source (don't hand-maintain)
|
|
136
|
+
- Show color palette swatches
|
|
137
|
+
- Typography scale examples
|
|
138
|
+
- Spacing scale visualization
|
|
139
|
+
- Semantic token reference
|
|
140
|
+
|
|
141
|
+
### Report to User
|
|
142
|
+
|
|
143
|
+
Summarize:
|
|
144
|
+
- Token files configured: X
|
|
145
|
+
- Themes available: [light, dark, ...]
|
|
146
|
+
- Token sets (if multiple): [brandA, brandB, ...]
|
|
147
|
+
- Container query setup: enabled/disabled
|
|
148
|
+
- Any warnings or manual steps needed
|