@pure-ds/core 0.3.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.
Files changed (129) hide show
  1. package/CSS-INTELLISENSE-LIMITATION.md +98 -0
  2. package/CSS-INTELLISENSE-QUICK-REF.md +238 -0
  3. package/INTELLISENSE.md +384 -0
  4. package/LICENSE +15 -0
  5. package/custom-elements-manifest.config.js +30 -0
  6. package/custom-elements.json +2003 -0
  7. package/dist/types/index.d.ts +2 -0
  8. package/dist/types/packages/pds-configurator/src/figma-export.d.ts +13 -0
  9. package/dist/types/packages/pds-configurator/src/figma-export.d.ts.map +1 -0
  10. package/dist/types/packages/pds-configurator/src/pds-config-form.d.ts +2 -0
  11. package/dist/types/packages/pds-configurator/src/pds-config-form.d.ts.map +1 -0
  12. package/dist/types/packages/pds-configurator/src/pds-configurator.d.ts +2 -0
  13. package/dist/types/packages/pds-configurator/src/pds-configurator.d.ts.map +1 -0
  14. package/dist/types/packages/pds-configurator/src/pds-demo.d.ts +2 -0
  15. package/dist/types/packages/pds-configurator/src/pds-demo.d.ts.map +1 -0
  16. package/dist/types/pds.config.d.ts +13 -0
  17. package/dist/types/pds.config.d.ts.map +1 -0
  18. package/dist/types/pds.d.ts +408 -0
  19. package/dist/types/public/assets/js/app.d.ts +2 -0
  20. package/dist/types/public/assets/js/app.d.ts.map +1 -0
  21. package/dist/types/public/assets/js/pds.d.ts +23 -0
  22. package/dist/types/public/assets/js/pds.d.ts.map +1 -0
  23. package/dist/types/public/assets/pds/components/pds-calendar.d.ts +23 -0
  24. package/dist/types/public/assets/pds/components/pds-calendar.d.ts.map +1 -0
  25. package/dist/types/public/assets/pds/components/pds-drawer.d.ts +2 -0
  26. package/dist/types/public/assets/pds/components/pds-drawer.d.ts.map +1 -0
  27. package/dist/types/public/assets/pds/components/pds-icon.d.ts +53 -0
  28. package/dist/types/public/assets/pds/components/pds-icon.d.ts.map +1 -0
  29. package/dist/types/public/assets/pds/components/pds-jsonform.d.ts +104 -0
  30. package/dist/types/public/assets/pds/components/pds-jsonform.d.ts.map +1 -0
  31. package/dist/types/public/assets/pds/components/pds-richtext.d.ts +121 -0
  32. package/dist/types/public/assets/pds/components/pds-richtext.d.ts.map +1 -0
  33. package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts +61 -0
  34. package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts.map +1 -0
  35. package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts +1 -0
  36. package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts.map +1 -0
  37. package/dist/types/public/assets/pds/components/pds-tabstrip.d.ts +39 -0
  38. package/dist/types/public/assets/pds/components/pds-tabstrip.d.ts.map +1 -0
  39. package/dist/types/public/assets/pds/components/pds-toaster.d.ts +111 -0
  40. package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -0
  41. package/dist/types/public/assets/pds/components/pds-upload.d.ts +83 -0
  42. package/dist/types/public/assets/pds/components/pds-upload.d.ts.map +1 -0
  43. package/dist/types/src/js/app.d.ts +2 -0
  44. package/dist/types/src/js/app.d.ts.map +1 -0
  45. package/dist/types/src/js/common/ask.d.ts +22 -0
  46. package/dist/types/src/js/common/ask.d.ts.map +1 -0
  47. package/dist/types/src/js/common/common.d.ts +3 -0
  48. package/dist/types/src/js/common/common.d.ts.map +1 -0
  49. package/dist/types/src/js/common/font-loader.d.ts +24 -0
  50. package/dist/types/src/js/common/font-loader.d.ts.map +1 -0
  51. package/dist/types/src/js/common/msg.d.ts +3 -0
  52. package/dist/types/src/js/common/msg.d.ts.map +1 -0
  53. package/dist/types/src/js/lit.d.ts +25 -0
  54. package/dist/types/src/js/lit.d.ts.map +1 -0
  55. package/dist/types/src/js/pds-configurator/figma-export.d.ts +13 -0
  56. package/dist/types/src/js/pds-configurator/figma-export.d.ts.map +1 -0
  57. package/dist/types/src/js/pds-configurator/pds-config-form.d.ts +2 -0
  58. package/dist/types/src/js/pds-configurator/pds-config-form.d.ts.map +1 -0
  59. package/dist/types/src/js/pds-configurator/pds-configurator.d.ts +2 -0
  60. package/dist/types/src/js/pds-configurator/pds-configurator.d.ts.map +1 -0
  61. package/dist/types/src/js/pds-configurator/pds-demo.d.ts +2 -0
  62. package/dist/types/src/js/pds-configurator/pds-demo.d.ts.map +1 -0
  63. package/dist/types/src/js/pds-core/pds-config.d.ts +758 -0
  64. package/dist/types/src/js/pds-core/pds-config.d.ts.map +1 -0
  65. package/dist/types/src/js/pds-core/pds-enhancer-metadata.d.ts +6 -0
  66. package/dist/types/src/js/pds-core/pds-enhancer-metadata.d.ts.map +1 -0
  67. package/dist/types/src/js/pds-core/pds-enhancers.d.ts +14 -0
  68. package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -0
  69. package/dist/types/src/js/pds-core/pds-enums.d.ts +87 -0
  70. package/dist/types/src/js/pds-core/pds-enums.d.ts.map +1 -0
  71. package/dist/types/src/js/pds-core/pds-generator.d.ts +741 -0
  72. package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -0
  73. package/dist/types/src/js/pds-core/pds-ontology.d.ts +48 -0
  74. package/dist/types/src/js/pds-core/pds-ontology.d.ts.map +1 -0
  75. package/dist/types/src/js/pds-core/pds-paths.d.ts +37 -0
  76. package/dist/types/src/js/pds-core/pds-paths.d.ts.map +1 -0
  77. package/dist/types/src/js/pds-core/pds-query.d.ts +102 -0
  78. package/dist/types/src/js/pds-core/pds-query.d.ts.map +1 -0
  79. package/dist/types/src/js/pds-core/pds-registry.d.ts +40 -0
  80. package/dist/types/src/js/pds-core/pds-registry.d.ts.map +1 -0
  81. package/dist/types/src/js/pds.d.ts +109 -0
  82. package/dist/types/src/js/pds.d.ts.map +1 -0
  83. package/dist/types/src/pds-core/pds-api.d.ts +31 -0
  84. package/dist/types/src/pds-core/pds-api.d.ts.map +1 -0
  85. package/package.json +104 -0
  86. package/packages/pds-cli/README.md +15 -0
  87. package/packages/pds-cli/bin/generate-css-data.js +565 -0
  88. package/packages/pds-cli/bin/generate-manifest.js +352 -0
  89. package/packages/pds-cli/bin/pds-build-icons.js +152 -0
  90. package/packages/pds-cli/bin/pds-dx.js +114 -0
  91. package/packages/pds-cli/bin/pds-static.js +556 -0
  92. package/packages/pds-cli/bin/pds.js +127 -0
  93. package/packages/pds-cli/bin/postinstall.js +380 -0
  94. package/packages/pds-cli/bin/sync-assets.js +252 -0
  95. package/packages/pds-cli/lib/asset-roots.js +47 -0
  96. package/packages/pds-cli/lib/fs-writer.js +75 -0
  97. package/pds.css-data.json +5 -0
  98. package/pds.html-data.json +5 -0
  99. package/public/assets/js/app.js +5719 -0
  100. package/public/assets/js/lit.js +131 -0
  101. package/public/assets/js/pds.js +3423 -0
  102. package/public/assets/pds/components/pds-calendar.js +837 -0
  103. package/public/assets/pds/components/pds-drawer.js +857 -0
  104. package/public/assets/pds/components/pds-icon.js +338 -0
  105. package/public/assets/pds/components/pds-jsonform.js +1775 -0
  106. package/public/assets/pds/components/pds-richtext.js +1035 -0
  107. package/public/assets/pds/components/pds-scrollrow.js +331 -0
  108. package/public/assets/pds/components/pds-splitpanel.js +401 -0
  109. package/public/assets/pds/components/pds-tabstrip.js +251 -0
  110. package/public/assets/pds/components/pds-toaster.js +446 -0
  111. package/public/assets/pds/components/pds-upload.js +657 -0
  112. package/public/assets/pds/custom-elements.json +2003 -0
  113. package/public/assets/pds/icons/pds-icons.svg +498 -0
  114. package/public/assets/pds/pds-css-complete.json +1861 -0
  115. package/public/assets/pds/pds.css-data.json +2152 -0
  116. package/public/assets/pds/vscode-custom-data.json +824 -0
  117. package/readme.md +1870 -0
  118. package/src/js/pds-core/pds-config.js +1162 -0
  119. package/src/js/pds-core/pds-enhancer-metadata.js +75 -0
  120. package/src/js/pds-core/pds-enhancers.js +357 -0
  121. package/src/js/pds-core/pds-enums.js +86 -0
  122. package/src/js/pds-core/pds-generator.js +5317 -0
  123. package/src/js/pds-core/pds-ontology.js +256 -0
  124. package/src/js/pds-core/pds-paths.js +109 -0
  125. package/src/js/pds-core/pds-query.js +571 -0
  126. package/src/js/pds-core/pds-registry.js +129 -0
  127. package/src/js/pds-core/pds.d.ts +129 -0
  128. package/src/js/pds.d.ts +408 -0
  129. package/src/js/pds.js +1579 -0
