@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
package/.mcp.json
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# Design System Ontology
|
|
2
|
+
|
|
3
|
+
An OWL ontology for modeling UI design systems as structured, queryable knowledge graphs. Built to bridge the gap between design specifications and implementation by establishing a shared semantic vocabulary for components, patterns, layouts, and their relationships.
|
|
4
|
+
|
|
5
|
+
**Core Philosophy:** A design system is more than a component library - it's a formal language. By modeling UI elements ontologically, we enable machine-readable specifications, automated consistency checking, and intelligent tooling that understands design intent.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### 1. Core Concepts
|
|
12
|
+
|
|
13
|
+
The ontology organizes UI elements into a hierarchy:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
UIElement (root)
|
|
17
|
+
└── UIBlock (visual/abstract entity for composing UIs)
|
|
18
|
+
├── Component - Implementable UI piece (Button, Badge, Card...)
|
|
19
|
+
├── Pattern - Reusable solution to UX problems
|
|
20
|
+
├── Layout - Opinionated space division for navigation
|
|
21
|
+
└── Subcomponent - Part of a parent component
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Components are organized by **Tiers** (scope/applicability) and can be customized through **ModifierFamilies** (variant axes).
|
|
25
|
+
|
|
26
|
+
### 2. Defining a Component
|
|
27
|
+
|
|
28
|
+
```turtle
|
|
29
|
+
@prefix dso: <https://ds.canonical.com/ontology#> .
|
|
30
|
+
@prefix ds: <https://ds.canonical.com/data/> .
|
|
31
|
+
|
|
32
|
+
ds:global.component.button a dso:Component ;
|
|
33
|
+
dso:name "Button" ;
|
|
34
|
+
dso:description "Buttons trigger actions within an interface" ;
|
|
35
|
+
dso:tier ds:global ;
|
|
36
|
+
dso:hasModifierFamily ds:global.modifier_family.importance ;
|
|
37
|
+
dso:whenToUse "For primary actions that transform or submit data" ;
|
|
38
|
+
dso:whenNotToUse "For navigation - use links instead" .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Tiered Organization
|
|
42
|
+
|
|
43
|
+
Components belong to tiers that define their scope:
|
|
44
|
+
|
|
45
|
+
| Tier | Description | Example Components |
|
|
46
|
+
|------|-------------|-------------------|
|
|
47
|
+
| `global` | Universal components | Button, Badge, Card, Accordion |
|
|
48
|
+
| `global_form` | Form-specific | Input, Select, Checkbox |
|
|
49
|
+
| `apps` | Application UI | Navigation, Toolbar, FileTree |
|
|
50
|
+
| `apps_wpe` | WordPress-specific | WPE variants |
|
|
51
|
+
| `site` | Marketing/website | Hero, Footer |
|
|
52
|
+
| `stores` | E-commerce | Product card, Cart |
|
|
53
|
+
| `documentation` | Docs-specific | Code block, API reference |
|
|
54
|
+
|
|
55
|
+
### 4. Modifier System
|
|
56
|
+
|
|
57
|
+
Modifiers provide systematic variation through **ModifierFamilies**:
|
|
58
|
+
|
|
59
|
+
```turtle
|
|
60
|
+
ds:global.modifier_family.importance a dso:ModifierFamily ;
|
|
61
|
+
dso:name "Importance" ;
|
|
62
|
+
dso:hasModifier ds:global.modifier.primary,
|
|
63
|
+
ds:global.modifier.secondary,
|
|
64
|
+
ds:global.modifier.tertiary .
|
|
65
|
+
|
|
66
|
+
ds:global.component.button
|
|
67
|
+
dso:hasModifierFamily ds:global.modifier_family.importance .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Available modifier families:
|
|
71
|
+
- **Importance** - Visual hierarchy (primary, secondary, tertiary)
|
|
72
|
+
- **Criticality** - Severity levels (success, warning, error)
|
|
73
|
+
- **Density** - Spacing variants (compact, default, comfortable)
|
|
74
|
+
- **Lifecycle** - State (draft, active, deprecated)
|
|
75
|
+
- **Anticipation** - Expected interaction type
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## How-To Guides
|
|
80
|
+
|
|
81
|
+
### How to Add a New Component
|
|
82
|
+
|
|
83
|
+
1. Determine the appropriate tier based on scope
|
|
84
|
+
2. Create a Turtle file in `data/{tier}/component/`
|
|
85
|
+
3. Define required properties: name, description, tier
|
|
86
|
+
4. Link to applicable modifier families
|
|
87
|
+
5. Add usage guidelines (whenToUse, whenNotToUse)
|
|
88
|
+
|
|
89
|
+
```turtle
|
|
90
|
+
@prefix dso: <https://ds.canonical.com/ontology#> .
|
|
91
|
+
@prefix ds: <https://ds.canonical.com/data/> .
|
|
92
|
+
|
|
93
|
+
ds:apps.component.file_tree a dso:Component ;
|
|
94
|
+
dso:name "FileTree" ;
|
|
95
|
+
dso:description "Hierarchical file browser for navigating directory structures" ;
|
|
96
|
+
dso:tier ds:apps ;
|
|
97
|
+
dso:whenToUse "When users need to navigate nested file hierarchies" ;
|
|
98
|
+
dso:figmaLink <https://figma.com/file/...> .
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### How to Define a Layout
|
|
102
|
+
|
|
103
|
+
Layouts define how space is divided for a domain of information:
|
|
104
|
+
|
|
105
|
+
```turtle
|
|
106
|
+
ds:apps.layout.sidebar a dso:Layout ;
|
|
107
|
+
dso:name "Sidebar Layout" ;
|
|
108
|
+
dso:domain "Application navigation" ;
|
|
109
|
+
dso:grid "1fr 4fr" ;
|
|
110
|
+
dso:gridAreas "sidebar main" ;
|
|
111
|
+
dso:targetDevices "desktop, tablet" .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### How to Create a Pattern
|
|
115
|
+
|
|
116
|
+
Patterns are reusable solutions to UX problems:
|
|
117
|
+
|
|
118
|
+
```turtle
|
|
119
|
+
ds:global.pattern.empty_state a dso:Pattern ;
|
|
120
|
+
dso:name "Empty State" ;
|
|
121
|
+
dso:description "Guidance shown when a container has no content" ;
|
|
122
|
+
dso:tier ds:global ;
|
|
123
|
+
dso:whenToUse "When a list, table, or container is empty" ;
|
|
124
|
+
dso:guidelines "Include illustration, message, and action" .
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### How to Model Component Composition
|
|
128
|
+
|
|
129
|
+
Use subcomponents for parts that belong to a parent:
|
|
130
|
+
|
|
131
|
+
```turtle
|
|
132
|
+
ds:global.subcomponent.button_icon a dso:Subcomponent ;
|
|
133
|
+
dso:name "Button Icon" ;
|
|
134
|
+
dso:parentComponent ds:global.component.button ;
|
|
135
|
+
dso:standalone false .
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### How to Query the Design System
|
|
139
|
+
|
|
140
|
+
Using sem tools:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Find all global components
|
|
144
|
+
sem lookup dso:Component --filter 'tier=ds:global'
|
|
145
|
+
|
|
146
|
+
# Get context for a specific component
|
|
147
|
+
sem context ds:global.component.button
|
|
148
|
+
|
|
149
|
+
# Find components using a modifier family
|
|
150
|
+
sem sparql "SELECT ?c WHERE { ?c dso:hasModifierFamily ds:global.modifier_family.criticality }"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Reference
|
|
156
|
+
|
|
157
|
+
### Classes
|
|
158
|
+
|
|
159
|
+
| Class | Description | Instances |
|
|
160
|
+
|-------|-------------|-----------|
|
|
161
|
+
| `UIElement` | Root class for all design system entities | - |
|
|
162
|
+
| `UIBlock` | Visual/abstract entity for composing UIs | - |
|
|
163
|
+
| `Component` | Implementable UI piece | 50 |
|
|
164
|
+
| `Pattern` | Reusable UX solution | 21 |
|
|
165
|
+
| `Layout` | Space division for navigation | 9 |
|
|
166
|
+
| `Subcomponent` | Part of a component | 13 |
|
|
167
|
+
| `Modifier` | Variant option | 31 |
|
|
168
|
+
| `ModifierFamily` | Grouping of related modifiers | 9 |
|
|
169
|
+
| `Tier` | Scope/applicability level | 7 |
|
|
170
|
+
| `Property` | Configurable component property | 2 |
|
|
171
|
+
| `Token` | Design token reference | - |
|
|
172
|
+
| `ImplementationObject` | Platform-specific implementation | - |
|
|
173
|
+
| `ImplementationLibrary` | Implementation library | - |
|
|
174
|
+
|
|
175
|
+
### UIBlock Properties
|
|
176
|
+
|
|
177
|
+
| Property | Range | Description |
|
|
178
|
+
|----------|-------|-------------|
|
|
179
|
+
| `name` | string | Display name |
|
|
180
|
+
| `description` | string | What this block is/does |
|
|
181
|
+
| `tier` | Tier | Scope classification |
|
|
182
|
+
| `whenToUse` | string | Usage guidance |
|
|
183
|
+
| `whenNotToUse` | string | Anti-patterns |
|
|
184
|
+
| `guidelines` | string | Design guidelines |
|
|
185
|
+
| `variants` | string | Available variants |
|
|
186
|
+
| `figmaLink` | anyURI | Link to Figma designs |
|
|
187
|
+
| `wireframeLink` | anyURI | Link to wireframes |
|
|
188
|
+
| `anatomy` | anyURI | Link to anatomy diagram |
|
|
189
|
+
| `hasModifierFamily` | ModifierFamily | Applicable variant axes |
|
|
190
|
+
| `hasProperty` | Property | Configurable properties |
|
|
191
|
+
| `usesToken` | Token | Design tokens used |
|
|
192
|
+
|
|
193
|
+
### Layout-Specific Properties
|
|
194
|
+
|
|
195
|
+
| Property | Range | Description |
|
|
196
|
+
|----------|-------|-------------|
|
|
197
|
+
| `domain` | string | Information domain |
|
|
198
|
+
| `grid` | string | CSS grid definition |
|
|
199
|
+
| `gridAreas` | string | Named grid areas |
|
|
200
|
+
| `targetDevices` | string | Supported devices |
|
|
201
|
+
|
|
202
|
+
### Component Relationships
|
|
203
|
+
|
|
204
|
+
| Property | Domain | Range | Description |
|
|
205
|
+
|----------|--------|-------|-------------|
|
|
206
|
+
| `hasSubcomponent` | Component | Subcomponent | Composition |
|
|
207
|
+
| `parentComponent` | Subcomponent | Component | Inverse of above |
|
|
208
|
+
| `hasModifierFamily` | UIBlock | ModifierFamily | Variant axes |
|
|
209
|
+
| `hasModifier` | ModifierFamily | Modifier | Variant options |
|
|
210
|
+
|
|
211
|
+
### Implementation Bridge
|
|
212
|
+
|
|
213
|
+
| Property | Domain | Range | Description |
|
|
214
|
+
|----------|--------|-------|-------------|
|
|
215
|
+
| `implementsBlock` | ImplementationObject | UIBlock | Links code to spec |
|
|
216
|
+
| `library` | ImplementationObject | ImplementationLibrary | Source library |
|
|
217
|
+
| `libraryTier` | ImplementationLibrary | Tier | Library's tier |
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Explanation
|
|
222
|
+
|
|
223
|
+
### Why an Ontology?
|
|
224
|
+
|
|
225
|
+
After a decade using Vanilla Framework (CSS library), Canonical observed that visual consistency worked well but led to challenges:
|
|
226
|
+
|
|
227
|
+
1. **Inconsistent terminology** - Same component, different names across teams
|
|
228
|
+
2. **Implicit relationships** - Component composition undocumented
|
|
229
|
+
3. **Lost design rationale** - Why decisions were made
|
|
230
|
+
4. **Fragmented specifications** - Figma, docs, code out of sync
|
|
231
|
+
|
|
232
|
+
An ontology addresses these by:
|
|
233
|
+
- **Establishing shared vocabulary** - One name, one meaning
|
|
234
|
+
- **Explicit relationships** - Queryable component graph
|
|
235
|
+
- **Structured metadata** - Guidelines, rationale, links preserved
|
|
236
|
+
- **Machine-readable specs** - Enables tooling and validation
|
|
237
|
+
|
|
238
|
+
### Design Principles
|
|
239
|
+
|
|
240
|
+
**1. Separation of Concept and Implementation**
|
|
241
|
+
|
|
242
|
+
The ontology separates the *what* (UIBlock) from the *how* (ImplementationObject). A Button concept can have multiple implementations across React, Web Components, or Flutter while maintaining semantic identity.
|
|
243
|
+
|
|
244
|
+
**2. Tiered Scoping**
|
|
245
|
+
|
|
246
|
+
Not all components belong everywhere. Tiers make scope explicit - global components are universal, while apps-tier components may not make sense on marketing sites.
|
|
247
|
+
|
|
248
|
+
**3. Systematic Variation**
|
|
249
|
+
|
|
250
|
+
ModifierFamilies provide principled variation. Instead of ad-hoc props like `isImportant`, `isPrimary`, `variant="critical"`, the ontology models Importance and Criticality as distinct axes that components can opt into.
|
|
251
|
+
|
|
252
|
+
**4. Documentation as Data**
|
|
253
|
+
|
|
254
|
+
Usage guidelines, when-to-use patterns, and design rationale are first-class properties - queryable, versionable, and programmatically accessible.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Architecture
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
design-system/
|
|
262
|
+
├── definitions/
|
|
263
|
+
│ └── ontology.ttl # TBox: Classes, properties
|
|
264
|
+
├── data/
|
|
265
|
+
│ ├── global/ # Global tier instances
|
|
266
|
+
│ │ ├── component/ # Button, Badge, Card...
|
|
267
|
+
│ │ ├── pattern/ # Empty state, Loading...
|
|
268
|
+
│ │ ├── layout/ # Grid layouts
|
|
269
|
+
│ │ ├── modifier/ # Primary, Secondary...
|
|
270
|
+
│ │ └── modifier_family/ # Importance, Criticality...
|
|
271
|
+
│ ├── apps/ # Apps tier
|
|
272
|
+
│ ├── site/ # Site tier
|
|
273
|
+
│ └── ... # Other tiers
|
|
274
|
+
├── sem.toml # Package manifest
|
|
275
|
+
└── README.md # This file
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Namespaces
|
|
279
|
+
|
|
280
|
+
```turtle
|
|
281
|
+
@prefix dso: <https://ds.canonical.com/ontology#> . # Ontology (TBox)
|
|
282
|
+
@prefix ds: <https://ds.canonical.com/data/> . # Instances (ABox)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### URI Convention
|
|
286
|
+
|
|
287
|
+
Instances follow the pattern: `{tier}.{class}.{name}`
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
ds:global.component.button
|
|
291
|
+
ds:apps.layout.sidebar
|
|
292
|
+
ds:global.modifier_family.importance
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Dependencies
|
|
296
|
+
|
|
297
|
+
- **sem_v1** - Semantic package infrastructure
|
|
298
|
+
- **artifact** - Artifact lifecycle management
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Data Pipeline
|
|
303
|
+
|
|
304
|
+
The design system data is extracted from Coda and transformed to RDF:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
bun install
|
|
308
|
+
|
|
309
|
+
# Create .env with Coda API key
|
|
310
|
+
echo "CODA_API_KEY=your-token" > .env
|
|
311
|
+
|
|
312
|
+
# Extract and transform
|
|
313
|
+
bun run ds:list # List available tables
|
|
314
|
+
bun run ds:extract # Extract to JSON
|
|
315
|
+
bun run ds:transform # Transform to JSON-LD/Turtle
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Implementation Collector
|
|
321
|
+
|
|
322
|
+
The `collect-implementations` script scans codebases for `@implements` annotations and generates RDF linking implementations to their design system specifications.
|
|
323
|
+
|
|
324
|
+
### Setup
|
|
325
|
+
|
|
326
|
+
1. Create a `design-system.json` config file in your project root:
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"name": "my-component-library",
|
|
331
|
+
"platform": "react",
|
|
332
|
+
"description": "React implementation of the design system",
|
|
333
|
+
"link": "https://github.com/org/my-library",
|
|
334
|
+
"documentation": "https://docs.example.com/components",
|
|
335
|
+
"tier": "ds:global",
|
|
336
|
+
"prefix": {
|
|
337
|
+
"short": "ds",
|
|
338
|
+
"namespace": "https://ds.canonical.com/"
|
|
339
|
+
},
|
|
340
|
+
"pattern": "src/**/*.tsx",
|
|
341
|
+
"outputDir": "data"
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Configuration Options
|
|
346
|
+
|
|
347
|
+
| Field | Required | Description |
|
|
348
|
+
|-------|----------|-------------|
|
|
349
|
+
| `name` | Yes | Library identifier (e.g., "pragma-react") |
|
|
350
|
+
| `platform` | Yes | Framework/platform (react, vue, angular, etc.) |
|
|
351
|
+
| `description` | No | Human-readable library description |
|
|
352
|
+
| `link` | Yes | Main repository or package URL |
|
|
353
|
+
| `documentation` | No | Documentation URL if different from link |
|
|
354
|
+
| `tier` | No | Design system tier reference (e.g., "ds:global") |
|
|
355
|
+
| `prefix.short` | Yes | Namespace prefix used in annotations (e.g., "ds") |
|
|
356
|
+
| `prefix.namespace` | Yes | Full namespace URI |
|
|
357
|
+
| `pattern` | Yes | Glob pattern for files to scan |
|
|
358
|
+
| `outputDir` | No | Output directory for .ttl files (default: "data") |
|
|
359
|
+
|
|
360
|
+
### Annotating Components
|
|
361
|
+
|
|
362
|
+
Add `@implements` annotations as comments in your component files:
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
// @implements ds:global.component.button
|
|
366
|
+
export function Button({ children, ...props }) {
|
|
367
|
+
return <button {...props}>{children}</button>;
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Annotation formats:
|
|
372
|
+
- Basic: `// @implements ds:global.component.button`
|
|
373
|
+
- With version: `// @implements ds:global.component.button@1.0.0`
|
|
374
|
+
- Draft status: `// @implements ds:global.component.button [draft]`
|
|
375
|
+
|
|
376
|
+
### Running the Collector
|
|
377
|
+
|
|
378
|
+
From within your project directory (where `design-system.json` is located):
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Using bun directly
|
|
382
|
+
bun /path/to/design-system/src/collect-implementations.ts
|
|
383
|
+
|
|
384
|
+
# Or if installed globally/linked
|
|
385
|
+
collect-implementations
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Output
|
|
389
|
+
|
|
390
|
+
The collector generates two Turtle files in the configured output directory:
|
|
391
|
+
|
|
392
|
+
1. **`implementationLibrary.ttl`** - Defines the implementation library:
|
|
393
|
+
```turtle
|
|
394
|
+
lib:my-component-library a dso:ImplementationLibrary ;
|
|
395
|
+
dso:name "my-component-library" ;
|
|
396
|
+
dso:platform "react" ;
|
|
397
|
+
dso:link <https://github.com/org/my-library> .
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
2. **`implementationObjects.ttl`** - Links each annotated file to its spec:
|
|
401
|
+
```turtle
|
|
402
|
+
lib:my-component-library.button a dso:ImplementationObject ;
|
|
403
|
+
dso:implementsBlock ds:global.component.button ;
|
|
404
|
+
dso:library lib:my-component-library ;
|
|
405
|
+
dso:sourceFile "src/components/Button.tsx" .
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Example Workflow
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# 1. Navigate to your component library
|
|
412
|
+
cd my-react-library
|
|
413
|
+
|
|
414
|
+
# 2. Add annotations to components
|
|
415
|
+
echo '// @implements ds:global.component.button' >> src/Button.tsx
|
|
416
|
+
|
|
417
|
+
# 3. Run the collector
|
|
418
|
+
bun ~/code/cn/design-system/src/collect-implementations.ts
|
|
419
|
+
|
|
420
|
+
# Output:
|
|
421
|
+
# Scanning src/**/*.tsx for @implements annotations...
|
|
422
|
+
# Found 1 valid implementation(s):
|
|
423
|
+
# - ds:global.component.button
|
|
424
|
+
# Written: data/implementationLibrary.ttl
|
|
425
|
+
# Written: data/implementationObjects.ttl
|
|
426
|
+
# Done!
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Version
|
|
432
|
+
|
|
433
|
+
0.1.0 - Initial release with component/pattern/layout hierarchy, tier organization, and modifier system
|
|
434
|
+
|
|
435
|
+
## References
|
|
436
|
+
|
|
437
|
+
- [Canonical's Design System: Towards a Design System Ontology](https://discourse.ubuntu.com/t/canonicals-new-design-system-towards-a-design-system-ontology/70367)
|
|
438
|
+
- [Vanilla Framework](https://vanillaframework.io/)
|