@canonical/design-system 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/.mcp.json +8 -0
- package/README.md +438 -0
- package/biome.json +6 -0
- package/bun.lock +349 -0
- package/data/apps/component/file_tree.ttl +8 -0
- package/data/apps/component/key_value_pair.ttl +8 -0
- package/data/apps/component/navigation.ttl +8 -0
- package/data/apps/component/skeleton_loading.ttl +8 -0
- package/data/apps/component/status_bar.ttl +8 -0
- package/data/apps/component/toolbar.ttl +8 -0
- package/data/apps/layout/application_layout.ttl +8 -0
- package/data/apps/layout/empty_layout.ttl +8 -0
- package/data/apps/layout/list_page_layout.ttl +8 -0
- package/data/apps/layout/settings_page_layout.ttl +8 -0
- package/data/apps/pattern/code_diff.ttl +8 -0
- package/data/apps/pattern/data_table.ttl +8 -0
- package/data/apps/pattern/destructive_modal.ttl +8 -0
- package/data/apps/pattern/key_value_summary.ttl +8 -0
- package/data/apps/pattern/keyboard_shortcuts.ttl +8 -0
- package/data/apps/pattern/notification_center.ttl +8 -0
- package/data/apps/pattern/side_panel.ttl +8 -0
- package/data/apps/pattern/sidepanel_stacked.ttl +8 -0
- package/data/apps.ttl +5 -0
- package/data/apps_wpe.ttl +5 -0
- package/data/documentation/layout/documentation_layout.ttl +8 -0
- package/data/documentation.ttl +5 -0
- package/data/global/component/accordion.ttl +14 -0
- package/data/global/component/announcement.ttl +8 -0
- package/data/global/component/badge.ttl +9 -0
- package/data/global/component/button.ttl +20 -0
- package/data/global/component/card.ttl +8 -0
- package/data/global/component/chip.ttl +8 -0
- package/data/global/component/code_snippet.ttl +8 -0
- package/data/global/component/contextual_menu.ttl +8 -0
- package/data/global/component/heading.ttl +14 -0
- package/data/global/component/icon.ttl +14 -0
- package/data/global/component/icon_in_container.ttl +8 -0
- package/data/global/component/keyboard_key.ttl +8 -0
- package/data/global/component/label.ttl +15 -0
- package/data/global/component/link.ttl +8 -0
- package/data/global/component/notification_inline.ttl +8 -0
- package/data/global/component/notification_toast.ttl +8 -0
- package/data/global/component/pagination.ttl +8 -0
- package/data/global/component/popover.ttl +8 -0
- package/data/global/component/rich_text_editor.ttl +8 -0
- package/data/global/component/search_bar.ttl +8 -0
- package/data/global/component/table.ttl +8 -0
- package/data/global/component/tabs.ttl +8 -0
- package/data/global/component/theme_switcher.ttl +8 -0
- package/data/global/component/tile.ttl +14 -0
- package/data/global/component/tooltip.ttl +8 -0
- package/data/global/group/buttons.ttl +8 -0
- package/data/global/group/cards.ttl +8 -0
- package/data/global/group/tiles.ttl +8 -0
- package/data/global/layout/error_layout.ttl +8 -0
- package/data/global/layout/form_layout.ttl +8 -0
- package/data/global/layout/identity_page_form.ttl +8 -0
- package/data/global/modifier/alpha.ttl +6 -0
- package/data/global/modifier/beta.ttl +6 -0
- package/data/global/modifier/caution.ttl +6 -0
- package/data/global/modifier/comfortable.ttl +6 -0
- package/data/global/modifier/completed.ttl +6 -0
- package/data/global/modifier/constructive.ttl +6 -0
- package/data/global/modifier/dark.ttl +6 -0
- package/data/global/modifier/dense.ttl +6 -0
- package/data/global/modifier/destructive.ttl +6 -0
- package/data/global/modifier/editable.ttl +6 -0
- package/data/global/modifier/elevated.ttl +6 -0
- package/data/global/modifier/error.ttl +6 -0
- package/data/global/modifier/experimental.ttl +6 -0
- package/data/global/modifier/failed.ttl +6 -0
- package/data/global/modifier/focused.ttl +6 -0
- package/data/global/modifier/highlighted.ttl +6 -0
- package/data/global/modifier/in_progress.ttl +6 -0
- package/data/global/modifier/information.ttl +6 -0
- package/data/global/modifier/light.ttl +6 -0
- package/data/global/modifier/loading.ttl +6 -0
- package/data/global/modifier/muted.ttl +6 -0
- package/data/global/modifier/paper.ttl +6 -0
- package/data/global/modifier/planned.ttl +6 -0
- package/data/global/modifier/primary.ttl +6 -0
- package/data/global/modifier/secondary.ttl +6 -0
- package/data/global/modifier/stable.ttl +6 -0
- package/data/global/modifier/success.ttl +6 -0
- package/data/global/modifier/tertiary.ttl +6 -0
- package/data/global/modifier/warning.ttl +6 -0
- package/data/global/modifier/wireframe.ttl +6 -0
- package/data/global/modifier_family/_color_luminosity.ttl +7 -0
- package/data/global/modifier_family/_emphasis.ttl +7 -0
- package/data/global/modifier_family/_other.ttl +7 -0
- package/data/global/modifier_family/anticipation.ttl +7 -0
- package/data/global/modifier_family/criticality.ttl +7 -0
- package/data/global/modifier_family/density.ttl +7 -0
- package/data/global/modifier_family/importance.ttl +7 -0
- package/data/global/modifier_family/lifecycle.ttl +7 -0
- package/data/global/modifier_family/release.ttl +7 -0
- package/data/global/pattern/breadcrumbs.ttl +14 -0
- package/data/global/pattern/info_table.ttl +8 -0
- package/data/global/pattern/modal.ttl +8 -0
- package/data/global/pattern/navigation.ttl +8 -0
- package/data/global/pattern/select_button.ttl +8 -0
- package/data/global/pattern/stepper.ttl +8 -0
- package/data/global/pattern/table_of_contents.ttl +8 -0
- package/data/global/pattern/timeline.ttl +14 -0
- package/data/global/subcomponent/accordion-item.ttl +19 -0
- package/data/global/subcomponent/breadcrumbs-item.ttl +19 -0
- package/data/global/subcomponent/card-content.ttl +14 -0
- package/data/global/subcomponent/card-header.ttl +14 -0
- package/data/global/subcomponent/card-image.ttl +20 -0
- package/data/global/subcomponent/divider.ttl +8 -0
- package/data/global/subcomponent/modal-content.ttl +8 -0
- package/data/global/subcomponent/modal-footer.ttl +8 -0
- package/data/global/subcomponent/modal-header.ttl +8 -0
- package/data/global/subcomponent/spinner.ttl +8 -0
- package/data/global/subcomponent/table-cell.ttl +8 -0
- package/data/global/subcomponent/table-row.ttl +8 -0
- package/data/global/subcomponent/tile-content.ttl +14 -0
- package/data/global/subcomponent/tile-header.ttl +14 -0
- package/data/global/subcomponent/timeline-content.ttl +14 -0
- package/data/global/subcomponent/timeline-event.ttl +31 -0
- package/data/global/subcomponent/timeline-footer.ttl +8 -0
- package/data/global/subcomponent/timeline-header.ttl +8 -0
- package/data/global.ttl +5 -0
- package/data/global_form/component/checkbox_input.ttl +8 -0
- package/data/global_form/component/choices_input.ttl +8 -0
- package/data/global_form/component/combobox_input.ttl +8 -0
- package/data/global_form/component/custom_choices_input.ttl +8 -0
- package/data/global_form/component/datepicker_input.ttl +8 -0
- package/data/global_form/component/rating_input.ttl +8 -0
- package/data/global_form/component/segmented_control_input.ttl +8 -0
- package/data/global_form/component/slider_input.ttl +8 -0
- package/data/global_form/component/switch_input.ttl +8 -0
- package/data/global_form/component/text_input.ttl +8 -0
- package/data/global_form/component/textarea_input.ttl +8 -0
- package/data/global_form/component/wysiwginput.ttl +8 -0
- package/data/global_form/pattern/field.ttl +8 -0
- package/data/global_form/pattern/form.ttl +8 -0
- package/data/global_form/subcomponent/field-description.ttl +8 -0
- package/data/global_form/subcomponent/field-label.ttl +8 -0
- package/data/global_form.ttl +5 -0
- package/data/site/component/quote.ttl +8 -0
- package/data/site/component/rule.ttl +8 -0
- package/data/site/component/section.ttl +8 -0
- package/data/site/layout/site_layout.ttl +8 -0
- package/data/site/pattern/hero-github.ttl +8 -0
- package/data/site/pattern/hero.ttl +8 -0
- package/data/site/pattern/info_table.ttl +8 -0
- package/data/site/pattern/skip_link.ttl +8 -0
- package/data/site.ttl +5 -0
- package/data/stores.ttl +5 -0
- package/definitions/ontology.ttl +498 -0
- package/package.json +42 -0
- package/session/A.DSL.md +429 -0
- package/session/B.NOTES.md +84 -0
- package/session/global.component.accordion.yaml +13 -0
- package/session/global.component.button.yaml +26 -0
- package/session/global.component.card.yaml +24 -0
- package/session/global.component.icon.yaml +7 -0
- package/session/global.component.label.yaml +7 -0
- package/session/global.component.tile.yaml +21 -0
- package/session/global.component.timeline.yaml +20 -0
- package/session/global.pattern.breadcrumbs.yaml +13 -0
- package/session/global.subcomponent.accordion-item.yaml +37 -0
- package/session/global.subcomponent.breadcrumbs-item.yaml +21 -0
- package/session/global.subcomponent.card-content.yaml +7 -0
- package/session/global.subcomponent.card-header.yaml +22 -0
- package/session/global.subcomponent.card-image.yaml +7 -0
- package/session/global.subcomponent.tile-content.yaml +7 -0
- package/session/global.subcomponent.tile-header.yaml +8 -0
- package/session/global.subcomponent.timeline-content.yaml +13 -0
- package/session/global.subcomponent.timeline-event.yaml +20 -0
- package/session/global.subcomponent.timeline-footer.yaml +9 -0
- package/session/global.subcomponent.timeline-header.yaml +18 -0
- package/skills/anatomy-author/ANATOMY_DSL_SPEC.md +423 -0
- package/skills/anatomy-author/SKILL.md +911 -0
- package/skills/component-specifier/SKILL.md +413 -0
- package/skills/design-auditor/SKILL.md +428 -0
- package/source.json +101 -0
- package/src/cli.ts +45 -0
- package/src/collect/generateTurtle.tests.ts +200 -0
- package/src/collect/generateTurtle.ts +187 -0
- package/src/collect/index.ts +4 -0
- package/src/collect/scanAnnotations.tests.ts +138 -0
- package/src/collect/scanAnnotations.ts +78 -0
- package/src/collect/types.ts +57 -0
- package/src/collect/validateCollectConfig.tests.ts +116 -0
- package/src/collect/validateCollectConfig.ts +74 -0
- package/src/collect-implementations.ts +99 -0
- package/src/commands/extract.tests.ts +41 -0
- package/src/commands/extract.ts +48 -0
- package/src/commands/index.ts +3 -0
- package/src/commands/list.tests.ts +26 -0
- package/src/commands/list.ts +26 -0
- package/src/commands/transform.tests.ts +28 -0
- package/src/commands/transform.ts +133 -0
- package/src/config/index.ts +2 -0
- package/src/config/source.schema.json +110 -0
- package/src/config/types.ts +97 -0
- package/src/config/validateConfig.tests.ts +46 -0
- package/src/config/validateConfig.ts +21 -0
- package/src/constants.ts +20 -0
- package/src/graph/GraphStore.tests.ts +157 -0
- package/src/graph/GraphStore.ts +200 -0
- package/src/graph/PrefixMap.tests.ts +129 -0
- package/src/graph/PrefixMap.ts +95 -0
- package/src/graph/buildUri.tests.ts +158 -0
- package/src/graph/buildUri.ts +69 -0
- package/src/graph/index.ts +4 -0
- package/src/graph/types.ts +20 -0
- package/src/providers/CodaProvider.tests.ts +241 -0
- package/src/providers/CodaProvider.ts +174 -0
- package/src/providers/CodaProvider.types.generated.ts +12236 -0
- package/src/providers/index.ts +18 -0
- package/src/serializers/JSONSerializer.tests.ts +79 -0
- package/src/serializers/JSONSerializer.ts +87 -0
- package/src/serializers/TTLSerializer.tests.ts +75 -0
- package/src/serializers/TTLSerializer.ts +99 -0
- package/src/serializers/index.ts +3 -0
- package/src/serializers/types.ts +16 -0
- package/src/transform/resolveReferences.tests.ts +63 -0
- package/src/transform/resolveReferences.ts +36 -0
- package/src/transform/resolveValue.tests.ts +76 -0
- package/src/transform/resolveValue.ts +87 -0
- package/src/transform/transform.tests.ts +99 -0
- package/src/transform/transform.ts +109 -0
- package/src/transform/transformRow.tests.ts +269 -0
- package/src/transform/transformRow.ts +220 -0
- package/src/transform/types.ts +26 -0
- package/tsconfig.json +8 -0
- package/vite.config.ts +11 -0
- package/vitest.config.ts +21 -0
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
# Anatomy Author
|
|
2
|
+
|
|
3
|
+
Write component anatomy specifications using the Design System Anatomy DSL. This skill combines semantic discovery (understanding existing components) with procedural authoring (creating well-formed YAML specifications).
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- Writing anatomy specifications for new or existing components
|
|
8
|
+
- Documenting component structure before implementation
|
|
9
|
+
- Discussing component composition with the team ("these nodes should be siblings, not parent-child")
|
|
10
|
+
- Auditing a codebase against its specifications
|
|
11
|
+
- Supporting code generation from specifications
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The Anatomy DSL represents design system components as YAML trees with:
|
|
16
|
+
- **Named nodes**: Components with URIs (`core:component:Button`)
|
|
17
|
+
- **Anonymous nodes**: Structural elements with roles (`content wrapper`)
|
|
18
|
+
- **Edges**: Parent-child relationships with cardinality and slot names
|
|
19
|
+
- **Styles**: Platform-agnostic properties using CTI-inspired keys
|
|
20
|
+
|
|
21
|
+
This skill helps you author these specifications correctly and consistently.
|
|
22
|
+
|
|
23
|
+
## Discovery Flow
|
|
24
|
+
|
|
25
|
+
Before writing an anatomy, understand the component's context:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
1. sem_lookup(type: "dso:Component", filters: {"dso:tier": "ds:global"})
|
|
29
|
+
-> Find existing components in the target tier
|
|
30
|
+
|
|
31
|
+
2. sem_context(node: "ds:global.component.button")
|
|
32
|
+
-> See modifier families and relationships
|
|
33
|
+
|
|
34
|
+
3. sem_lookup(type: "dso:Subcomponent", filters: {"dso:parentComponent": "ds:global.component.card"})
|
|
35
|
+
-> Find existing subcomponents for composition patterns
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Discovery Queries
|
|
39
|
+
|
|
40
|
+
**Find components by tier:**
|
|
41
|
+
```sparql
|
|
42
|
+
SELECT ?component ?name WHERE {
|
|
43
|
+
?component a dso:Component ;
|
|
44
|
+
dso:name ?name ;
|
|
45
|
+
dso:tier ds:global .
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Find subcomponents of a component:**
|
|
50
|
+
```sparql
|
|
51
|
+
SELECT ?sub ?name WHERE {
|
|
52
|
+
?sub a dso:Subcomponent ;
|
|
53
|
+
dso:name ?name ;
|
|
54
|
+
dso:parentComponent ds:global.component.card .
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## DSL Reference
|
|
59
|
+
|
|
60
|
+
### YAML Format
|
|
61
|
+
|
|
62
|
+
All anatomy files must start with `---` (YAML document start marker):
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
---
|
|
66
|
+
node:
|
|
67
|
+
uri: global.component.button
|
|
68
|
+
# ...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Type System Overview
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
AnatomySpec
|
|
75
|
+
-> node: NamedNode (root must be named)
|
|
76
|
+
|
|
77
|
+
NamedNode
|
|
78
|
+
-> uri: string ("tier.type.name")
|
|
79
|
+
-> styles?: Record<string, TokenPath | TokenPath[] | PrimitiveValue>
|
|
80
|
+
-> edges?: Edge[]
|
|
81
|
+
|
|
82
|
+
AnonymousNode
|
|
83
|
+
-> role: string ("content wrapper")
|
|
84
|
+
-> styles?: Record<string, TokenPath | TokenPath[] | PrimitiveValue>
|
|
85
|
+
-> edges?: Edge[]
|
|
86
|
+
|
|
87
|
+
Edge
|
|
88
|
+
-> node?: NamedNode | AnonymousNode
|
|
89
|
+
-> switch?: Switch (mutually exclusive with node)
|
|
90
|
+
-> relation: Relation
|
|
91
|
+
|
|
92
|
+
Switch
|
|
93
|
+
-> on: "props" | "internal" | "override"
|
|
94
|
+
-> cases: SwitchCase[]
|
|
95
|
+
|
|
96
|
+
SwitchCase
|
|
97
|
+
-> uri?: string (shorthand)
|
|
98
|
+
-> node?: Node (full form)
|
|
99
|
+
|
|
100
|
+
Relation
|
|
101
|
+
-> cardinality: string ("1", "0..1", "0..*", "1..*")
|
|
102
|
+
-> slotName?: string ("default", "header", "icon")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### URI Encoding Convention
|
|
106
|
+
|
|
107
|
+
URIs follow turtle conventions with dot-separated paths: `tier.type.name`
|
|
108
|
+
|
|
109
|
+
| Symbol | Meaning | Example |
|
|
110
|
+
|--------|---------|---------|
|
|
111
|
+
| `.` | Path hierarchy | `global.component.button` |
|
|
112
|
+
| `_` | Word boundary from PascalCase | `CardHeader` → `card_header` |
|
|
113
|
+
| `-` | Dot in compound names | `Card.Header` → `card-header` |
|
|
114
|
+
|
|
115
|
+
**Examples:**
|
|
116
|
+
|
|
117
|
+
| Component | URI |
|
|
118
|
+
|-----------|-----|
|
|
119
|
+
| `Button` | `global.component.button` |
|
|
120
|
+
| `Accordion.Item` | `global.subcomponent.accordion-item` |
|
|
121
|
+
| `CardHeader` | `global.subcomponent.card_header` |
|
|
122
|
+
|
|
123
|
+
**Tiers and Types:**
|
|
124
|
+
|
|
125
|
+
| Tier | Type | Use Case |
|
|
126
|
+
|------|------|----------|
|
|
127
|
+
| `global` | `component` | Universal standalone components |
|
|
128
|
+
| `global` | `subcomponent` | Parts of components (user-instantiable) |
|
|
129
|
+
| `global` | `pattern` | UX solutions combining components |
|
|
130
|
+
| `global` | `layout` | Space-dividing containers |
|
|
131
|
+
| `apps` | `component` | Application-specific components |
|
|
132
|
+
|
|
133
|
+
**Parent Reference in Subcomponents:**
|
|
134
|
+
|
|
135
|
+
Subcomponents must reference their parent in the name:
|
|
136
|
+
|
|
137
|
+
| Labelled Name | Turtle URI |
|
|
138
|
+
|---------------|------------|
|
|
139
|
+
| `Timeline.Item` | `global.subcomponent.timeline-item` |
|
|
140
|
+
| `Accordion.ItemHeader` | `global.subcomponent.accordion-item_header` |
|
|
141
|
+
|
|
142
|
+
### Named vs Anonymous
|
|
143
|
+
|
|
144
|
+
| Type | Identifier | Use Case |
|
|
145
|
+
|------|------------|----------|
|
|
146
|
+
| Named | `uri` | User-instantiable components (things users compose in their code) |
|
|
147
|
+
| Anonymous | `role` | Internal structural elements not directly instantiated by users |
|
|
148
|
+
|
|
149
|
+
**Rule of thumb:** Ask "Can/should a user write `<ComponentName>` in their code?" If yes, use `uri`. If no, use `role`.
|
|
150
|
+
|
|
151
|
+
### DRY Principle
|
|
152
|
+
|
|
153
|
+
When a node has a URI (is not anonymous), it references its own DSL file. Do not inline the full tree—reference the URI only.
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
# Correct: reference only
|
|
157
|
+
edges:
|
|
158
|
+
- node:
|
|
159
|
+
uri: global.component.button
|
|
160
|
+
relation:
|
|
161
|
+
cardinality: "1"
|
|
162
|
+
|
|
163
|
+
# Incorrect: inlining full definition
|
|
164
|
+
edges:
|
|
165
|
+
- node:
|
|
166
|
+
uri: global.component.button
|
|
167
|
+
styles:
|
|
168
|
+
# ... full button styles duplicated here
|
|
169
|
+
relation:
|
|
170
|
+
cardinality: "1"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Cardinality Notation
|
|
174
|
+
|
|
175
|
+
| Notation | Meaning | Example Use |
|
|
176
|
+
|----------|---------|-------------|
|
|
177
|
+
| `"1"` or `"1..1"` | Exactly one (required) | Card body |
|
|
178
|
+
| `"0..1"` | Zero or one (optional) | Card header, Card footer |
|
|
179
|
+
| `"0..*"` | Zero or more | List items |
|
|
180
|
+
| `"1..*"` | One or more | Accordion items (need at least one) |
|
|
181
|
+
| `"2..5"` | Between 2 and 5 | Tab panel (min/max tabs) |
|
|
182
|
+
|
|
183
|
+
### Switch Construct
|
|
184
|
+
|
|
185
|
+
The `switch` construct models positions in the anatomy tree that can be filled by one of several alternatives. It operates at the edge level, parallel to `node`, making polymorphism explicit.
|
|
186
|
+
|
|
187
|
+
#### Syntax
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
edges:
|
|
191
|
+
- switch:
|
|
192
|
+
on: <discriminator>
|
|
193
|
+
cases:
|
|
194
|
+
- uri: <component-uri>
|
|
195
|
+
default: true # optional, marks default case
|
|
196
|
+
- uri: <component-uri>
|
|
197
|
+
- uri: $custom # reserved URI for user-provided components
|
|
198
|
+
relation:
|
|
199
|
+
cardinality: <cardinality>
|
|
200
|
+
slotName: <slot>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Discriminator Vocabulary
|
|
204
|
+
|
|
205
|
+
| Value | Meaning | Use Case |
|
|
206
|
+
|-------|---------|----------|
|
|
207
|
+
| `props` | Consumer chooses via component props | `<Field type="checkbox">` renders Checkbox vs Radio |
|
|
208
|
+
| `internal` | Component manages choice internally | AsyncButton shows Loading/Success/Error based on state |
|
|
209
|
+
| `override` | Consumer can replace with custom component | Timeline accepts custom Event component via slot |
|
|
210
|
+
|
|
211
|
+
#### Shorthand Expansion
|
|
212
|
+
|
|
213
|
+
The shorthand `- uri: X` expands to `- node: { uri: X }`. This allows cases to be expressed concisely when no additional metadata is needed:
|
|
214
|
+
|
|
215
|
+
```yaml
|
|
216
|
+
# Shorthand (common case)
|
|
217
|
+
cases:
|
|
218
|
+
- uri: global.component.checkbox
|
|
219
|
+
|
|
220
|
+
# Expands to full form
|
|
221
|
+
cases:
|
|
222
|
+
- node:
|
|
223
|
+
uri: global.component.checkbox
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
When a case requires additional properties (styles, nested edges), use the full node form:
|
|
227
|
+
|
|
228
|
+
```yaml
|
|
229
|
+
cases:
|
|
230
|
+
- node:
|
|
231
|
+
uri: global.component.textarea
|
|
232
|
+
styles:
|
|
233
|
+
size.height: hug
|
|
234
|
+
size.min.height: size/input/multiline
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### Reserved URI: `$custom`
|
|
238
|
+
|
|
239
|
+
The `$custom` URI indicates that the position accepts a user-provided component:
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
cases:
|
|
243
|
+
- uri: global.subcomponent.timeline-event
|
|
244
|
+
- uri: $custom # consumer can provide custom component
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### Examples
|
|
248
|
+
|
|
249
|
+
**Field with prop-based switch:**
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
---
|
|
253
|
+
node:
|
|
254
|
+
uri: global.component.field
|
|
255
|
+
edges:
|
|
256
|
+
- switch:
|
|
257
|
+
on: props
|
|
258
|
+
cases:
|
|
259
|
+
- uri: global.component.checkbox
|
|
260
|
+
- uri: global.component.radio
|
|
261
|
+
- uri: global.component.text-input
|
|
262
|
+
relation:
|
|
263
|
+
cardinality: "1"
|
|
264
|
+
slotName: input
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Async button with internal state switch:**
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
---
|
|
271
|
+
node:
|
|
272
|
+
uri: global.component.async-button
|
|
273
|
+
edges:
|
|
274
|
+
- switch:
|
|
275
|
+
on: internal
|
|
276
|
+
cases:
|
|
277
|
+
- uri: global.subcomponent.async-button-idle
|
|
278
|
+
- uri: global.subcomponent.async-button-loading
|
|
279
|
+
- uri: global.subcomponent.async-button-success
|
|
280
|
+
- uri: global.subcomponent.async-button-error
|
|
281
|
+
relation:
|
|
282
|
+
cardinality: "1"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Timeline with override-capable slot:**
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
---
|
|
289
|
+
node:
|
|
290
|
+
uri: global.component.timeline
|
|
291
|
+
edges:
|
|
292
|
+
- switch:
|
|
293
|
+
on: override
|
|
294
|
+
cases:
|
|
295
|
+
- uri: global.subcomponent.timeline-event
|
|
296
|
+
- uri: $custom
|
|
297
|
+
relation:
|
|
298
|
+
cardinality: "1..*"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Slot Names
|
|
302
|
+
|
|
303
|
+
Common slot conventions:
|
|
304
|
+
|
|
305
|
+
| Slot | Purpose |
|
|
306
|
+
|------|---------|
|
|
307
|
+
| `default` | Main content area (React children, Vue default slot) |
|
|
308
|
+
| `header` | Header content |
|
|
309
|
+
| `footer` | Footer content |
|
|
310
|
+
| `icon` | Icon placement |
|
|
311
|
+
| `label` | Text label |
|
|
312
|
+
| `media` | Image/video content |
|
|
313
|
+
| `actions` | Action buttons |
|
|
314
|
+
|
|
315
|
+
**Convention:** `slotName: default` implies the main children slot (`children` in React, default slot in Vue).
|
|
316
|
+
|
|
317
|
+
### Style Key Categories
|
|
318
|
+
|
|
319
|
+
Styles use CTI-inspired dot-notation: `category.type[.item]`
|
|
320
|
+
|
|
321
|
+
#### Layout (typically invariant)
|
|
322
|
+
```yaml
|
|
323
|
+
layout.type: stack | flow | grid
|
|
324
|
+
layout.direction: horizontal | vertical
|
|
325
|
+
layout.align: start | center | end | stretch
|
|
326
|
+
layout.justify: start | center | end | space-between | space-around
|
|
327
|
+
layout.wrap: true | false
|
|
328
|
+
layout.display: block | flex | grid | none
|
|
329
|
+
layout.flex: 1 | auto
|
|
330
|
+
layout.overflow: hidden | scroll | visible
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Spacing (invariant if literal, themeable if token)
|
|
334
|
+
```yaml
|
|
335
|
+
spacing.internal: spacing/medium # padding (themeable)
|
|
336
|
+
spacing.external: spacing/large # margin (themeable)
|
|
337
|
+
spacing.gap: spacing/small # gap between children (themeable)
|
|
338
|
+
spacing.margin.bottom: spacing/small # specific margin
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### Appearance (typically themeable)
|
|
342
|
+
```yaml
|
|
343
|
+
appearance.background: color/surface/card
|
|
344
|
+
appearance.border: border/style/default
|
|
345
|
+
appearance.border.top: border/style/divider
|
|
346
|
+
appearance.shadow: shadow/elevated/medium
|
|
347
|
+
appearance.radius: shape/rounded/full
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
#### Size (invariant if structural, themeable if token)
|
|
351
|
+
```yaml
|
|
352
|
+
size.width: fill | hug | 100% # invariant
|
|
353
|
+
size.width: size/card/width # themeable
|
|
354
|
+
size.max.width: size/container/max
|
|
355
|
+
size.max.height: size/media/max
|
|
356
|
+
size.min.height: 48px
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### Typography (typically themeable)
|
|
360
|
+
```yaml
|
|
361
|
+
typography.size: font/size/body
|
|
362
|
+
typography.weight: font/weight/bold
|
|
363
|
+
typography.color: color/text/primary
|
|
364
|
+
typography.align: center | left | right # can be invariant
|
|
365
|
+
typography.line.height: 1.5
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### Interaction (typically invariant)
|
|
369
|
+
```yaml
|
|
370
|
+
interaction.cursor: pointer | default
|
|
371
|
+
interaction.transition.property: background
|
|
372
|
+
interaction.transition.duration: transition/duration # token = themeable
|
|
373
|
+
interaction.transition.timing: ease
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
#### Object (for media)
|
|
377
|
+
```yaml
|
|
378
|
+
object.fit: cover | contain | fill
|
|
379
|
+
object.position: center | top
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Templates
|
|
383
|
+
|
|
384
|
+
### Basic Component Template
|
|
385
|
+
|
|
386
|
+
```yaml
|
|
387
|
+
node:
|
|
388
|
+
uri: {tier}:component:{Name}
|
|
389
|
+
styles:
|
|
390
|
+
# Structural (invariant)
|
|
391
|
+
layout.type: stack
|
|
392
|
+
layout.direction: vertical
|
|
393
|
+
|
|
394
|
+
# Themeable
|
|
395
|
+
appearance.background: color/surface/{name}
|
|
396
|
+
spacing.internal: spacing/medium
|
|
397
|
+
|
|
398
|
+
edges:
|
|
399
|
+
- node:
|
|
400
|
+
uri: {tier}:element:{Name}Content
|
|
401
|
+
relation:
|
|
402
|
+
cardinality: "1..1"
|
|
403
|
+
slotName: default
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Component with Optional Parts
|
|
407
|
+
|
|
408
|
+
```yaml
|
|
409
|
+
node:
|
|
410
|
+
uri: core:component:Card
|
|
411
|
+
styles:
|
|
412
|
+
layout.type: stack
|
|
413
|
+
layout.direction: vertical
|
|
414
|
+
appearance.background: color/surface/card
|
|
415
|
+
appearance.shadow: shadow/card
|
|
416
|
+
appearance.radius: shape/rounded/full
|
|
417
|
+
|
|
418
|
+
edges:
|
|
419
|
+
- node:
|
|
420
|
+
uri: core:element:CardHeader
|
|
421
|
+
styles:
|
|
422
|
+
layout.type: flow
|
|
423
|
+
layout.direction: horizontal
|
|
424
|
+
spacing.internal: spacing/medium
|
|
425
|
+
relation:
|
|
426
|
+
cardinality: "0..1" # optional
|
|
427
|
+
slotName: header
|
|
428
|
+
|
|
429
|
+
- node:
|
|
430
|
+
uri: core:element:CardBody
|
|
431
|
+
styles:
|
|
432
|
+
layout.type: stack
|
|
433
|
+
spacing.internal: spacing/large
|
|
434
|
+
relation:
|
|
435
|
+
cardinality: "1..1" # required
|
|
436
|
+
slotName: body
|
|
437
|
+
|
|
438
|
+
- node:
|
|
439
|
+
uri: core:element:CardFooter
|
|
440
|
+
styles:
|
|
441
|
+
layout.type: flow
|
|
442
|
+
layout.justify: space-between
|
|
443
|
+
spacing.internal: spacing/small
|
|
444
|
+
relation:
|
|
445
|
+
cardinality: "0..1" # optional
|
|
446
|
+
slotName: footer
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Nested Components (Repeating)
|
|
450
|
+
|
|
451
|
+
```yaml
|
|
452
|
+
node:
|
|
453
|
+
uri: core:component:Accordion
|
|
454
|
+
styles:
|
|
455
|
+
layout.type: stack
|
|
456
|
+
layout.direction: vertical
|
|
457
|
+
appearance.border: border/style/accordion
|
|
458
|
+
|
|
459
|
+
edges:
|
|
460
|
+
- node:
|
|
461
|
+
uri: core:component:AccordionItem
|
|
462
|
+
edges:
|
|
463
|
+
- node:
|
|
464
|
+
uri: core:element:AccordionItemHeader
|
|
465
|
+
styles:
|
|
466
|
+
layout.type: flow
|
|
467
|
+
layout.align: center
|
|
468
|
+
interaction.cursor: pointer
|
|
469
|
+
relation:
|
|
470
|
+
cardinality: "1..1"
|
|
471
|
+
slotName: header
|
|
472
|
+
|
|
473
|
+
- node:
|
|
474
|
+
uri: core:element:AccordionItemContent
|
|
475
|
+
styles:
|
|
476
|
+
layout.overflow: hidden
|
|
477
|
+
spacing.internal: spacing/large
|
|
478
|
+
relation:
|
|
479
|
+
cardinality: "1..1"
|
|
480
|
+
slotName: default
|
|
481
|
+
|
|
482
|
+
relation:
|
|
483
|
+
cardinality: "1..*" # one or more items
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Anonymous Wrapper Node
|
|
487
|
+
|
|
488
|
+
Use when you need a structural element without design system identity:
|
|
489
|
+
|
|
490
|
+
```yaml
|
|
491
|
+
node:
|
|
492
|
+
uri: core:component:Modal
|
|
493
|
+
styles:
|
|
494
|
+
layout.type: stack
|
|
495
|
+
appearance.background: color/surface/modal
|
|
496
|
+
|
|
497
|
+
edges:
|
|
498
|
+
- node:
|
|
499
|
+
role: backdrop overlay # anonymous - no uri
|
|
500
|
+
styles:
|
|
501
|
+
layout.display: block
|
|
502
|
+
appearance.background: color/overlay/dark
|
|
503
|
+
interaction.cursor: pointer
|
|
504
|
+
relation:
|
|
505
|
+
cardinality: "1..1"
|
|
506
|
+
|
|
507
|
+
- node:
|
|
508
|
+
role: content container # anonymous wrapper
|
|
509
|
+
styles:
|
|
510
|
+
layout.type: stack
|
|
511
|
+
size.max.width: size/modal/max
|
|
512
|
+
spacing.internal: spacing/large
|
|
513
|
+
edges:
|
|
514
|
+
- node:
|
|
515
|
+
uri: core:element:ModalHeader
|
|
516
|
+
relation:
|
|
517
|
+
cardinality: "0..1"
|
|
518
|
+
slotName: header
|
|
519
|
+
- node:
|
|
520
|
+
uri: core:element:ModalBody
|
|
521
|
+
relation:
|
|
522
|
+
cardinality: "1..1"
|
|
523
|
+
slotName: body
|
|
524
|
+
relation:
|
|
525
|
+
cardinality: "1..1"
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Simple Button Example
|
|
529
|
+
|
|
530
|
+
```yaml
|
|
531
|
+
node:
|
|
532
|
+
uri: core:component:Button
|
|
533
|
+
styles:
|
|
534
|
+
# Structural
|
|
535
|
+
layout.type: flow
|
|
536
|
+
layout.direction: horizontal
|
|
537
|
+
layout.align: center
|
|
538
|
+
layout.justify: center
|
|
539
|
+
|
|
540
|
+
# Themeable
|
|
541
|
+
spacing.internal: spacing/button
|
|
542
|
+
spacing.gap: spacing/small
|
|
543
|
+
appearance.background: color/action/primary
|
|
544
|
+
appearance.radius: shape/rounded/button
|
|
545
|
+
typography.weight: font/weight/medium
|
|
546
|
+
|
|
547
|
+
# Interaction
|
|
548
|
+
interaction.cursor: pointer
|
|
549
|
+
interaction.transition.property: background, transform
|
|
550
|
+
interaction.transition.duration: transition/fast
|
|
551
|
+
|
|
552
|
+
edges:
|
|
553
|
+
- node:
|
|
554
|
+
uri: core:element:ButtonIcon
|
|
555
|
+
styles:
|
|
556
|
+
size.width: size/icon/small
|
|
557
|
+
size.height: size/icon/small
|
|
558
|
+
relation:
|
|
559
|
+
cardinality: "0..1"
|
|
560
|
+
slotName: icon
|
|
561
|
+
|
|
562
|
+
- node:
|
|
563
|
+
uri: core:element:ButtonLabel
|
|
564
|
+
styles:
|
|
565
|
+
typography.size: font/size/button
|
|
566
|
+
typography.color: color/text/on-action
|
|
567
|
+
relation:
|
|
568
|
+
cardinality: "1..1"
|
|
569
|
+
slotName: label
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
## Workflow
|
|
573
|
+
|
|
574
|
+
### 1. Identify the Component
|
|
575
|
+
|
|
576
|
+
First, determine if the component exists in the design system:
|
|
577
|
+
|
|
578
|
+
```
|
|
579
|
+
sem_lookup(type: "dso:Component", filters: {"dso:name": "Button"})
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
If it exists, gather context:
|
|
583
|
+
```
|
|
584
|
+
sem_context(node: "ds:global.component.button", depth: 2)
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### 2. Gather Structural Requirements
|
|
588
|
+
|
|
589
|
+
Ask:
|
|
590
|
+
- What are the main parts? (header, body, footer, icon, label)
|
|
591
|
+
- Which parts are required vs optional?
|
|
592
|
+
- Can any parts repeat?
|
|
593
|
+
- Are there anonymous structural wrappers needed?
|
|
594
|
+
|
|
595
|
+
### 3. Determine Tier and Type
|
|
596
|
+
|
|
597
|
+
| Question | Answer | Result |
|
|
598
|
+
|----------|--------|--------|
|
|
599
|
+
| Is it universal? | Yes | `core:component:` |
|
|
600
|
+
| Is it app-specific? | Yes | `app:component:` |
|
|
601
|
+
| Is it a subpart? | Yes | `{tier}:element:` |
|
|
602
|
+
| Is it a UX solution? | Yes | `{tier}:pattern:` |
|
|
603
|
+
| Does it divide space? | Yes | `{tier}:layout:` |
|
|
604
|
+
|
|
605
|
+
### 4. Define Edges
|
|
606
|
+
|
|
607
|
+
For each child:
|
|
608
|
+
1. Is it named (in DS) or anonymous (structural wrapper)?
|
|
609
|
+
2. What is its cardinality?
|
|
610
|
+
3. Does it map to a slot?
|
|
611
|
+
|
|
612
|
+
### 5. Apply Styles
|
|
613
|
+
|
|
614
|
+
For each node, consider:
|
|
615
|
+
- **Layout**: How is content arranged?
|
|
616
|
+
- **Spacing**: Internal padding, gaps between children
|
|
617
|
+
- **Appearance**: Background, borders, shadows, radius
|
|
618
|
+
- **Size**: Width/height constraints
|
|
619
|
+
- **Typography**: Text styling (for text-containing nodes)
|
|
620
|
+
- **Interaction**: Cursor, transitions (for interactive nodes)
|
|
621
|
+
|
|
622
|
+
**Rule of thumb**:
|
|
623
|
+
- Structural values (stack, center, fill) = invariant
|
|
624
|
+
- Token references (spacing/medium) = themeable
|
|
625
|
+
|
|
626
|
+
### 6. Validate
|
|
627
|
+
|
|
628
|
+
Check your anatomy against:
|
|
629
|
+
- [ ] Root node is named (has `uri`)
|
|
630
|
+
- [ ] All cardinalities are valid notation
|
|
631
|
+
- [ ] Style keys follow CTI convention
|
|
632
|
+
- [ ] Token paths use `/` delimiter
|
|
633
|
+
- [ ] Anonymous nodes have `role`, not `uri`
|
|
634
|
+
- [ ] Nested components make semantic sense
|
|
635
|
+
|
|
636
|
+
## Response Format
|
|
637
|
+
|
|
638
|
+
When creating an anatomy, respond with:
|
|
639
|
+
|
|
640
|
+
```markdown
|
|
641
|
+
## Anatomy: {ComponentName}
|
|
642
|
+
|
|
643
|
+
**URI:** `{tier}:component:{name}`
|
|
644
|
+
**Tier:** {tier} - {rationale}
|
|
645
|
+
|
|
646
|
+
### Structure Overview
|
|
647
|
+
- {Part 1} (required/optional)
|
|
648
|
+
- {Part 2} (required/optional)
|
|
649
|
+
- ...
|
|
650
|
+
|
|
651
|
+
### Specification
|
|
652
|
+
|
|
653
|
+
\`\`\`yaml
|
|
654
|
+
{yaml content}
|
|
655
|
+
\`\`\`
|
|
656
|
+
|
|
657
|
+
### Notes
|
|
658
|
+
- {Design decision 1}
|
|
659
|
+
- {Design decision 2}
|
|
660
|
+
|
|
661
|
+
### Next Steps
|
|
662
|
+
1. Review with design team
|
|
663
|
+
2. Link to Figma component
|
|
664
|
+
3. Use for implementation guidance
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
## Tips
|
|
668
|
+
|
|
669
|
+
1. **Start simple**: Begin with just structure, add styles incrementally
|
|
670
|
+
2. **Use discovery**: Query existing components for patterns and consistency
|
|
671
|
+
3. **Name thoughtfully**: URIs are identifiers - choose clear, consistent names
|
|
672
|
+
4. **Annotate decisions**: Use YAML comments for non-obvious choices
|
|
673
|
+
5. **Validate cardinality**: Think through edge cases (empty states, maximums)
|
|
674
|
+
6. **Separate concerns**: Structural styles vs themeable styles
|
|
675
|
+
7. **Anonymous nodes are OK**: Don't force DS identity on pure wrappers
|
|
676
|
+
|
|
677
|
+
## Limitations
|
|
678
|
+
|
|
679
|
+
- Does not handle conditional rendering (show/hide based on state)
|
|
680
|
+
- Does not represent portal content (elements rendered elsewhere in DOM)
|
|
681
|
+
- Style inheritance is not yet supported (e.g., "inherits from Card")
|
|
682
|
+
- No runtime behavior specification (only static structure)
|
|
683
|
+
|
|
684
|
+
## References
|
|
685
|
+
|
|
686
|
+
- [Open UI W3C Working Group](https://open-ui.org/) - Inspiration for code-based anatomy
|
|
687
|
+
- [Components as Data](https://medium.com/@nathanacurtis/components-as-data-2be178777f21) - Nathan Curtis's exploration
|
|
688
|
+
- [W3C Design Token Format](https://design-tokens.github.io/community-group/format/) - Token path conventions
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
## Appendix: Anatomy DSL Specification
|
|
693
|
+
|
|
694
|
+
The complete type system for the Anatomy DSL. This specification defines the formal structure for representing component anatomies.
|
|
695
|
+
|
|
696
|
+
### Abstract
|
|
697
|
+
|
|
698
|
+
This specification presents a DSL to represent design system anatomies, providing an accurate platform-agnostic markup primitive to precede implementation.
|
|
699
|
+
|
|
700
|
+
### Intended Usage
|
|
701
|
+
|
|
702
|
+
1. **Documentation**: Implementation primitive for markup and style bindings
|
|
703
|
+
2. **Specification**: Using the tree-based DSL to identify entities to implement and/or reuse
|
|
704
|
+
3. **Discussion**: Using the DSL to discuss across conversations related to DS (e.g., "I believe these nodes should be siblings, not parents of one another")
|
|
705
|
+
4. **Inference**: Supporting automated inference to audit a codebase against its specifications or to support code generation
|
|
706
|
+
|
|
707
|
+
### Requirements
|
|
708
|
+
|
|
709
|
+
**General DSL Requirements:**
|
|
710
|
+
- The DSL MUST optimize for readability
|
|
711
|
+
- The DSL MUST be easy to get started with and use a familiar language
|
|
712
|
+
- The scope of the DSL MUST be minimized to cover only the strict necessary - additional specification information being covered in the schema
|
|
713
|
+
|
|
714
|
+
**Modelling Requirements:**
|
|
715
|
+
- The children of a node MUST be modelled through a reified relation for annotation purposes
|
|
716
|
+
- The DSL MUST support anonymous nodes (nodes that are not named components). In this case, the DSL should support role annotations
|
|
717
|
+
- The DSL MUST support reified annotations of cardinality
|
|
718
|
+
- The DSL MUST support all classes of UI Blocks identified in the ontology (Layout, Pattern, Component, Subcomponent)
|
|
719
|
+
|
|
720
|
+
### Type System
|
|
721
|
+
|
|
722
|
+
The children one-to-many relation follows inspiration from the [Relay connection pattern](https://relay.dev/graphql/connections.htm).
|
|
723
|
+
|
|
724
|
+
```typescript
|
|
725
|
+
/* Reusable types */
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Styles use a CTI (Category-Type-Item) inspired flat key structure
|
|
729
|
+
* for platform-agnostic UI properties.
|
|
730
|
+
*
|
|
731
|
+
* KEY NAMING CONVENTION:
|
|
732
|
+
* Properties follow dot-notation: "category.type[.item]"
|
|
733
|
+
* - Category: Primary concern (layout, spacing, appearance, typography, size)
|
|
734
|
+
* - Type: Specific aspect within that category
|
|
735
|
+
* - Item: Optional further specification
|
|
736
|
+
*
|
|
737
|
+
* INVARIANT VS THEMEABLE:
|
|
738
|
+
* - Invariant (structural): layout.type, layout.direction, size.width: "fill"
|
|
739
|
+
* - Themeable (brand/theme): appearance.*, spacing.* (when using tokens)
|
|
740
|
+
*/
|
|
741
|
+
type Styles = Record<string, TokenPath | PrimitiveValue>;
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* TokenPath: Forward-slash delimited path to a design token.
|
|
745
|
+
* Examples: "spacing/medium", "color/surface/primary", "font/size/heading/1"
|
|
746
|
+
*/
|
|
747
|
+
type TokenPath = string;
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* PrimitiveValue: Direct values not resolved from tokens.
|
|
751
|
+
* Examples: "stack", "center", "fill", 1.5, true
|
|
752
|
+
*/
|
|
753
|
+
type PrimitiveValue = string | number | boolean;
|
|
754
|
+
|
|
755
|
+
/* Main types */
|
|
756
|
+
|
|
757
|
+
interface Relation {
|
|
758
|
+
/**
|
|
759
|
+
* Cardinality: Number of allowed instances.
|
|
760
|
+
* - "1" : Exactly one (required)
|
|
761
|
+
* - "0..1" : Zero or one (optional)
|
|
762
|
+
* - "0..*" : Zero or more
|
|
763
|
+
* - "1..*" : One or more
|
|
764
|
+
* - "2..5" : Between 2 and 5
|
|
765
|
+
*/
|
|
766
|
+
cardinality: string;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Maps content to a specific slot in the parent component.
|
|
770
|
+
* Common values: "default", "header", "footer", "icon", "label"
|
|
771
|
+
*/
|
|
772
|
+
slotName?: string;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Base interface for all nodes in the anatomy tree.
|
|
777
|
+
*/
|
|
778
|
+
interface BaseNode {
|
|
779
|
+
/**
|
|
780
|
+
* Style properties using CTI-inspired keys.
|
|
781
|
+
*
|
|
782
|
+
* Categories:
|
|
783
|
+
* - layout.* : type, direction, align, justify, wrap, display, flex, overflow
|
|
784
|
+
* - spacing.* : internal, external, gap, margin.*, padding.*
|
|
785
|
+
* - appearance.*: background, border, shadow, radius
|
|
786
|
+
* - size.* : width, height, max.*, min.*
|
|
787
|
+
* - typography.*: size, weight, color, align, line.height
|
|
788
|
+
* - interaction.*: cursor, transition.*
|
|
789
|
+
* - object.* : fit, position
|
|
790
|
+
*/
|
|
791
|
+
styles?: Styles;
|
|
792
|
+
|
|
793
|
+
/** Child nodes and their relationships. */
|
|
794
|
+
edges?: Edge[];
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Named nodes represent identifiable components in the design system.
|
|
799
|
+
*/
|
|
800
|
+
interface NamedNode extends BaseNode {
|
|
801
|
+
/**
|
|
802
|
+
* Unique identifier following "tier:type:name" pattern.
|
|
803
|
+
* Examples: "core:component:Button", "app:layout:AppLayout"
|
|
804
|
+
*/
|
|
805
|
+
uri: string;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Anonymous nodes represent structural elements without DS identity.
|
|
810
|
+
*/
|
|
811
|
+
interface AnonymousNode extends BaseNode {
|
|
812
|
+
/**
|
|
813
|
+
* Human-readable description of the node's purpose.
|
|
814
|
+
* Examples: "content wrapper", "spacer element", "icon container"
|
|
815
|
+
*/
|
|
816
|
+
role: string;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
type Node = NamedNode | AnonymousNode;
|
|
820
|
+
|
|
821
|
+
interface Edge {
|
|
822
|
+
node: Node;
|
|
823
|
+
relation: Relation;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Root specification for a component anatomy.
|
|
828
|
+
* The top-level node must always be Named.
|
|
829
|
+
*/
|
|
830
|
+
interface AnatomySpec {
|
|
831
|
+
node: NamedNode;
|
|
832
|
+
}
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
### Language Choice
|
|
836
|
+
|
|
837
|
+
YAML is chosen as the markup language for its:
|
|
838
|
+
- Indentation-based structure matching tree hierarchies
|
|
839
|
+
- Readability over JSON's verbosity
|
|
840
|
+
- Wide adoption and tooling support
|
|
841
|
+
|
|
842
|
+
Alternatives considered and rejected:
|
|
843
|
+
- JSON: Too verbose for deep nesting
|
|
844
|
+
- TOML: Difficulty with deeply nested maps
|
|
845
|
+
- SDLang/KDL: Promising but lacking wide adoption
|
|
846
|
+
|
|
847
|
+
### Complete Example: Accordion
|
|
848
|
+
|
|
849
|
+
```yaml
|
|
850
|
+
node:
|
|
851
|
+
uri: core:component:Accordion
|
|
852
|
+
styles:
|
|
853
|
+
# Structural (invariant)
|
|
854
|
+
layout.type: stack
|
|
855
|
+
layout.direction: vertical
|
|
856
|
+
|
|
857
|
+
# Themeable
|
|
858
|
+
appearance.border: border/style/accordion
|
|
859
|
+
|
|
860
|
+
edges:
|
|
861
|
+
- node:
|
|
862
|
+
uri: core:component:AccordionItem
|
|
863
|
+
edges:
|
|
864
|
+
- node:
|
|
865
|
+
uri: core:element:AccordionItemHeader
|
|
866
|
+
styles:
|
|
867
|
+
# Structural (invariant)
|
|
868
|
+
layout.type: flow
|
|
869
|
+
layout.direction: horizontal
|
|
870
|
+
layout.align: center
|
|
871
|
+
|
|
872
|
+
# Interaction (invariant)
|
|
873
|
+
interaction.cursor: pointer
|
|
874
|
+
interaction.transition.property: background
|
|
875
|
+
interaction.transition.timing: ease
|
|
876
|
+
|
|
877
|
+
# Themeable
|
|
878
|
+
spacing.internal: spacing/medium
|
|
879
|
+
appearance.background: color/surface/header
|
|
880
|
+
typography.weight: font/weight/semibold
|
|
881
|
+
interaction.transition.duration: transition/duration
|
|
882
|
+
|
|
883
|
+
relation:
|
|
884
|
+
cardinality: "1..1"
|
|
885
|
+
slotName: header
|
|
886
|
+
|
|
887
|
+
- node:
|
|
888
|
+
uri: core:element:AccordionItemContent
|
|
889
|
+
styles:
|
|
890
|
+
# Structural (invariant)
|
|
891
|
+
layout.display: block
|
|
892
|
+
layout.overflow: hidden
|
|
893
|
+
|
|
894
|
+
# Themeable
|
|
895
|
+
spacing.internal: spacing/large
|
|
896
|
+
appearance.background: color/surface/content
|
|
897
|
+
|
|
898
|
+
relation:
|
|
899
|
+
cardinality: "1..1"
|
|
900
|
+
slotName: default
|
|
901
|
+
|
|
902
|
+
relation:
|
|
903
|
+
cardinality: "1..*"
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
### Future Work
|
|
907
|
+
|
|
908
|
+
The following features would require additional work:
|
|
909
|
+
- Representation of related nodes displayed in portals
|
|
910
|
+
- Representation of conditional display
|
|
911
|
+
- Inheritance reference for styles (e.g., "NetworkCard inherits from Card")
|