@sxl-studio/storybook-addon 1.1.0 → 1.1.1
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/CHANGELOG.md +4 -0
- package/README.md +46 -13
- package/dist/manager.js +1 -4
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
- **Registry matching:** removed the behavior where a **single** registry entry was applied to **every** story. Matching now always uses the same story-context heuristic (or explicit `sxl.component` / `sxl.figmaNodeId`). Unrelated stories show the “no Figma integration” state.
|
|
6
|
+
|
|
3
7
|
## 1.1.0
|
|
4
8
|
|
|
5
9
|
- **Preset (zero-config):** merges Content-Security-Policy so the Figma embed iframe can load (`frame-src` includes `https://www.figma.com`).
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Storybook addon for [SXL Studio](https://sxl-studio.com) — displays Figma Embe
|
|
|
4
4
|
|
|
5
5
|
## Changelog
|
|
6
6
|
|
|
7
|
-
See [CHANGELOG.md](./CHANGELOG.md) (e.g. **1.1.0
|
|
7
|
+
See [CHANGELOG.md](./CHANGELOG.md) (e.g. **1.1.1** registry matching fix; **1.1.0** preset CSP, `/sxl-tokens`, legacy filename alias, quieter logs).
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -21,9 +21,11 @@ npm install @sxl-studio/storybook-addon --save-dev
|
|
|
21
21
|
|
|
22
22
|
## Setup
|
|
23
23
|
|
|
24
|
-
### 1. Register the addon
|
|
24
|
+
### 1. Register the addon (`main`)
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
List **`@sxl-studio/storybook-addon`** in **`addons`**. The preset ships with the package and is applied when Storybook loads the addon (no separate preset import in `main` unless your setup requires the explicit `@sxl-studio/storybook-addon/preset` entry — see troubleshooting in docs).
|
|
27
|
+
|
|
28
|
+
**Minimal `main.ts`:**
|
|
27
29
|
|
|
28
30
|
```ts
|
|
29
31
|
export default {
|
|
@@ -34,21 +36,35 @@ export default {
|
|
|
34
36
|
};
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
**With a shared Storybook config** (internal design-system package, monorepo): **append** to the shared addons array — do not drop existing entries.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import sharedMain from '@your-org/storybook-vue/main';
|
|
43
|
+
|
|
44
|
+
const config = {
|
|
45
|
+
...sharedMain,
|
|
46
|
+
addons: [...(sharedMain.addons ?? []), '@sxl-studio/storybook-addon'],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default config;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Import the registry (`preview`)
|
|
38
53
|
|
|
39
|
-
The SXL Studio Figma plugin generates
|
|
54
|
+
The SXL Studio Figma plugin generates **`diff-code-connect.<figmaFileKey>.json`** (or an exported `sxl-codeconnect.json`). Put it in **`parameters.sxl.registry`**. The **relative import path is up to your repo** (e.g. `../../tokens/tokens/diff-code-connect.xxx.json`).
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
- **`fromDiffCodeConnect(raw)`** — explicit normalization; use if you prefer one code path.
|
|
57
|
+
- **Raw `import registry from '...json'`** — often enough for current plugin output.
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
- If `diff-code-connect.SXL-Components.json` is **missing** but another `diff-code-connect.*.json` exists in that folder, Vite gets a **`resolve.alias`** from the legacy path to the first matching file (sorted by name). You can keep a stable import path in preview while the plugin emits `diff-code-connect.<figmaFileKey>.json`.
|
|
59
|
+
**Preset (automatic):** when the addon preset runs, it:
|
|
45
60
|
|
|
46
|
-
|
|
61
|
+
- Serves a nearby **`tokens/tokens`** folder at **`/sxl-tokens/…`** (dev + `storybook build` via `staticDirs`) so `compositionFilePath` in the registry resolves without extra Vite config.
|
|
62
|
+
- Can **`resolve.alias`** a stable filename like `diff-code-connect.SXL-Components.json` to the real `diff-code-connect.*.json` when only one candidate exists in that folder (see CHANGELOG).
|
|
47
63
|
|
|
48
|
-
|
|
64
|
+
**Minimal `preview.ts`:**
|
|
49
65
|
|
|
50
66
|
```ts
|
|
51
|
-
import registry from '../
|
|
67
|
+
import registry from '../path/to/diff-code-connect.<fileKey>.json';
|
|
52
68
|
|
|
53
69
|
export default {
|
|
54
70
|
parameters: {
|
|
@@ -57,10 +73,25 @@ export default {
|
|
|
57
73
|
};
|
|
58
74
|
```
|
|
59
75
|
|
|
60
|
-
**
|
|
76
|
+
**With a shared `preview`** — merge **`parameters`** so shared decorators/globals stay intact:
|
|
61
77
|
|
|
62
78
|
```ts
|
|
63
|
-
import
|
|
79
|
+
import sharedPreview from '@your-org/storybook-vue/preview';
|
|
80
|
+
import registry from '../../tokens/tokens/diff-code-connect.<fileKey>.json';
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
...sharedPreview,
|
|
84
|
+
parameters: {
|
|
85
|
+
...sharedPreview.parameters,
|
|
86
|
+
sxl: { registry },
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Alternative — converter:**
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import raw from '../diff-code-connect.<fileKey>.json';
|
|
64
95
|
import { fromDiffCodeConnect } from '@sxl-studio/storybook-addon';
|
|
65
96
|
|
|
66
97
|
export default {
|
|
@@ -72,6 +103,8 @@ export default {
|
|
|
72
103
|
|
|
73
104
|
### 3. Match stories to Figma components
|
|
74
105
|
|
|
106
|
+
Stories are matched to registry entries by explicit `sxl.component` / `sxl.figmaNodeId`, or by a **heuristic** on story title and file path. **A registry with a single component is not shown on every story** — unrelated stories show a “no integration” state until the story context matches or you set parameters manually.
|
|
107
|
+
|
|
75
108
|
Per-story matching:
|
|
76
109
|
|
|
77
110
|
```ts
|
package/dist/manager.js
CHANGED
|
@@ -3706,10 +3706,7 @@ function resolveEntry(params, ctx) {
|
|
|
3706
3706
|
found = registry.entries.find((e) => e.displayName.toLowerCase() === name);
|
|
3707
3707
|
}
|
|
3708
3708
|
}
|
|
3709
|
-
if (!found
|
|
3710
|
-
found = registry.entries[0];
|
|
3711
|
-
}
|
|
3712
|
-
if (!found && registry.entries.length > 1) {
|
|
3709
|
+
if (!found) {
|
|
3713
3710
|
found = matchByStoryContext(registry.entries, ctx);
|
|
3714
3711
|
}
|
|
3715
3712
|
if (!found) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sxl-studio/storybook-addon",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Storybook addon for SXL Studio — displays Figma Embed, component info and design token status for linked components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"build": "tsup",
|
|
27
27
|
"dev": "tsup --watch",
|
|
28
28
|
"lint": "tsc --noEmit",
|
|
29
|
-
"prepublishOnly": "npm run build"
|
|
29
|
+
"prepublishOnly": "npm run build",
|
|
30
|
+
"push": "npm run build && npm publish"
|
|
30
31
|
},
|
|
31
32
|
"keywords": [
|
|
32
33
|
"storybook",
|