package/readme.md ADDED
@@ -0,0 +1,1870 @@
1
+ # Pure Design System (PDS)
2
+
3
+ > ⚠️ **Beta Software** - APIs are stabilizing but may still change. Pin versions in production: `"@pure-ds/core": "~0.3.0"`
4
+
5
+ [![CI](https://github.com/mvneerven/pure-ds/actions/workflows/ci.yml/badge.svg)](https://github.com/mvneerven/pure-ds/actions/workflows/ci.yml)
6
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](#license)
7
+ [![npm version](https://img.shields.io/npm/v/@pure-ds/core.svg)](https://www.npmjs.com/package/@pure-ds/core)
8
+
9
+ **Why build a design system when you can generate one?**
10
+
11
+ ![Pure Design System logo](public/assets/img/logo.png)
12
+
13
+ > A radically lightweight, fully standards-based design system for the modern web
14
+ > Everything optional. Nothing hidden. The force is within the platform.
15
+
16
+ Pure Design System generates complete, production-ready design systems from JavaScript configuration. Write your design intent once—colors, typography, spacing—and get tokens, primitives, components, and utilities automatically.
17
+
18
+ ### pds.config.js
19
+
20
+ ```javascript
21
+ export const config = {
22
+ design: {
23
+ colors: { primary: '#007acc', secondary: '#5c2d91' },
24
+ typography: { baseFontSize: 16, fontScale: 1.25 },
25
+ spatialRhythm: { baseUnit: 8, scaleRatio: 1.5 }
26
+ }
27
+ }
28
+ ```
29
+
30
+ ### app.js
31
+
32
+ ```javascript
33
+ import { PDS } from '@pure-ds/core';
34
+ import { config } from './pds.config.js';
35
+
36
+ await PDS.start(config);
37
+
38
+ // Start using components immediately
39
+ // <pds-icon icon="star"></pds-icon>
40
+ ```
41
+
42
+ **Key Features:**
43
+
44
+ - 🎨 **Configuration-Driven** - Single source of truth generates everything
45
+ - 🚀 **Live or Static** - Runtime generation or pre-built bundles
46
+ - 🎯 **Framework Agnostic** - Vanilla, Lit, React, Vue, Svelte, Next.js
47
+ - 🌐 **Web Standards** - EventTarget API, Constructable Stylesheets, Shadow DOM
48
+ - 🧩 **Progressive Enhancement** - Semantic HTML first, enhance where needed
49
+ - 🔍 **Smart Query System** - Ask questions: "what is the focus border color?"
50
+ - ♿ **Accessibility Built-in** - WCAG AA validation, contrast checking
51
+ - 🎛️ **Interactive Configurator** - Visual design tool with live preview
52
+ - 🔤 **Automatic Font Loading** - Google Fonts loaded on demand
53
+ - 📦 **Zero Build Required** - Works directly in browsers
54
+ - 📋 **Custom Elements Manifest** - Full IDE integration with autocomplete and type checking
55
+
56
+ ---
57
+
58
+ ## Table of Contents
59
+
60
+ - [What is This?](#what-is-this)
61
+ - [Who is it For?](#who-is-it-for)
62
+ - [Getting Started](#getting-started)
63
+ - [Core Architecture](#core-architecture)
64
+ - [1. Style Generation & Injection](#1-style-generation--injection)
65
+ - [2. Progressive Enhancements](#2-progressive-enhancements)
66
+ - [3. Web Components](#3-web-components)
67
+ - [Styling Layers](#styling-layers)
68
+ - [Shadow DOM Adoption](#shadow-dom-adoption)
69
+ - [Icon System](#icon-system)
70
+ - [Smart Query System](#smart-query-system)
71
+ - [Design Validation](#design-validation)
72
+ - [Advanced Features](#advanced-features)
73
+ - [API Reference](#api-reference)
74
+ - [Extending PDS](#extending-pds)
75
+ - [Using from CDN](#using-from-cdn)
76
+ - [CLI & Export](#cli--export)
77
+ - [Custom Elements Manifest](#custom-elements-manifest)
78
+ - [Framework Integration](#framework-integration)
79
+ - [Troubleshooting](#troubleshooting)
80
+ - [License](#license)
81
+
82
+ ---
83
+
84
+ ## What is This?
85
+
86
+ Pure Design System is based on the [Pure Web Manifesto](https://pureweb.dev/manifesto).
87
+
88
+ It transforms configuration into complete design systems using three integrated pillars:
89
+
90
+ ### 1. **Generated Styles** (Tokens → CSS)
91
+ Your config defines design intent. PDS generates (in a deterministic way):
92
+ - **Color scales** (50-900 shades from base colors)
93
+ - **Surface semantics** (bg, text, border, shadow, interactive states)
94
+ - **Spacing tokens** (mathematical progression)
95
+ - **Typography scales** (modular scale from base size)
96
+ - **Component primitives** (buttons, forms, cards, badges)
97
+ - **Utility classes** (layout, borders, effects)
98
+
99
+ ### 2. **Progressive Enhancements** (Lightweight DOM behaviors)
100
+ Semantic HTML gets enhanced with JavaScript:
101
+ - **Dropdowns** - `<nav data-dropdown>` auto-enhanced
102
+ - **Toggles** - `<label data-toggle>` becomes switches
103
+ - **Range sliders** - Value bubbles and visual feedback
104
+ - **Required fields** - Automatic asterisks and validation hints
105
+ - **Custom enhancements** - Extensible system for your patterns
106
+
107
+ ### 3. **Web Components** (Rich UI, lazy-loaded using [AutoDefiner](https://www.npmjs.com/package/pure-web#user-content-autodefiner))
108
+ Optional components loaded on demand:
109
+ - `<pds-icon>` - SVG sprite icons
110
+ - `<pds-drawer>` - Slide-out panels (top, bottom, lef, right)
111
+ - `<pds-tabstrip>` - Accessible tabs
112
+ - `<pds-upload>` - File upload with drag & drop and preview
113
+ - `<pds-toaster>` - Smart Toast notifications
114
+ - `<pds-richtext>` - Rich text editor (prefers `#showdown` import map; `format="markdown"` keeps Markdown values)
115
+ - `<pds-jsonform>` - Dynamic forms generated from JSON Schema
116
+ - `<pds-splitpanel>` - Resizable panes
117
+ - `<pds-scrollrow>` - Horizontal scrolling containers
118
+
119
+ ### How It Works
120
+
121
+ ```
122
+ ┌──────────────────────────────────────────────────────────────┐
123
+ │ Configuration │
124
+ │ ───────────── │
125
+ │ colors: { primary: '#007acc' } │
126
+ │ typography: { baseFontSize: 16, fontScale: 1.25 } │
127
+ │ spatialRhythm: { baseUnit: 8 } │
128
+ └─────────────────────┬────────────────────────────────────────┘
129
+
130
+
131
+ ┌──────────────────────────────────────────────────────────────┐
132
+ │ Generator (Live or Static) │
133
+ │ ────────────────────────── │
134
+ │ • Generates color scales (primary-50 → primary-900) │
135
+ │ • Creates surface tokens (bg, text, border, shadow) │
136
+ │ • Computes spacing progression (0-12) │
137
+ │ • Builds typography scale (6 levels) │
138
+ │ • Generates CSS layers (tokens → primitives → utilities) │
139
+ │ • Validates contrast ratios (WCAG AA) │
140
+ └─────────────────────┬────────────────────────────────────────┘
141
+
142
+
143
+ ┌──────────────────────────────────────────────────────────────┐
144
+ │ Output │
145
+ │ ────── │
146
+ │ Tokens: --color-primary-500, --spacing-4 │
147
+ │ Primitives: .btn-primary, .card, .badge │
148
+ │ Components: <pds-drawer>, <pds-icon> │
149
+ │ Utilities: .flex, .gap-4, .border-gradient │
150
+ └──────────────────────────────────────────────────────────────┘
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Who is it For?
156
+
157
+ ### 🎨 Design System Teams
158
+ - Generate multiple brand variants from a single codebase
159
+ - A/B test design directions by swapping configs
160
+ - Maintain consistency with centralized tokens
161
+ - Validate accessibility automatically
162
+
163
+ ### 🚀 Product Teams
164
+ - Ship faster with auto-generated primitives
165
+ - Customize with JS config instead of SASS/CSS
166
+ - Work with any framework or no framework
167
+ - Reduce bundle size with lazy-loaded components
168
+
169
+ ### 🛠️ Design Tool Builders
170
+ - Build live configurators with instant preview
171
+ - Export static bundles for production
172
+ - Query the system programmatically
173
+ - Access complete object model for introspection
174
+
175
+ ### 👩‍💻 Developers
176
+ - Learn by exploring the interactive showcase
177
+ - Adopt incrementally (tokens only → full system)
178
+ - Extend with custom enhancers and components
179
+ - Debug with structured CSS layers
180
+
181
+ ---
182
+
183
+ ## Getting Started
184
+
185
+ ### Installation
186
+
187
+ ```bash
188
+ npm install @pure-ds/core
189
+ ```
190
+
191
+ Assets (components, icons) are auto-copied to your project during install. To manually sync:
192
+
193
+ ```bash
194
+ node node_modules/@pure-ds/core/packages/pds-cli/bin/postinstall.js
195
+ ```
196
+
197
+ ### Lit Import Convention
198
+
199
+ PDS uses a virtual import for Lit so you control the resolution:
200
+
201
+ ```javascript
202
+ import { html, css, LitElement } from '#pds/lit';
203
+ ```
204
+
205
+ **In browsers (no bundler)** - Use import maps:
206
+
207
+ ```html
208
+ <script type="importmap">
209
+ {
210
+ "imports": {
211
+ "#pds/lit": "/assets/js/lit.js"
212
+ }
213
+ }
214
+ </script>
215
+ ```
216
+
217
+ **In bundlers** - Alias to the real `lit` package:
218
+
219
+ ```javascript
220
+ // vite.config.js
221
+ export default {
222
+ resolve: {
223
+ alias: { '#pds/lit': 'lit' }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ### Quick Start: Live Mode
229
+
230
+ Generate styles at runtime with instant updates:
231
+
232
+ ```javascript
233
+ import { PDS } from '@pure-ds/core';
234
+
235
+ await PDS.start({
236
+ mode: 'live',
237
+ preset: 'default', // or: ocean-breeze, midnight-steel, etc.
238
+
239
+ // Override preset values
240
+ design: {
241
+ colors: {
242
+ primary: '#007acc',
243
+ secondary: '#5c2d91'
244
+ },
245
+ typography: {
246
+ fontFamilyHeadings: 'Inter, sans-serif',
247
+ fontFamilyBody: 'Inter, sans-serif'
248
+ }
249
+ },
250
+
251
+ // Component auto-loading
252
+ autoDefine: {
253
+ predefine: ['pds-icon'] // Eagerly load these
254
+ }
255
+ });
256
+
257
+ // Use components - they'll lazy-load automatically
258
+ // <pds-drawer id="menu"></pds-drawer>
259
+ ```
260
+
261
+ ### Quick Start: Static Mode
262
+
263
+ Pre-generate assets for production:
264
+
265
+ **1. Export static files:**
266
+
267
+ ```bash
268
+ npm run pds:export
269
+ ```
270
+
271
+ This creates:
272
+ - `pds/styles/pds-*.css` and `pds-*.css.js` (Constructable Stylesheets)
273
+ - `pds/components/*.js` (Web Components)
274
+ - `pds/icons/pds-icons.svg` (Icon sprite)
275
+ - `pds/custom-elements.json` (Custom Elements Manifest for IDE integration)
276
+
277
+ **2. Initialize in static mode:**
278
+
279
+ ```javascript
280
+ import { PDS } from '@pure-ds/core';
281
+
282
+ await PDS.start({
283
+ mode: 'static',
284
+ preset: 'default',
285
+
286
+ staticPaths: {
287
+ tokens: '/pds/styles/pds-tokens.css.js',
288
+ primitives: '/pds/styles/pds-primitives.css.js',
289
+ components: '/pds/styles/pds-components.css.js',
290
+ utilities: '/pds/styles/pds-utilities.css.js',
291
+ styles: '/pds/styles/pds-styles.css.js'
292
+ },
293
+ });
294
+ ```
295
+
296
+ ### Minimal Example
297
+
298
+ ```html
299
+ <!DOCTYPE html>
300
+ <html lang="en">
301
+ <head>
302
+ <meta charset="UTF-8">
303
+ <title>PDS App</title>
304
+ <script type="importmap">
305
+ {
306
+ "imports": {
307
+ "#pds/lit": "/assets/js/lit.js"
308
+ }
309
+ }
310
+ </script>
311
+ </head>
312
+ <body>
313
+ <button class="btn-primary">
314
+ <pds-icon icon="heart"></pds-icon>
315
+ Click me
316
+ </button>
317
+
318
+ <script type="module">
319
+ import { PDS } from '/assets/js/pds.js';
320
+
321
+ await PDS.start({
322
+ design: {
323
+ colors: { primary: '#007acc' }
324
+ }
325
+ });
326
+ </script>
327
+ </body>
328
+ </html>
329
+ ```
330
+
331
+ ---
332
+
333
+ ## Core Architecture
334
+
335
+ PDS has three integrated systems that work together to create complete design systems.
336
+
337
+ ### 1. Style Generation & Injection
338
+
339
+ The heart of PDS is the **Generator** - it transforms your configuration into structured CSS.
340
+
341
+ #### Token Generation
342
+
343
+ ```javascript
344
+ // Your config
345
+ {
346
+ colors: { primary: '#007acc' },
347
+ typography: { baseFontSize: 16, fontScale: 1.25 },
348
+ spatialRhythm: { baseUnit: 8, scaleRatio: 1.5 }
349
+ }
350
+
351
+ // PDS generates tokens
352
+ --color-primary-50 → #e6f7ff
353
+ --color-primary-100 → #b3e5ff
354
+ --color-primary-200 → #80d4ff
355
+ ...
356
+ --color-primary-900 → #003d66
357
+
358
+ --spacing-0 → 0
359
+ --spacing-1 → 8px
360
+ --spacing-2 → 12px (8 × 1.5)
361
+ --spacing-3 → 18px (12 × 1.5)
362
+ ...
363
+
364
+ --font-size-xs → 0.64rem
365
+ --font-size-sm → 0.8rem
366
+ --font-size-base → 1rem
367
+ --font-size-lg → 1.25rem
368
+ --font-size-xl → 1.5625rem
369
+ ```
370
+
371
+ #### Surface Semantics
372
+
373
+ PDS generates smart surface tokens that adapt to context:
374
+
375
+ ```css
376
+ /* Light theme */
377
+ --surface-bg: var(--color-gray-50);
378
+ --surface-text: var(--color-gray-900);
379
+ --surface-text-secondary: var(--color-gray-700);
380
+ --surface-border: var(--color-gray-300);
381
+ --surface-shadow: rgba(0, 0, 0, 0.1);
382
+
383
+ /* Dark theme (auto-generated) */
384
+ [data-theme="dark"] {
385
+ --surface-bg: var(--color-gray-900);
386
+ --surface-text: var(--color-gray-50);
387
+ --surface-text-secondary: var(--color-gray-300);
388
+ --surface-border: var(--color-gray-700);
389
+ --surface-shadow: rgba(0, 0, 0, 0.5);
390
+ }
391
+ ```
392
+
393
+ #### Interactive States
394
+
395
+ Button and interactive element states are computed automatically:
396
+
397
+ ```css
398
+ /* Primary button */
399
+ --primary-fill: var(--color-primary-600);
400
+ --primary-fill-hover: var(--color-primary-700);
401
+ --primary-fill-active: var(--color-primary-800);
402
+
403
+ /* Text/outline buttons */
404
+ --primary-text: var(--color-primary-600);
405
+ --primary-text-hover: var(--color-primary-700);
406
+ ```
407
+
408
+ #### Live vs Static Mode
409
+
410
+ **Live Mode:**
411
+ - CSS generated in-browser at runtime
412
+ - Instant updates when config changes
413
+ - Perfect for design tools and configurators
414
+ - Access via `PDS.compiled` object model
415
+ - Automatic font loading from Google Fonts
416
+
417
+ **Static Mode:**
418
+ - CSS pre-generated at build time
419
+ - Optimized for production performance
420
+ - Host anywhere (CDN, static server)
421
+ - Constructable Stylesheets for instant adoption
422
+ - No runtime overhead
423
+
424
+ ### 2. Progressive Enhancements
425
+
426
+ Lightweight JavaScript behaviors applied to semantic HTML. These are **not Web Components** - just DOM enhancements that make standard HTML more interactive.
427
+
428
+ #### Built-in Enhancers
429
+
430
+ **Dropdown Menus** - `<nav data-dropdown>`
431
+
432
+ ```html
433
+ <nav data-dropdown>
434
+ <button>Menu</button>
435
+ <menu>
436
+ <li><a href="#home">Home</a></li>
437
+ <li><a href="#about">About</a></li>
438
+ <li><a href="#contact">Contact</a></li>
439
+ </menu>
440
+ </nav>
441
+ ```
442
+
443
+ Features:
444
+ - Click to toggle visibility
445
+ - Auto-positioning (up/down based on space)
446
+ - Horizontal alignment (`.align-right` class)
447
+ - Keyboard support (Escape to close)
448
+ - Click-outside to close
449
+ - Scrollable when content exceeds viewport
450
+
451
+ **Toggle Switches** - `<label data-toggle>`
452
+
453
+ ```html
454
+ <label data-toggle>
455
+ <span data-label>Enable notifications</span>
456
+ <input type="checkbox">
457
+ </label>
458
+ ```
459
+
460
+ Creates styled toggle switches from standard checkboxes.
461
+
462
+ **Range Sliders** - `<input type="range">`
463
+
464
+ ```html
465
+ <!-- Standard mode: floating bubble on interaction -->
466
+ <label>
467
+ <span>Volume</span>
468
+ <input type="range" min="0" max="100" value="50">
469
+ </label>
470
+
471
+ <!-- Inline output mode: persistent value display -->
472
+ <label class="range-output">
473
+ <span>Volume</span>
474
+ <input type="range" min="0" max="100" value="50">
475
+ </label>
476
+ ```
477
+
478
+ Enhances range inputs with automatic value display. Use `range-output` class for inline output with semantic `<output>` element.
479
+
480
+ **Required Field Indicators** - `form [required]`
481
+
482
+ ```html
483
+ <label>
484
+ <span>Email</span>
485
+ <input type="email" required>
486
+ </label>
487
+ ```
488
+
489
+ Automatically adds asterisk to label.
490
+
491
+ #### Custom Enhancers
492
+
493
+ Add your own progressive enhancements:
494
+
495
+ ```javascript
496
+ await PDS.start({
497
+ enhancers: [
498
+ {
499
+ selector: '[data-tooltip]',
500
+ description: 'Adds tooltip on hover',
501
+ run: (element) => {
502
+ const text = element.dataset.tooltip;
503
+ element.addEventListener('mouseenter', () => {
504
+ // Show tooltip
505
+ });
506
+ }
507
+ },
508
+ {
509
+ selector: '[data-copy]',
510
+ description: 'Copy text to clipboard on click',
511
+ run: (element) => {
512
+ element.addEventListener('click', () => {
513
+ navigator.clipboard.writeText(element.dataset.copy);
514
+ });
515
+ }
516
+ }
517
+ ]
518
+ });
519
+ ```
520
+
521
+ ### 3. Web Components
522
+
523
+ Rich, reusable UI components built with Lit. Lazy-loaded automatically via the **Auto-Define** system.
524
+
525
+ #### Available Components
526
+
527
+ **`<pds-icon>`** - SVG sprite icons
528
+ ```html
529
+ <pds-icon icon="heart"></pds-icon>
530
+ <pds-icon icon="star" size="lg"></pds-icon>
531
+ <pds-icon icon="list" size="32" color="red"></pds-icon>
532
+ <pds-icon icon="info" label="Information"></pds-icon>
533
+ ```
534
+
535
+ Attributes:
536
+ - `icon` - Symbol ID (required)
537
+ - `size` - Named size (xs/sm/md/lg/xl/2xl) or pixel value
538
+ - `color` - CSS color (defaults to currentColor)
539
+ - `label` - Accessible name (makes icon `role="img"`)
540
+
541
+ **`<pds-drawer>`** - Slide-out panels
542
+ ```html
543
+ <pds-drawer id="menu" position="left">
544
+ <h2 slot="header">Menu</h2>
545
+ <nav>...</nav>
546
+ </pds-drawer>
547
+
548
+ <button onclick="document.getElementById('menu').open()">
549
+ Open Menu
550
+ </button>
551
+ ```
552
+
553
+ Attributes:
554
+ - `position` - left/right/top/bottom
555
+ - `open` - Boolean, controls visibility
556
+
557
+ Methods:
558
+ - `open()` - Show drawer
559
+ - `close()` - Hide drawer
560
+ - `toggle()` - Toggle visibility
561
+
562
+ **`<pds-tabstrip>`** - Accessible tab interface
563
+ ```html
564
+ <pds-tabstrip>
565
+ <button slot="tab">Overview</button>
566
+ <div slot="panel">Overview content</div>
567
+
568
+ <button slot="tab">Details</button>
569
+ <div slot="panel">Details content</div>
570
+ </pds-tabstrip>
571
+ ```
572
+
573
+ Features:
574
+ - Keyboard navigation (Arrow keys, Home, End)
575
+ - ARIA attributes automatic
576
+ - Focus management
577
+ - URL hash sync (optional)
578
+
579
+ **`<pds-upload>`** - File upload with preview
580
+ ```html
581
+ <pds-upload
582
+ accept="image/*"
583
+ multiple
584
+ max-size="5000000">
585
+ </pds-upload>
586
+ ```
587
+
588
+ Attributes:
589
+ - `accept` - File types (MIME or extensions)
590
+ - `multiple` - Allow multiple files
591
+ - `max-size` - Max file size in bytes
592
+ - `max-files` - Max number of files
593
+
594
+ Events:
595
+ - `files-changed` - Fired when selection changes
596
+ - `file-error` - Fired on validation errors
597
+
598
+ **`<pds-toaster>`** - Toast notifications
599
+ ```html
600
+ <pds-toaster id="toaster"></pds-toaster>
601
+
602
+ <script>
603
+ const toaster = document.getElementById('toaster');
604
+ toaster.show({
605
+ message: 'Saved successfully!',
606
+ type: 'success',
607
+ duration: 3000
608
+ });
609
+ </script>
610
+ ```
611
+
612
+ Or use via events:
613
+ ```javascript
614
+ PDS.dispatchEvent(new CustomEvent('pds:toast', {
615
+ detail: {
616
+ message: 'Error occurred',
617
+ type: 'danger',
618
+ duration: 5000
619
+ }
620
+ }));
621
+ ```
622
+
623
+ **`<pds-richtext>`** - Rich text editor
624
+ ```html
625
+ <script type="importmap">
626
+ {
627
+ "imports": {
628
+ "#showdown": "https://cdn.jsdelivr.net/npm/showdown@2.1.0/dist/showdown.mjs"
629
+ }
630
+ }
631
+ </script>
632
+
633
+ <pds-richtext
634
+ value="<p>Initial content</p>"
635
+ format="html">
636
+ </pds-richtext>
637
+ ```
638
+
639
+ Set `format="markdown"` when you want the submitted form value to stay in Markdown:
640
+ ```html
641
+ <pds-richtext name="release-notes" format="markdown"></pds-richtext>
642
+ ```
643
+ The element will use the `#showdown` import-map specifier first, and will only fall back to loading the script from CDNs if that specifier is missing.
644
+
645
+ Features:
646
+ - Bold, italic, underline, strikethrough
647
+ - Headings, lists, links
648
+ - Code blocks
649
+ - Undo/redo
650
+ - Markdown shortcuts
651
+
652
+ **`<pds-jsonform>`** - Dynamic forms from JSON Schema
653
+ ```html
654
+ <pds-jsonform schema='{"type":"object","properties":{...}}'></pds-jsonform>
655
+ ```
656
+
657
+ Generates complete forms with validation from JSON Schema.
658
+
659
+ **`<pds-splitpanel>`** - Resizable panes
660
+ ```html
661
+ <pds-splitpanel orientation="horizontal">
662
+ <div slot="start">Left pane</div>
663
+ <div slot="end">Right pane</div>
664
+ </pds-splitpanel>
665
+ ```
666
+
667
+ **`<pds-scrollrow>`** - Horizontal scrolling container
668
+ ```html
669
+ <pds-scrollrow>
670
+ <div class="card">Card 1</div>
671
+ <div class="card">Card 2</div>
672
+ <div class="card">Card 3</div>
673
+ </pds-scrollrow>
674
+ ```
675
+
676
+ Shows scroll buttons when content overflows.
677
+
678
+ #### Auto-Define System
679
+
680
+ Components are registered automatically when their tags appear in the DOM:
681
+
682
+ ```javascript
683
+ await PDS.start({
684
+ autoDefine: {
685
+ baseURL: '/auto-define/',
686
+
687
+ // Eagerly load these components
688
+ predefine: ['pds-icon', 'pds-drawer'],
689
+
690
+ // Custom file mapping
691
+ mapper: (tag) => {
692
+ if (tag.startsWith('my-')) {
693
+ return `/components/${tag}.js`;
694
+ }
695
+ // Return nothing to use PDS default mapping
696
+ },
697
+
698
+ // Advanced options
699
+ scanExisting: true, // Scan for tags on init
700
+ observeShadows: true, // Watch Shadow DOM
701
+ patchAttachShadow: true, // Monitor dynamic shadows
702
+ debounceMs: 16 // Debounce observation
703
+ }
704
+ });
705
+ ```
706
+
707
+ The system:
708
+ 1. Observes DOM for new custom elements
709
+ 2. Checks if tag is defined
710
+ 3. Loads corresponding module
711
+ 4. Registers custom element
712
+ 5. Upgrades existing instances
713
+
714
+ > ⚠️ **Important: Programmatic Access to Auto-Defined Components**
715
+ >
716
+ > Components loaded via `autoDefine` are registered asynchronously. If you need to access component methods or properties programmatically (e.g., `toaster.toast()`), ensure the component is defined first:
717
+ >
718
+ > ```javascript
719
+ > // Wait for component to be defined
720
+ > await customElements.whenDefined('pds-toaster');
721
+ > const toaster = document.querySelector('pds-toaster');
722
+ > toaster.toast('Hello!');
723
+ > ```
724
+ >
725
+ > **Alternative:** Use `predefine` to eagerly load components at `PDS.start()` time:
726
+ >
727
+ > ```javascript
728
+ > await PDS.start({
729
+ > autoDefine: {
730
+ > predefine: ['pds-toaster', 'pds-icon'] // Loaded immediately
731
+ > }
732
+ > });
733
+ > // Components are now available synchronously
734
+ > ```
735
+
736
+ ---
737
+
738
+ ## Styling Layers
739
+
740
+ PDS generates CSS in structured layers for predictable specificity and modularity.
741
+
742
+ ### Layer Structure
743
+
744
+ ```
745
+ ┌──────────────────────────────────────────────────────────┐
746
+ │ tokens CSS Custom Properties │
747
+ │ --color-*, --spacing-*, --font-* │
748
+ ├──────────────────────────────────────────────────────────┤
749
+ │ primitives Base elements │
750
+ │ button, input, .card, .badge │
751
+ ├──────────────────────────────────────────────────────────┤
752
+ │ components Rich UI │
753
+ │ .drawer, .tabstrip, .upload │
754
+ ├──────────────────────────────────────────────────────────┤
755
+ │ utilities Composable helpers │
756
+ │ .flex, .gap-4, .border-gradient │
757
+ └──────────────────────────────────────────────────────────┘
758
+ ```
759
+
760
+ ### Layer Details
761
+
762
+ **Tokens** - Design foundation
763
+ - Colors (scales + semantics)
764
+ - Spacing (0-12 progression)
765
+ - Typography (families, sizes, weights)
766
+ - Borders (widths, radius)
767
+ - Shadows (depths)
768
+ - Transitions (speeds)
769
+ - Z-index (layers)
770
+ - Layout (breakpoints, max-width)
771
+
772
+ **Primitives** - Native elements enhanced
773
+ - Buttons (`.btn-primary`, `.btn-secondary`, `.btn-outline`)
774
+ - Forms (`input`, `select`, `textarea`, `fieldset`)
775
+ - Surfaces (`.card`, `.surface`)
776
+ - Badges (`.badge`, `.badge-success`)
777
+ - Alerts (`.alert`, `.alert-warning`)
778
+ - Typography (headings, paragraphs, lists)
779
+ - Tables (responsive, striped)
780
+
781
+ **Components** - Web Component styles
782
+ - Styles for `<pds-*>` elements
783
+ - Internal component structure
784
+ - State management (`:state()` selectors)
785
+
786
+ **Utilities** - Layout and effects
787
+ - Flex (`.flex`, `.flex-col`, `.items-center`)
788
+ - Grid (`.grid`, `.grid-cols-3`)
789
+ - Spacing (`.gap-4`, `.p-4`, `.m-2`)
790
+ - Borders (`.border`, `.border-gradient`, `.border-glow`)
791
+ - Effects (`.shadow-lg`, `.rounded-lg`)
792
+
793
+ ### Accessing Layers
794
+
795
+ **In live mode:**
796
+ ```javascript
797
+ const compiled = PDS.compiled;
798
+
799
+ // Get layer CSS
800
+ const tokensCSS = compiled.layers.tokens.css;
801
+ const primitivesCSS = compiled.layers.primitives.css;
802
+
803
+ // Get as stylesheet
804
+ const sheet = await PDS.registry.getStylesheet('primitives');
805
+ ```
806
+
807
+ **In static mode:**
808
+ ```javascript
809
+ // Import constructable stylesheets
810
+ import tokensSheet from '/pds/styles/pds-tokens.css.js';
811
+ import primitivesSheet from '/pds/styles/pds-primitives.css.js';
812
+ ```
813
+
814
+ ---
815
+
816
+ ## Shadow DOM Adoption
817
+
818
+ PDS provides helpers for adopting styles into Shadow DOM.
819
+
820
+ ### Basic Adoption
821
+
822
+ ```javascript
823
+ class MyComponent extends HTMLElement {
824
+ constructor() {
825
+ super();
826
+ this.attachShadow({ mode: 'open' });
827
+ }
828
+
829
+ async connectedCallback() {
830
+ // Adopt just primitives (most common)
831
+ await PDS.adoptPrimitives(this.shadowRoot);
832
+
833
+ this.shadowRoot.innerHTML = `
834
+ <button class="btn-primary">Click me</button>
835
+ `;
836
+ }
837
+ }
838
+ ```
839
+
840
+ ### Multiple Layers
841
+
842
+ ```javascript
843
+ // Adopt specific layers
844
+ await PDS.adoptLayers(this.shadowRoot, ['primitives', 'components']);
845
+
846
+ // Adopt with custom styles
847
+ const myStyles = PDS.createStylesheet(`
848
+ :host {
849
+ display: block;
850
+ padding: var(--spacing-4);
851
+ }
852
+ `);
853
+
854
+ await PDS.adoptLayers(this.shadowRoot, ['primitives'], [myStyles]);
855
+ ```
856
+
857
+ ### Lit Component Example
858
+
859
+ ```javascript
860
+ import { html, css, LitElement } from '#pds/lit';
861
+
862
+ class MyCard extends LitElement {
863
+ static styles = css`
864
+ :host {
865
+ display: block;
866
+ }
867
+ `;
868
+
869
+ async connectedCallback() {
870
+ super.connectedCallback();
871
+ await PDS.adoptPrimitives(this.shadowRoot);
872
+ }
873
+
874
+ render() {
875
+ return html`
876
+ <article class="card">
877
+ <h3>Card Title</h3>
878
+ <p>Card content</p>
879
+ <button class="btn-primary">Action</button>
880
+ </article>
881
+ `;
882
+ }
883
+ }
884
+ ```
885
+
886
+ ---
887
+
888
+ ## Icon System
889
+
890
+ PDS uses SVG sprites for efficient icon rendering.
891
+
892
+ ### Icon Component
893
+
894
+ ```html
895
+ <!-- Basic usage -->
896
+ <pds-icon icon="heart"></pds-icon>
897
+
898
+ <!-- Sized icons -->
899
+ <pds-icon icon="star" size="sm"></pds-icon>
900
+ <pds-icon icon="star" size="lg"></pds-icon>
901
+ <pds-icon icon="star" size="32"></pds-icon>
902
+
903
+ <!-- Colored icons -->
904
+ <pds-icon icon="warning" color="red"></pds-icon>
905
+ <pds-icon icon="info" color="var(--color-primary-500)"></pds-icon>
906
+
907
+ <!-- Accessible icons -->
908
+ <pds-icon icon="list" label="Open navigation menu"></pds-icon>
909
+ ```
910
+
911
+ ### Configuration
912
+
913
+ ```javascript
914
+ await PDS.start({
915
+ design: {
916
+ icons: {
917
+ set: 'phosphor', // Icon family
918
+ weight: 'regular', // Icon weight
919
+ defaultSize: 24, // Default size in pixels
920
+ sizes: { // Named sizes
921
+ xs: 16,
922
+ sm: 20,
923
+ md: 24,
924
+ lg: 32,
925
+ xl: 48,
926
+ '2xl': 64
927
+ },
928
+ spritePath: '/assets/pds/icons/pds-icons.svg'
929
+ }
930
+ }
931
+ });
932
+ ```
933
+
934
+ ### Custom Icons
935
+
936
+ Add custom icons to the sprite:
937
+
938
+ **1. Configure custom icons:**
939
+ ```javascript
940
+ // pds.config.js
941
+ export default {
942
+ design: {
943
+ icons: {
944
+ set: 'phosphor',
945
+ include: [
946
+ 'house', 'gear', 'heart', 'star',
947
+ 'user', 'bell', 'search', 'menu'
948
+ ]
949
+ }
950
+ }
951
+ };
952
+ ```
953
+
954
+ **2. Rebuild sprite:**
955
+ ```bash
956
+ npm run pds:build-icons
957
+ ```
958
+
959
+ **3. Use in your app:**
960
+ ```html
961
+ <pds-icon icon="house"></pds-icon>
962
+ ```
963
+
964
+ ### Icon Tokens
965
+
966
+ Icons are available as CSS custom properties:
967
+
968
+ ```css
969
+ --icon-set: phosphor;
970
+ --icon-weight: regular;
971
+ --icon-size-xs: 16px;
972
+ --icon-size-sm: 20px;
973
+ --icon-size-md: 24px;
974
+ --icon-size-lg: 32px;
975
+ ```
976
+
977
+ ---
978
+
979
+ ## Smart Query System
980
+
981
+ Ask questions about your design system using natural language.
982
+
983
+ ### Usage
984
+
985
+ ```javascript
986
+ // Programmatic API
987
+ const results = await PDS.query("what is the focus border color on inputs?");
988
+
989
+ results.forEach(result => {
990
+ console.log(result.text); // "Focus border color: var(--color-primary-500)"
991
+ console.log(result.category); // "Color Token"
992
+ console.log(result.cssVar); // "var(--color-primary-500)"
993
+ console.log(result.code); // Example code
994
+ });
995
+ ```
996
+
997
+ ### Example Queries
998
+
999
+ **Color Questions:**
1000
+ ```javascript
1001
+ await PDS.query("what is the focus border color on inputs?")
1002
+ await PDS.query("what foreground color should I use on this surface?")
1003
+ await PDS.query("button hover color")
1004
+ await PDS.query("primary color scale")
1005
+ ```
1006
+
1007
+ **Utility Questions:**
1008
+ ```javascript
1009
+ await PDS.query("what are the utility classes for borders?")
1010
+ await PDS.query("border gradient effect")
1011
+ await PDS.query("flex layout utilities")
1012
+ await PDS.query("gap between elements")
1013
+ ```
1014
+
1015
+ **Component Questions:**
1016
+ ```javascript
1017
+ await PDS.query("how do I create an icon-only button?")
1018
+ await PDS.query("drawer component")
1019
+ await PDS.query("tab strip usage")
1020
+ ```
1021
+
1022
+ **Layout Questions:**
1023
+ ```javascript
1024
+ await PDS.query("how can I group stuff in containers?")
1025
+ await PDS.query("grid container")
1026
+ await PDS.query("card component")
1027
+ ```
1028
+
1029
+ ### AutoComplete Integration
1030
+
1031
+ The query system integrates with `#pds-search` in the configurator. Type queries directly in the search box for instant answers.
1032
+
1033
+ ### How It Works
1034
+
1035
+ 1. **Intent Detection** - Recognizes what you're asking about (color, spacing, component, utility)
1036
+ 2. **Entity Recognition** - Identifies design elements (button, input, surface)
1037
+ 3. **Context Analysis** - Detects states (hover, focus, active)
1038
+ 4. **Data Querying** - Searches `PDS.compiled`, `PDS.ontology`, `PDS.currentConfig`
1039
+ 5. **Scoring & Ranking** - Returns top 10 most relevant results
1040
+
1041
+ See [PDS-QUERY-SYSTEM.md](./PDS-QUERY-SYSTEM.md) for detailed documentation.
1042
+
1043
+ ---
1044
+
1045
+ ## Design Validation
1046
+
1047
+ PDS automatically validates designs for accessibility issues.
1048
+
1049
+ ### Automatic Validation
1050
+
1051
+ In live mode with presets enabled:
1052
+
1053
+ ```bash
1054
+ npm run build
1055
+ ```
1056
+
1057
+ Validates all presets during build and reports issues:
1058
+
1059
+ ```
1060
+ ❌ Preset validation failed:
1061
+
1062
+ — Travel Market
1063
+ • Primary text on surface is too low (3.95 < 4.5)
1064
+ [light/outline] (/colors/primary)
1065
+
1066
+ — Mobility App
1067
+ • Primary button contrast too low in dark theme (2.85 < 4.5)
1068
+ [dark/btn-primary] (/colors/darkMode/primary)
1069
+ ```
1070
+
1071
+ ### Manual Validation
1072
+
1073
+ ```javascript
1074
+ const result = PDS.validateDesign({
1075
+ colors: {
1076
+ primary: '#007acc',
1077
+ background: '#ffffff'
1078
+ }
1079
+ }, {
1080
+ minContrast: 4.5 // WCAG AA standard
1081
+ });
1082
+
1083
+ if (!result.ok) {
1084
+ console.table(result.issues);
1085
+ // [
1086
+ // {
1087
+ // path: '/colors/primary',
1088
+ // message: 'Primary button contrast too low...',
1089
+ // ratio: 3.2,
1090
+ // min: 4.5,
1091
+ // context: 'light/btn-primary'
1092
+ // }
1093
+ // ]
1094
+ }
1095
+ ```
1096
+
1097
+ ### Batch Validation
1098
+
1099
+ ```javascript
1100
+ const results = PDS.validateDesigns([
1101
+ { name: 'Light', config: {...} },
1102
+ { name: 'Dark', config: {...} }
1103
+ ], {
1104
+ minContrast: 4.5
1105
+ });
1106
+
1107
+ results.forEach(({ name, ok, issues }) => {
1108
+ if (!ok) {
1109
+ console.log(`${name} has ${issues.length} issues`);
1110
+ }
1111
+ });
1112
+ ```
1113
+
1114
+ ### Validation Checks
1115
+
1116
+ - **Primary Button (Light)** - Button fill vs white text
1117
+ - **Primary Button (Dark)** - Button fill vs white text in dark mode
1118
+ - **Surface Text (Light)** - Text color vs surface background
1119
+ - **Primary Links/Outline (Light)** - Primary text vs surface
1120
+ - **Surface Text (Dark)** - Text color vs dark surface
1121
+
1122
+ All checks verify WCAG AA minimum contrast ratio (4.5:1 default).
1123
+
1124
+ ---
1125
+
1126
+ ## Advanced Features
1127
+
1128
+ ### Automatic Font Loading
1129
+
1130
+ In live mode, PDS automatically loads fonts from Google Fonts when they're not available locally.
1131
+
1132
+ ```javascript
1133
+ await PDS.start({
1134
+ mode: 'live',
1135
+ design: {
1136
+ typography: {
1137
+ fontFamilyHeadings: 'Inter, sans-serif',
1138
+ fontFamilyBody: 'Inter, sans-serif',
1139
+ fontFamilyMono: 'Fira Code, monospace'
1140
+ }
1141
+ }
1142
+ });
1143
+
1144
+ // Fonts are automatically loaded from Google Fonts if needed
1145
+ ```
1146
+
1147
+ **Features:**
1148
+ - Smart detection (skips system fonts)
1149
+ - Parallel loading for performance
1150
+ - Font weights: 400, 500, 600, 700
1151
+ - `font-display: swap` for better UX
1152
+ - 5-second timeout prevents hanging
1153
+
1154
+ **Manual loading:**
1155
+ ```javascript
1156
+ import { loadGoogleFont } from '@pure-ds/core/common/font-loader';
1157
+
1158
+ await loadGoogleFont('Roboto', {
1159
+ weights: [400, 500, 700],
1160
+ italic: true
1161
+ });
1162
+ ```
1163
+
1164
+ ### Event Bus
1165
+
1166
+ PDS is an EventTarget - listen for system events:
1167
+
1168
+ ```javascript
1169
+ // System ready
1170
+ PDS.addEventListener('pds:ready', (e) => {
1171
+ console.log('PDS ready:', e.detail.mode);
1172
+ });
1173
+
1174
+ // Theme changed
1175
+ PDS.addEventListener('pds:theme:changed', (e) => {
1176
+ console.log('Theme:', e.detail.theme);
1177
+ });
1178
+
1179
+ // Design updated (configurator)
1180
+ PDS.addEventListener('pds:design:updated', (e) => {
1181
+ console.log('New config:', e.detail.config);
1182
+ });
1183
+
1184
+ // Error handling
1185
+ PDS.addEventListener('pds:error', (e) => {
1186
+ console.error('PDS error:', e.detail.error);
1187
+ });
1188
+ ```
1189
+
1190
+ **Available events:**
1191
+ - `pds:ready` - System initialized
1192
+ - `pds:error` - Error occurred
1193
+ - `pds:theme:changed` - Theme switched
1194
+ - `pds:design:updated` - Config changed
1195
+ - `pds:design:field:changed` - Single field updated
1196
+ - `pds:inspector:mode:changed` - Inspector toggled
1197
+ - `pds:inspector:deactivate` - Inspector close requested
1198
+ - `pds:docs:view` - Documentation view requested
1199
+ - `pds:toast` - Toast notification triggered
1200
+
1201
+ ### Theme Management
1202
+
1203
+ ```javascript
1204
+ // Get current theme
1205
+ const theme = PDS.theme; // 'light' | 'dark' | 'system' | null
1206
+
1207
+ // Set theme
1208
+ PDS.theme = 'dark';
1209
+ PDS.theme = 'system'; // Follows OS preference
1210
+ PDS.theme = null; // Remove preference
1211
+
1212
+ // Or use method
1213
+ await PDS.setTheme('dark');
1214
+ ```
1215
+
1216
+ Theme is stored in localStorage and updates `html[data-theme]` automatically.
1217
+
1218
+ ### Compiled Object Model
1219
+
1220
+ In live mode, access the complete generated system:
1221
+
1222
+ ```javascript
1223
+ const compiled = PDS.compiled;
1224
+
1225
+ // Tokens
1226
+ compiled.tokens.colors.primary[500];
1227
+ compiled.tokens.spacing[4];
1228
+ compiled.tokens.typography.fontFamily.body;
1229
+
1230
+ // Layers
1231
+ compiled.layers.tokens.css;
1232
+ compiled.layers.primitives.css;
1233
+
1234
+ // Metadata
1235
+ compiled.meta.generatedAt;
1236
+ compiled.meta.totalSize;
1237
+ compiled.meta.tokenGroups;
1238
+
1239
+ // Helpers
1240
+ compiled.helpers.getColorScales();
1241
+ compiled.helpers.getColorScale('primary');
1242
+ compiled.helpers.getSpacingValues();
1243
+ ```
1244
+
1245
+ ### Presets
1246
+
1247
+ Choose from built-in presets:
1248
+
1249
+ ```javascript
1250
+ // View available presets
1251
+ Object.keys(PDS.presets);
1252
+ // ['default', 'ocean-breeze', 'midnight-steel', ...]
1253
+
1254
+ // Use a preset
1255
+ await PDS.start({
1256
+ preset: 'ocean-breeze',
1257
+ design: {
1258
+ // Override specific values
1259
+ colors: { primary: '#custom' }
1260
+ }
1261
+ });
1262
+
1263
+ // Access preset config
1264
+ const preset = PDS.presets['ocean-breeze'];
1265
+ console.log(preset.colors.primary);
1266
+ ```
1267
+
1268
+ **Available presets:**
1269
+ - `default` - Clean, modern baseline
1270
+ - `ocean-breeze` - Cool blues and teals
1271
+ - `midnight-steel` - Dark, professional
1272
+ - `sunset-vibes` - Warm oranges and purples
1273
+ - `forest-calm` - Natural greens
1274
+ - `lavender-dream` - Soft purples
1275
+ - `coral-energy` - Vibrant pinks and oranges
1276
+ - `arctic-frost` - Cool grays and blues
1277
+ - `golden-hour` - Warm yellows and golds
1278
+ - `neon-city` - Bright, high-contrast
1279
+ - `travel-market` - Earthy, adventurous
1280
+ - `mobility-app` - Tech-forward transportation
1281
+
1282
+ ---
1283
+
1284
+ ## API Reference
1285
+
1286
+ ### PDS.start(config)
1287
+
1288
+ Main initialization method.
1289
+
1290
+ ```typescript
1291
+ await PDS.start({
1292
+ // Mode
1293
+ mode?: 'live' | 'static' = 'live',
1294
+
1295
+ // Design configuration
1296
+ preset?: string,
1297
+ design?: {
1298
+ colors?: {...},
1299
+ typography?: {...},
1300
+ spatialRhythm?: {...},
1301
+ shape?: {...},
1302
+ behavior?: {...},
1303
+ layout?: {...},
1304
+ layers?: {...},
1305
+ icons?: {...}
1306
+ },
1307
+
1308
+ // Static mode paths
1309
+ staticPaths?: {
1310
+ tokens?: string,
1311
+ primitives?: string,
1312
+ components?: string,
1313
+ utilities?: string,
1314
+ styles?: string
1315
+ },
1316
+
1317
+ // Component loading
1318
+ autoDefine?: {
1319
+ baseURL?: string,
1320
+ predefine?: string[],
1321
+ mapper?: (tag: string) => string | void,
1322
+ scanExisting?: boolean,
1323
+ observeShadows?: boolean,
1324
+ patchAttachShadow?: boolean,
1325
+ debounceMs?: number
1326
+ },
1327
+
1328
+ // Progressive enhancements
1329
+ enhancers?: Array<{
1330
+ selector: string,
1331
+ description?: string,
1332
+ run: (element: Element) => void
1333
+ }>,
1334
+
1335
+ // Runtime options
1336
+ applyGlobalStyles?: boolean = false,
1337
+ manageTheme?: boolean = false,
1338
+ themeStorageKey?: string = 'pure-ds-theme',
1339
+ preloadStyles?: boolean = false,
1340
+ criticalLayers?: string[] = ['tokens', 'primitives']
1341
+ });
1342
+ ```
1343
+
1344
+ ### PDS.query(question)
1345
+
1346
+ Smart query interface.
1347
+
1348
+ ```typescript
1349
+ const results = await PDS.query(question: string);
1350
+ // Returns array of results with text, value, icon, category, etc.
1351
+ ```
1352
+
1353
+ ### PDS.validateDesign(config, options)
1354
+
1355
+ Validate design for accessibility.
1356
+
1357
+ ```typescript
1358
+ const result = PDS.validateDesign(config, { minContrast: 4.5 });
1359
+ // Returns: { ok: boolean, issues: Array }
1360
+ ```
1361
+
1362
+ ### PDS.adoptLayers(shadowRoot, layers, additionalSheets)
1363
+
1364
+ Adopt stylesheets into Shadow DOM.
1365
+
1366
+ ```typescript
1367
+ await PDS.adoptLayers(shadowRoot, ['primitives'], [customSheet]);
1368
+ ```
1369
+
1370
+ ### PDS.adoptPrimitives(shadowRoot, additionalSheets)
1371
+
1372
+ Adopt primitives layer (convenience method).
1373
+
1374
+ ### PDS.createStylesheet(css)
1375
+
1376
+ Create constructable stylesheet from CSS string.
1377
+
1378
+ ### PDS.setTheme(theme)
1379
+
1380
+ Change theme programmatically.
1381
+
1382
+ ### PDS Properties
1383
+
1384
+ ```typescript
1385
+ PDS.Generator // Generator class
1386
+ PDS.registry // Runtime registry
1387
+ PDS.ontology // Design system metadata
1388
+ PDS.presets // Built-in presets
1389
+ PDS.enums // Enumeration values
1390
+ PDS.currentConfig // Current configuration (read-only)
1391
+ PDS.compiled // Compiled state (live mode only)
1392
+ PDS.theme // Current theme (getter/setter)
1393
+ PDS.defaultEnhancers // Built-in enhancements
1394
+ ```
1395
+
1396
+ ---
1397
+
1398
+ ## Extending PDS
1399
+
1400
+ ### Custom Enhancers
1401
+
1402
+ ```javascript
1403
+ await PDS.start({
1404
+ enhancers: [
1405
+ {
1406
+ selector: '[data-animate-in]',
1407
+ description: 'Animate elements as they enter viewport',
1408
+ run: (element) => {
1409
+ const observer = new IntersectionObserver((entries) => {
1410
+ entries.forEach(entry => {
1411
+ if (entry.isIntersecting) {
1412
+ element.classList.add('animated');
1413
+ observer.unobserve(element);
1414
+ }
1415
+ });
1416
+ });
1417
+ observer.observe(element);
1418
+ }
1419
+ }
1420
+ ]
1421
+ });
1422
+ ```
1423
+
1424
+ ### Custom Components
1425
+
1426
+ ```javascript
1427
+ await PDS.start({
1428
+ autoDefine: {
1429
+ mapper: (tag) => {
1430
+ if (tag.startsWith('my-')) {
1431
+ return `/components/${tag}.js`;
1432
+ }
1433
+ // Let PDS handle pds-* components
1434
+ }
1435
+ }
1436
+ });
1437
+ ```
1438
+
1439
+ ### Custom Presets
1440
+
1441
+ ```javascript
1442
+ export const myPreset = {
1443
+ id: 'my-brand',
1444
+ name: 'My Brand Theme',
1445
+ colors: { primary: '#007acc', secondary: '#5c2d91' },
1446
+ typography: { fontFamilyHeadings: 'Montserrat' }
1447
+ };
1448
+
1449
+ await PDS.start({ design: myPreset });
1450
+ ```
1451
+
1452
+ ---
1453
+
1454
+ ## Using from CDN
1455
+
1456
+ ```html
1457
+ <!DOCTYPE html>
1458
+ <html lang="en">
1459
+ <head>
1460
+ <script type="importmap">
1461
+ {
1462
+ "imports": {
1463
+ "#pds/lit": "https://cdn.jsdelivr.net/npm/lit@3/index.js"
1464
+ }
1465
+ }
1466
+ </script>
1467
+ </head>
1468
+ <body>
1469
+ <button class="btn-primary">Click me</button>
1470
+
1471
+ <script type="module">
1472
+ import { PDS } from 'https://cdn.jsdelivr.net/npm/@pure-ds/core@latest/public/assets/js/pds.js';
1473
+
1474
+ await PDS.start({
1475
+ mode: 'static',
1476
+ staticPaths: {
1477
+ tokens: 'https://cdn.jsdelivr.net/npm/@pure-ds/core@latest/public/assets/pds/styles/pds-tokens.css.js',
1478
+ primitives: 'https://cdn.jsdelivr.net/npm/@pure-ds/core@latest/public/assets/pds/styles/pds-primitives.css.js',
1479
+ utilities: 'https://cdn.jsdelivr.net/npm/@pure-ds/core@latest/public/assets/pds/styles/pds-utilities.css.js'
1480
+ },
1481
+ autoDefine: {
1482
+ baseURL: 'https://cdn.jsdelivr.net/npm/@pure-ds/core@latest/public/assets/pds/components/'
1483
+ },
1484
+ applyGlobalStyles: true
1485
+ });
1486
+ </script>
1487
+ </body>
1488
+ </html>
1489
+ ```
1490
+
1491
+ ---
1492
+
1493
+ ## CLI & Export
1494
+
1495
+ ### Available Scripts
1496
+
1497
+ | Script | Description |
1498
+ |--------|-------------|
1499
+ | `npm run pds:export` | Full export: styles, components, icons, and IntelliSense data |
1500
+ | `npm run pds:dx` | Generate all IntelliSense data (HTML + CSS) |
1501
+ | `npm run pds:manifest` | Generate HTML IntelliSense (Custom Elements Manifest) |
1502
+ | `npm run pds:css-data` | Generate CSS IntelliSense (tokens, classes, attributes) |
1503
+ | `npm run pds:build-icons` | Build custom icon sprite |
1504
+ | `npm run sync-assets` | Sync assets between locations |
1505
+
1506
+ ### Export Static Assets
1507
+
1508
+ ```bash
1509
+ npm run pds:export
1510
+ ```
1511
+
1512
+ **Output:**
1513
+ ```
1514
+ pds/
1515
+ ├── styles/
1516
+ │ ├── pds-tokens.css
1517
+ │ ├── pds-tokens.css.js
1518
+ │ ├── pds-primitives.css
1519
+ │ ├── pds-primitives.css.js
1520
+ │ ├── pds-components.css
1521
+ │ ├── pds-components.css.js
1522
+ │ ├── pds-utilities.css
1523
+ │ ├── pds-utilities.css.js
1524
+ │ └── pds-styles.css.js
1525
+ ├── components/
1526
+ │ └── pds-*.js (all components)
1527
+ ├── icons/
1528
+ │ └── pds-icons.svg
1529
+ ├── custom-elements.json # HTML IntelliSense
1530
+ ├── vscode-custom-data.json # HTML IntelliSense (VS Code)
1531
+ ├── pds.css-data.json # CSS IntelliSense (VS Code)
1532
+ └── pds-css-complete.json # CSS IntelliSense (all editors)
1533
+ ```
1534
+
1535
+ ### Generate IntelliSense Data
1536
+
1537
+ For complete IDE support with autocomplete:
1538
+
1539
+ ```bash
1540
+ # Generate both HTML and CSS IntelliSense (recommended)
1541
+ npm run pds:dx
1542
+
1543
+ # Or generate individually
1544
+ npm run pds:manifest # HTML component autocomplete
1545
+ npm run pds:css-data # CSS token & class autocomplete
1546
+ ```
1547
+
1548
+ See [INTELLISENSE.md](./INTELLISENSE.md) for setup instructions.
1549
+
1550
+ ### Configuration
1551
+
1552
+ ```javascript
1553
+ // pds.config.js
1554
+ export default {
1555
+ staticBase: 'pds',
1556
+ static: { root: 'public/assets/pds/' },
1557
+ preset: 'default',
1558
+ design: { colors: { primary: '#007acc' } }
1559
+ };
1560
+ ```
1561
+
1562
+ ### Build Icons
1563
+
1564
+ ```bash
1565
+ npm run pds:build-icons
1566
+ ```
1567
+
1568
+ ### Sync Assets
1569
+
1570
+ ```bash
1571
+ npm run sync-assets
1572
+ ```
1573
+
1574
+ ---
1575
+
1576
+ ## IntelliSense & IDE Support
1577
+
1578
+ PDS provides comprehensive IntelliSense support for both HTML and CSS, dramatically improving developer experience with autocomplete, documentation, and type hints.
1579
+
1580
+ > 📖 **[Full IntelliSense Guide](./INTELLISENSE.md)** - Detailed setup for all editors
1581
+
1582
+ ### Quick Setup (VS Code)
1583
+
1584
+ Add to `.vscode/settings.json`:
1585
+
1586
+ ```json
1587
+ {
1588
+ "html.customData": [
1589
+ "node_modules/@pure-ds/core/public/assets/pds/vscode-custom-data.json"
1590
+ ],
1591
+ "css.customData": [
1592
+ "node_modules/@pure-ds/core/public/assets/pds/pds.css-data.json"
1593
+ ]
1594
+ }
1595
+ ```
1596
+
1597
+ Reload VS Code: **Ctrl+Shift+P** → **Developer: Reload Window**
1598
+
1599
+ ### What You Get
1600
+
1601
+ #### HTML IntelliSense
1602
+ - ✅ Web component autocomplete (`<pds-drawer>`, `<pds-icon>`)
1603
+ - ✅ Attribute suggestions with descriptions
1604
+ - ✅ Enum value autocomplete (`position="left|right|top|bottom"`)
1605
+ - ✅ Icon name suggestions (all available icons)
1606
+
1607
+ #### CSS IntelliSense
1608
+ - ✅ CSS token autocomplete in `.css` files and `<style>` tags
1609
+ - ✅ Token value previews on hover (`--color-primary-500`, `--spacing-4`)
1610
+ - ✅ 165 CSS custom properties with descriptions
1611
+ - ⚠️ **Note**: Inline `style` attributes don't support IntelliSense (VS Code limitation - use CSS files or `<style>` tags)
1612
+
1613
+ > 📖 **[CSS IntelliSense Limitations](./CSS-INTELLISENSE-LIMITATION.md)** - Important info about where IntelliSense works
1614
+
1615
+ ### Generation
1616
+
1617
+ IntelliSense data is automatically generated with export:
1618
+
1619
+ ```bash
1620
+ # Generate all IntelliSense data (HTML + CSS)
1621
+ npm run pds:dx
1622
+
1623
+ # Or as part of full export
1624
+ npm run pds:export
1625
+
1626
+ # Or generate individually
1627
+ npm run pds:manifest # HTML IntelliSense only
1628
+ npm run pds:css-data # CSS IntelliSense only
1629
+ ```
1630
+
1631
+ ### Generated Files
1632
+
1633
+ ```
1634
+ public/assets/pds/
1635
+ ├── custom-elements.json # Standard Custom Elements Manifest
1636
+ ├── vscode-custom-data.json # VS Code HTML custom data
1637
+ ├── pds.css-data.json # VS Code CSS custom data
1638
+ └── pds-css-complete.json # Standard CSS data (all editors)
1639
+
1640
+ # Root reference files
1641
+ pds.html-data.json # Points to HTML custom data
1642
+ pds.css-data.json # Points to CSS custom data
1643
+ ```
1644
+
1645
+ ### Usage Examples
1646
+
1647
+ **HTML Autocomplete:**
1648
+ ```html
1649
+ <!-- Type <pds- to see all components -->
1650
+ <pds-drawer position="right" open>
1651
+ <div slot="drawer-header">Settings</div>
1652
+ </pds-drawer>
1653
+
1654
+ <!-- Icon autocomplete suggests all available icons -->
1655
+ <pds-icon icon="star"></pds-icon>
1656
+ ```
1657
+
1658
+ **CSS Token Autocomplete:**
1659
+ ```css
1660
+ .my-component {
1661
+ /* Type --color and see all color tokens */
1662
+ background: var(--color-primary-500);
1663
+ padding: var(--spacing-4);
1664
+ border-radius: var(--radius-md);
1665
+ box-shadow: var(--shadow-lg);
1666
+ }
1667
+ ```
1668
+
1669
+ **Utility Class Autocomplete:**
1670
+ ```html
1671
+ <div class="flex gap-4 items-center">
1672
+ <div class="card surface-elevated">
1673
+ <!-- Primitives and utilities autocomplete -->
1674
+ </div>
1675
+ </div>
1676
+ ```
1677
+
1678
+ ### What's Included
1679
+
1680
+ **150+ CSS Custom Properties:**
1681
+ - Colors: `--color-{name}-{50-900}`
1682
+ - Spacing: `--spacing-{xs|sm|md|lg|xl|...}`
1683
+ - Typography: `--font-family-*`, `--font-size-*`, `--font-weight-*`
1684
+ - Borders: `--radius-*`, `--border-width-*`
1685
+ - Shadows: `--shadow-{sm|md|lg|xl|2xl}`
1686
+ - Surfaces: `--surface-bg`, `--surface-text`, `--surface-border`
1687
+
1688
+ **50+ CSS Classes:**
1689
+ - Primitives: `.badge`, `.card`, `.surface`, `.alert`
1690
+ - Layout: `.flex`, `.grid`, `.grid-cols-{1-6}`, `.container`
1691
+ - Utilities: `.gap-{0-12}`, `.items-*`, `.justify-*`
1692
+ - Effects: `.border-gradient`, `.border-glow`
1693
+
1694
+ **5+ Data Enhancements:**
1695
+ - `data-dropdown`, `data-toggle`, `data-tabs`, `data-modal`, `data-tooltip`
1696
+
1697
+ ### Cross-Editor Support
1698
+
1699
+ PDS IntelliSense works with:
1700
+ - ✅ **VS Code** - Full support (HTML + CSS)
1701
+ - ✅ **WebStorm/IntelliJ** - Automatic recognition
1702
+ - ✅ **Sublime Text** - Via LSP package
1703
+ - ✅ **Vim/Neovim** - Via coc-css/coc-html
1704
+ - ✅ **Any LSP-compliant editor**
1705
+
1706
+ See [INTELLISENSE.md](./INTELLISENSE.md) for detailed setup instructions for each editor.
1707
+
1708
+ ---
1709
+
1710
+ ## Custom Elements Manifest
1711
+
1712
+ PDS automatically generates a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) for web component documentation. This is part of the IntelliSense system but can be used standalone.
1713
+
1714
+ ### What's Documented
1715
+ - Properties, attributes, methods, events
1716
+ - Slots and CSS custom properties
1717
+ - CSS parts for Shadow DOM styling
1718
+
1719
+ See the [IntelliSense Guide](./INTELLISENSE.md) for complete documentation.
1720
+ - 📖 **Hover documentation** - View descriptions without leaving your code
1721
+
1722
+ For detailed information, see [CUSTOM-ELEMENTS-MANIFEST.md](./CUSTOM-ELEMENTS-MANIFEST.md).
1723
+
1724
+ ---
1725
+
1726
+ ## Framework Integration
1727
+
1728
+ ### Vite
1729
+
1730
+ ```javascript
1731
+ // vite.config.js
1732
+ export default {
1733
+ resolve: {
1734
+ alias: { '#pds/lit': 'lit' }
1735
+ }
1736
+ };
1737
+
1738
+ // main.js
1739
+ import { PDS } from '@pure-ds/core';
1740
+ await PDS.start({ design: { colors: { primary: '#007acc' } } });
1741
+ ```
1742
+
1743
+ ### Next.js
1744
+
1745
+ ```javascript
1746
+ // app/layout.tsx
1747
+ 'use client';
1748
+
1749
+ import { useEffect } from 'react';
1750
+ import { PDS } from '@pure-ds/core';
1751
+
1752
+ export default function RootLayout({ children }) {
1753
+ useEffect(() => {
1754
+ PDS.start({ mode: 'static', applyGlobalStyles: true });
1755
+ }, []);
1756
+
1757
+ return <html><body>{children}</body></html>;
1758
+ }
1759
+
1760
+ // next.config.js
1761
+ module.exports = {
1762
+ webpack: (config) => {
1763
+ config.resolve.alias['#pds/lit'] = 'lit';
1764
+ return config;
1765
+ }
1766
+ };
1767
+ ```
1768
+
1769
+ ### React
1770
+
1771
+ ```javascript
1772
+ import { useEffect } from 'react';
1773
+ import { PDS } from 'pure-ds';
1774
+
1775
+ function App() {
1776
+ useEffect(() => {
1777
+ PDS.start({ design: { colors: { primary: '#007acc' } } });
1778
+ }, []);
1779
+
1780
+ return <button className="btn-primary">Click me</button>;
1781
+ }
1782
+ ```
1783
+
1784
+ ### Vue
1785
+
1786
+ ```javascript
1787
+ // main.js
1788
+ import { PDS } from 'pure-ds';
1789
+ await PDS.start({ design: { colors: { primary: '#007acc' } } });
1790
+
1791
+ // vite.config.js
1792
+ export default {
1793
+ resolve: { alias: { '#pds/lit': 'lit' } }
1794
+ };
1795
+ ```
1796
+
1797
+ ---
1798
+
1799
+ ## Troubleshooting
1800
+
1801
+ ### Components Not Loading
1802
+
1803
+ 1. Verify components directory exists
1804
+ 2. Check import map for `#pds/lit`
1805
+ 3. Manually sync: `node node_modules/pure-ds/packages/pds-cli/bin/postinstall.js`
1806
+ 4. Check browser console for errors
1807
+
1808
+ ### Flash of Unstyled Content
1809
+
1810
+ ```javascript
1811
+ await PDS.start({
1812
+ preloadStyles: true,
1813
+ criticalLayers: ['tokens', 'primitives']
1814
+ });
1815
+ ```
1816
+
1817
+ ### Theme Not Changing
1818
+
1819
+ Enable theme management:
1820
+ ```javascript
1821
+ await PDS.start({ manageTheme: true });
1822
+ await PDS.setTheme('dark');
1823
+ ```
1824
+
1825
+ ### Fonts Not Loading
1826
+
1827
+ Check font names are correct:
1828
+ ```javascript
1829
+ design: {
1830
+ typography: {
1831
+ fontFamilyHeadings: 'Inter, sans-serif' // Exact name
1832
+ }
1833
+ }
1834
+ ```
1835
+
1836
+ ---
1837
+
1838
+ ## Contributing
1839
+
1840
+ Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md).
1841
+
1842
+ ```bash
1843
+ git clone https://github.com/mvneerven/pure-ds.git
1844
+ cd pure-ds
1845
+ npm install
1846
+ npm run dev
1847
+ ```
1848
+
1849
+ ---
1850
+
1851
+ ## License
1852
+
1853
+ **ISC License** - See [LICENSE](./LICENSE)
1854
+
1855
+ ---
1856
+
1857
+ ## Links
1858
+
1859
+ - 🌐 **Homepage:** https://puredesignsystem.z6.web.core.windows.net/
1860
+ - 📦 **NPM:** https://www.npmjs.com/package/pure-ds
1861
+ - 🐙 **GitHub:** https://github.com/mvneerven/pure-ds
1862
+ - 📖 **Docs:** [GETTING-STARTED.md](./GETTING-STARTED.md) | [PDS-QUERY-SYSTEM.md](./PDS-QUERY-SYSTEM.md)
1863
+ - 💬 **Discussions:** https://github.com/mvneerven/pure-ds/discussions
1864
+ - 🐛 **Issues:** https://github.com/mvneerven/pure-ds/issues
1865
+
1866
+ ---
1867
+
1868
+ **Made with ❤️ for the open web**
1869
+
1870
+