@pure-ds/storybook 0.1.6 → 0.1.8

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.
@@ -42,6 +42,7 @@ console.log('🎨 Starting PDS initialization with preset:', initialPreset);
42
42
 
43
43
  // Wrap top-level await in IIFE for production build compatibility
44
44
  (async () => {
45
+ window.__pdsInitializing = true;
45
46
  const pdsOptions = {
46
47
  mode: 'live',
47
48
  preset: initialPreset,
@@ -69,6 +70,7 @@ console.log('🎨 Starting PDS initialization with preset:', initialPreset);
69
70
  }
70
71
 
71
72
  await PDS.start(pdsOptions);
73
+ window.__pdsInitializing = false;
72
74
 
73
75
  console.log('✨ PDS initialized in live mode for Storybook');
74
76
  console.log('📦 AutoDefiner active at:', PDS.autoDefiner?.config?.baseURL);
@@ -112,7 +114,7 @@ const withPDS = (story, context) => {
112
114
  // Check again after applying
113
115
  const afterSheets = document.adoptedStyleSheets || [];
114
116
  const afterPdsSheets = afterSheets.filter(s => s._pds === true);
115
- } else {
117
+ } else if (!window.__pdsInitializing) {
116
118
  console.warn('⚠️ No designer found!');
117
119
  }
118
120
 
@@ -358,41 +360,6 @@ const expandSemanticTags = (input) => {
358
360
  return expanded;
359
361
  };
360
362
 
361
- const getStoryStore = () => {
362
- if (typeof window === 'undefined') return null;
363
- return window.__STORYBOOK_STORY_STORE__ || null;
364
- };
365
-
366
- const collectStoryIndexTags = (storyId) => {
367
- if (!storyId) return undefined;
368
- const storyStore = getStoryStore();
369
- const index = storyStore?.storyIndex;
370
- if (!index) return undefined;
371
-
372
- const entries = index.entries || index;
373
- const entry = entries?.[storyId];
374
- return entry?.tags;
375
- };
376
-
377
- const collectStoryStoreEntryTags = (storyId) => {
378
- const storyStore = getStoryStore();
379
- if (!storyStore?.fromId || !storyId) return undefined;
380
-
381
- try {
382
- const entry = storyStore.fromId(storyId);
383
- if (!entry) return undefined;
384
-
385
- return mergeTagSets(
386
- entry.meta?.tags,
387
- entry.parameters?.tags,
388
- entry.moduleExport?.default?.tags,
389
- entry.moduleExport?.tags
390
- );
391
- } catch {
392
- return undefined;
393
- }
394
- };
395
-
396
363
  const ensureRelatedStyles = (() => {
397
364
  let injected = false;
398
365
  return () => {
@@ -964,27 +931,14 @@ const getContextTags = (context) => {
964
931
  context.moduleExport?.parameters?.pds?.tags,
965
932
  context.moduleExport?.pds?.tags,
966
933
  context.parameters?.pdsTags,
967
- context.moduleExport?.tags,
968
- collectStoryIndexTags(storyId),
969
- collectStoryStoreEntryTags(storyId)
934
+ context.moduleExport?.tags
970
935
  );
971
936
 
972
937
  if (initial.size > 0) {
973
938
  return expandSemanticTags(initial);
974
939
  }
975
940
 
976
- const fallback = new Set();
977
- const clientApi = typeof window !== 'undefined' ? window.__STORYBOOK_CLIENT_API__ : null;
978
- if (!clientApi?.raw) return fallback;
979
-
980
- clientApi
981
- .raw()
982
- .filter((story) => story?.title === context.title)
983
- .forEach((story) => {
984
- getStoryTags(story).forEach((tag) => fallback.add(tag));
985
- });
986
-
987
- return expandSemanticTags(fallback);
941
+ return expandSemanticTags(new Set());
988
942
  };
989
943
 
990
944
  const getStoryTags = (story) => {
@@ -999,24 +953,13 @@ const getStoryTags = (story) => {
999
953
  story.moduleExport?.pds?.tags,
1000
954
  story.parameters?.pdsTags,
1001
955
  story.moduleExport?.default?.tags,
1002
- story.moduleExport?.tags,
1003
- collectStoryIndexTags(story.id),
1004
- collectStoryStoreEntryTags(story.id)
956
+ story.moduleExport?.tags
1005
957
  );
1006
958
 
1007
959
  if (collected.size > 0) {
1008
960
  return expandSemanticTags(collected);
1009
961
  }
1010
962
 
1011
- const storyStore = getStoryStore();
1012
- const storyIndex = storyStore?.storyIndex;
1013
- if (storyIndex?.entries) {
1014
- const entry = storyIndex.entries[story.id];
1015
- if (entry?.tags) {
1016
- return expandSemanticTags(mergeTagSets(entry.tags));
1017
- }
1018
- }
1019
-
1020
963
  return expandSemanticTags(collected);
1021
964
  };
1022
965
 
@@ -1029,37 +972,6 @@ const getAllStoriesForRelated = () => {
1029
972
  return stories;
1030
973
  }
1031
974
 
1032
- const storyStore = getStoryStore();
1033
- const indexEntries = storyStore?.storyIndex?.entries;
1034
- if (!indexEntries) return stories;
1035
-
1036
- Object.entries(indexEntries).forEach(([storyId, entry]) => {
1037
- if (!entry || entry.type !== 'story') return;
1038
-
1039
- let storeEntry;
1040
- if (storyStore?.fromId) {
1041
- try {
1042
- storeEntry = storyStore.fromId(storyId);
1043
- } catch {}
1044
- }
1045
-
1046
- const parameters = storeEntry?.parameters || storeEntry?.story?.parameters || entry.parameters || {};
1047
- const meta = storeEntry?.meta || { title: entry.title };
1048
- const moduleExport = storeEntry?.moduleExport;
1049
- const tags = mergeTagSets(entry.tags, storeEntry?.tags);
1050
-
1051
- stories.push({
1052
- id: storyId,
1053
- title: storeEntry?.story?.title || entry.title,
1054
- name: entry.name,
1055
- importPath: entry.importPath,
1056
- parameters,
1057
- meta,
1058
- moduleExport,
1059
- tags
1060
- });
1061
- });
1062
-
1063
975
  return stories;
1064
976
  };
1065
977
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "generatedAt": "2025-12-16T13:36:16.421Z",
2
+ "generatedAt": "2025-12-16T13:39:44.048Z",
3
3
  "sources": {
4
4
  "customElements": "custom-elements.json",
5
5
  "ontology": "src\\js\\pds-core\\pds-ontology.js",
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@pure-ds/storybook",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Storybook showcase for Pure Design System with live configuration",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "bin": {
8
8
  "pds-storybook": "./bin/index.js"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "registry": "https://registry.npmjs.org/"
9
13
  },
10
14
  "files": [
11
15
  "bin",
@@ -24,11 +28,11 @@
24
28
  "package-build": "node scripts/package-build.js",
25
29
  "storybook": "npm run build-reference && storybook dev -p 6006",
26
30
  "build-storybook": "npm run build-reference && storybook build --output-dir storybook-static",
27
- "storybook:dev": "npm run generate-stories && npm run storybook",
28
- "storybook:build": "npm run generate-stories && npm run build-storybook"
31
+ "storybook:dev": "npm run storybook",
32
+ "storybook:build": "npm run build-storybook"
29
33
  },
30
34
  "peerDependencies": {
31
- "@pure-ds/core": "^0.3.0"
35
+ "@pure-ds/core": "^0.3.1"
32
36
  },
33
37
  "dependencies": {
34
38
  "@custom-elements-manifest/analyzer": "^0.11.0",
@@ -44,10 +44,8 @@ console.log('Copying custom-elements.json...');
44
44
  cpSync(join(monorepoRoot, 'custom-elements.json'), join(packageRoot, 'custom-elements.json'));
45
45
 
46
46
  // 3. Run Generation Scripts
47
- console.log('Generating stories...');
48
- // We run the scripts. They will generate stories into `stories/`.
49
- // These scripts use `../../../src` to READ data. That is fine as long as we are in the monorepo during build.
50
- execSync('node scripts/generate-stories.js', { cwd: packageRoot, stdio: 'inherit' });
47
+ // console.log('Generating stories...');
48
+ // execSync('node scripts/generate-stories.js', { cwd: packageRoot, stdio: 'inherit' });
51
49
 
52
50
  console.log('Building reference...');
53
51
  execSync('node scripts/build-pds-reference.mjs', { cwd: packageRoot, stdio: 'inherit' });
@@ -1,96 +1,96 @@
1
- # Getting Started with PDS Storybook
2
-
3
- Welcome to the **Pure Design System** Storybook! This is a comprehensive showcase of the configuration-driven design system that generates complete design systems from JavaScript configuration.
4
-
5
- ## 🎨 What You're Looking At
6
-
7
- This Storybook instance demonstrates:
8
-
9
- - **Live Configuration** - Use the PDS Configurator button in the toolbar to change the design in real-time
10
- - **Multiple Presets** - Switch between design presets using the toolbar
11
- - **Theme Switching** - Toggle between light and dark themes
12
- - **Quick Search** - Use the search icon to query tokens and components
13
-
14
- ## 🚀 Quick Start
15
-
16
- ### 1. Try the Configurator
17
-
18
- Click the **PDS Configurator** button in the toolbar (circle icon) to open the configuration panel at the bottom of the screen. From there you can:
19
-
20
- - Change colors, typography, spacing
21
- - Toggle effects like liquid glass
22
- - Export your configuration
23
- - See changes applied instantly across all stories
24
-
25
- ### 2. Browse Stories
26
-
27
- Stories are organized by best practices:
28
-
29
- - **Foundations** - Design tokens (colors, typography, spacing, icons)
30
- - **Primitives** - Basic UI elements (buttons, forms, cards, badges)
31
- - **Components** - Web Components (pds-icon, pds-drawer, pds-tabstrip, etc.)
32
- - **Patterns** - Layout patterns and utilities
33
- - **Enhancements** - Progressive enhancements for semantic HTML
34
-
35
- ### 3. Use Quick Search
36
-
37
- Click the search icon in the toolbar to query the design system:
38
-
39
- - "what is the focus border color on inputs?"
40
- - "button hover color"
41
- - "how do I create a card?"
42
-
43
- ## 📚 Story Features
44
-
45
- Each story includes:
46
-
47
- - **Interactive controls** - Use the Controls panel to customize
48
- - **Preset selection** - Try different design presets
49
- - **Color overrides** - Override primary/secondary colors per story
50
- - **Live updates** - Changes apply immediately
51
-
52
- ## 🎯 Key Features
53
-
54
- ### Configuration-Driven
55
-
56
- ```javascript
57
- await PDS.start({
58
- design: {
59
- colors: { primary: '#007acc', secondary: '#5c2d91' },
60
- typography: { baseFontSize: 16, fontScale: 1.25 },
61
- spatialRhythm: { baseUnit: 8, scaleRatio: 1.5 }
62
- }
63
- });
64
- ```
65
-
66
- ### Live Mode
67
-
68
- This Storybook runs PDS in **live mode**, meaning:
69
- - Styles are generated at runtime
70
- - Configuration changes apply instantly
71
- - Full access to `PDS.compiled` object model
72
- - Automatic font loading from Google Fonts
73
-
74
- ### Framework Agnostic
75
-
76
- While this Storybook uses Vite + Web Components, PDS works with:
77
- - Vanilla JavaScript
78
- - Lit
79
- - React
80
- - Vue
81
- - Svelte
82
- - Next.js
83
-
84
- ## 🔗 Resources
85
-
86
- - [GitHub](https://github.com/mvneerven/pure-ds)
87
- - [NPM Package](https://www.npmjs.com/package/@pure-ds/core)
88
- - [Documentation](https://puredesignsystem.z6.web.core.windows.net/)
89
-
90
- ## 💡 Tips
91
-
92
- 1. **Start with Foundations** - Understand the token system first
93
- 2. **Experiment with Presets** - See how different designs look
94
- 3. **Open the Configurator** - Try changing values live
95
- 4. **Use Quick Search** - Find tokens and components quickly
96
- 5. **Check Controls** - Each story has customizable parameters
1
+ # Getting Started with PDS Storybook
2
+
3
+ Welcome to the **Pure Design System** Storybook! This is a comprehensive showcase of the configuration-driven design system that generates complete design systems from JavaScript configuration.
4
+
5
+ ## 🎨 What You're Looking At
6
+
7
+ This Storybook instance demonstrates:
8
+
9
+ - **Live Configuration** - Use the PDS Configurator button in the toolbar to change the design in real-time
10
+ - **Multiple Presets** - Switch between design presets using the toolbar
11
+ - **Theme Switching** - Toggle between light and dark themes
12
+ - **Quick Search** - Use the search icon to query tokens and components
13
+
14
+ ## 🚀 Quick Start
15
+
16
+ ### 1. Try the Configurator
17
+
18
+ Click the **PDS Configurator** button in the toolbar (circle icon) to open the configuration panel at the bottom of the screen. From there you can:
19
+
20
+ - Change colors, typography, spacing
21
+ - Toggle effects like liquid glass
22
+ - Export your configuration
23
+ - See changes applied instantly across all stories
24
+
25
+ ### 2. Browse Stories
26
+
27
+ Stories are organized by best practices:
28
+
29
+ - **Foundations** - Design tokens (colors, typography, spacing, icons)
30
+ - **Primitives** - Basic UI elements (buttons, forms, cards, badges)
31
+ - **Components** - Web Components (pds-icon, pds-drawer, pds-tabstrip, etc.)
32
+ - **Patterns** - Layout patterns and utilities
33
+ - **Enhancements** - Progressive enhancements for semantic HTML
34
+
35
+ ### 3. Use Quick Search
36
+
37
+ Click the search icon in the toolbar to query the design system:
38
+
39
+ - "what is the focus border color on inputs?"
40
+ - "button hover color"
41
+ - "how do I create a card?"
42
+
43
+ ## 📚 Story Features
44
+
45
+ Each story includes:
46
+
47
+ - **Interactive controls** - Use the Controls panel to customize
48
+ - **Preset selection** - Try different design presets
49
+ - **Color overrides** - Override primary/secondary colors per story
50
+ - **Live updates** - Changes apply immediately
51
+
52
+ ## 🎯 Key Features
53
+
54
+ ### Configuration-Driven
55
+
56
+ ```javascript
57
+ await PDS.start({
58
+ design: {
59
+ colors: { primary: '#007acc', secondary: '#5c2d91' },
60
+ typography: { baseFontSize: 16, fontScale: 1.25 },
61
+ spatialRhythm: { baseUnit: 8, scaleRatio: 1.5 }
62
+ }
63
+ });
64
+ ```
65
+
66
+ ### Live Mode
67
+
68
+ This Storybook runs PDS in **live mode**, meaning:
69
+ - Styles are generated at runtime
70
+ - Configuration changes apply instantly
71
+ - Full access to `PDS.compiled` object model
72
+ - Automatic font loading from Google Fonts
73
+
74
+ ### Framework Agnostic
75
+
76
+ While this Storybook uses Vite + Web Components, PDS works with:
77
+ - Vanilla JavaScript
78
+ - Lit
79
+ - React
80
+ - Vue
81
+ - Svelte
82
+ - Next.js
83
+
84
+ ## 🔗 Resources
85
+
86
+ - [GitHub](https://github.com/mvneerven/pure-ds)
87
+ - [NPM Package](https://www.npmjs.com/package/pure-ds)
88
+ - [Documentation](https://puredesignsystem.z6.web.core.windows.net/)
89
+
90
+ ## 💡 Tips
91
+
92
+ 1. **Start with Foundations** - Understand the token system first
93
+ 2. **Experiment with Presets** - See how different designs look
94
+ 3. **Open the Configurator** - Try changing values live
95
+ 4. **Use Quick Search** - Find tokens and components quickly
96
+ 5. **Check Controls** - Each story has customizable parameters