@repobuddy/storybook 2.28.0 → 2.29.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/esm/index.d.ts +2 -0
- package/esm/index.js +4 -4
- package/package.json +23 -14
- package/src/contexts/_story_card_scope.tsx +1 -1
- package/src/decorators/show_source.tsx +5 -3
- package/styles.css +1 -1
package/esm/index.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ type ShowSourceOptions = Pick<StoryCardProps, 'className' | 'data-testid'> & {
|
|
|
121
121
|
source?: ((source: string | undefined) => string) | string | undefined;
|
|
122
122
|
showOriginalSource?: boolean | undefined;
|
|
123
123
|
placement?: 'before' | 'after' | undefined;
|
|
124
|
+
language?: 'json' | 'md' | 'html' | 'css' | 'js' | 'ts' | (string & {}) | undefined;
|
|
124
125
|
};
|
|
125
126
|
/**
|
|
126
127
|
* A decorator that shows the source code of a story relative to the rendered story.
|
|
@@ -138,6 +139,7 @@ declare function showSource<TRenderer extends Renderer = Renderer, TArgs = Args>
|
|
|
138
139
|
placement,
|
|
139
140
|
showOriginalSource,
|
|
140
141
|
source,
|
|
142
|
+
language,
|
|
141
143
|
...options
|
|
142
144
|
}?: ShowSourceOptions): DecoratorFunction<TRenderer, TArgs>;
|
|
143
145
|
//#endregion
|
package/esm/index.js
CHANGED
|
@@ -190,7 +190,7 @@ const channel = addons.getChannel();
|
|
|
190
190
|
* @param options.placement - Where to show the source code relative to the story.
|
|
191
191
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
192
192
|
*/
|
|
193
|
-
function showSource({ className, placement, showOriginalSource, source, ...options } = {}) {
|
|
193
|
+
function showSource({ className, placement, showOriginalSource, source, language, ...options } = {}) {
|
|
194
194
|
if (isRunningInTest()) return (Story) => /* @__PURE__ */ jsx(Story, {});
|
|
195
195
|
return (Story, { parameters: { docs, darkMode } }) => {
|
|
196
196
|
const storedItem = window.localStorage.getItem("sb-addon-themes-3");
|
|
@@ -202,13 +202,13 @@ function showSource({ className, placement, showOriginalSource, source, ...optio
|
|
|
202
202
|
}, []);
|
|
203
203
|
const originalSource = showOriginalSource ? docs?.source?.originalSource : docs?.source?.code ?? docs?.source?.originalSource;
|
|
204
204
|
const code = typeof source === "function" ? source(originalSource) : source ?? originalSource;
|
|
205
|
-
const
|
|
205
|
+
const lang = language ?? (code === docs?.source?.originalSource ? void 0 : docs?.source?.language);
|
|
206
206
|
const isOriginalSource = code === docs?.source?.originalSource;
|
|
207
207
|
const sourceContent = useMemo(() => /* @__PURE__ */ jsx(SyntaxHighlighter, {
|
|
208
208
|
"data-testid": "source-content",
|
|
209
|
-
language,
|
|
209
|
+
language: lang,
|
|
210
210
|
children: code
|
|
211
|
-
}), [code,
|
|
211
|
+
}), [code, lang]);
|
|
212
212
|
const showBefore = (placement ?? "before") === "before";
|
|
213
213
|
const sourceCardClassName = useCallback((state) => {
|
|
214
214
|
const modifiedState = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -27,9 +27,7 @@
|
|
|
27
27
|
"#repobuddy/storybook": "./src/index.ts",
|
|
28
28
|
"#repobuddy/storybook/manager": "./src/manager/index.ts",
|
|
29
29
|
"#repobuddy/storybook/storybook-addon-tag-badges": "./src/storybook-addon-tag-badges/index.ts",
|
|
30
|
-
"#repobuddy/storybook/storybook-dark-mode": "./src/storybook-dark-mode/index.ts"
|
|
31
|
-
"#repobuddy/storybook/variants": "./src/variants/index.ts",
|
|
32
|
-
"#repobuddy/storybook/variants/package.json": "./src/variants/package.json"
|
|
30
|
+
"#repobuddy/storybook/storybook-dark-mode": "./src/storybook-dark-mode/index.ts"
|
|
33
31
|
},
|
|
34
32
|
"exports": {
|
|
35
33
|
".": {
|
|
@@ -86,42 +84,53 @@
|
|
|
86
84
|
"devDependencies": {
|
|
87
85
|
"@repobuddy/vitest": "^2.1.1",
|
|
88
86
|
"@storybook-community/storybook-dark-mode": "^7.1.0",
|
|
89
|
-
"@storybook/addon-docs": "^10.
|
|
90
|
-
"@storybook/addon-vitest": "^10.3.
|
|
91
|
-
"@storybook/react-vite": "^10.3.
|
|
87
|
+
"@storybook/addon-docs": "^10.3.5",
|
|
88
|
+
"@storybook/addon-vitest": "^10.3.5",
|
|
89
|
+
"@storybook/react-vite": "^10.3.5",
|
|
92
90
|
"@tailwindcss/cli": "^4.1.17",
|
|
93
91
|
"@tailwindcss/vite": "^4.1.17",
|
|
94
92
|
"@vitest/browser": "^4.0.16",
|
|
95
|
-
"@vitest/browser-playwright": "^4.
|
|
93
|
+
"@vitest/browser-playwright": "^4.1.4",
|
|
96
94
|
"@vitest/coverage-v8": "^4.0.16",
|
|
97
95
|
"dedent": "^1.7.0",
|
|
98
96
|
"npm-run-all2": "^8.0.4",
|
|
99
97
|
"react": "^19.2.0",
|
|
100
98
|
"react-dom": "^19.2.0",
|
|
101
99
|
"rimraf": "^6.1.0",
|
|
102
|
-
"storybook": "^10.3.
|
|
100
|
+
"storybook": "^10.3.5",
|
|
103
101
|
"storybook-addon-code-editor": "^6.1.3",
|
|
104
|
-
"storybook-addon-tag-badges": "^3.0
|
|
105
|
-
"storybook-addon-vis": "^
|
|
106
|
-
"tsdown": "^0.
|
|
107
|
-
"vite": "^8.0.
|
|
102
|
+
"storybook-addon-tag-badges": "^3.1.0",
|
|
103
|
+
"storybook-addon-vis": "^4.0.0",
|
|
104
|
+
"tsdown": "^0.22.0",
|
|
105
|
+
"vite": "^8.0.8",
|
|
108
106
|
"vitest": "^4.0.16"
|
|
109
107
|
},
|
|
110
108
|
"peerDependencies": {
|
|
111
109
|
"@storybook-community/storybook-dark-mode": "^7.0.0",
|
|
112
110
|
"@storybook/addon-docs": "^10.2.4",
|
|
113
111
|
"@types/react": ">= 16",
|
|
114
|
-
"
|
|
112
|
+
"react": ">= 16",
|
|
113
|
+
"storybook-addon-tag-badges": "^3.0.2",
|
|
114
|
+
"storybook": "^10.2.4"
|
|
115
115
|
},
|
|
116
116
|
"peerDependenciesMeta": {
|
|
117
117
|
"@storybook-community/storybook-dark-mode": {
|
|
118
118
|
"optional": true
|
|
119
119
|
},
|
|
120
|
+
"@storybook/addon-docs": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
120
123
|
"@types/react": {
|
|
121
124
|
"optional": true
|
|
122
125
|
},
|
|
126
|
+
"react": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
123
129
|
"storybook-addon-tag-badges": {
|
|
124
130
|
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"storybook": {
|
|
133
|
+
"optional": true
|
|
125
134
|
}
|
|
126
135
|
},
|
|
127
136
|
"scripts": {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type StoryCardRegistryContextValue
|
|
8
8
|
} from './_story_card_registry_context.js'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type StoryCardScopeProps = { Story: ComponentType } & StoryCardEntry
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Ensures a story-card collection scope: creates the root container when no context exists,
|
|
@@ -22,6 +22,7 @@ export type ShowSourceOptions = Pick<StoryCardProps, 'className' | 'data-testid'
|
|
|
22
22
|
source?: ((source: string | undefined) => string) | string | undefined
|
|
23
23
|
showOriginalSource?: boolean | undefined
|
|
24
24
|
placement?: 'before' | 'after' | undefined
|
|
25
|
+
language?: 'json' | 'md' | 'html' | 'css' | 'js' | 'ts' | (string & {}) | undefined
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -40,6 +41,7 @@ export function showSource<TRenderer extends Renderer = Renderer, TArgs = Args>(
|
|
|
40
41
|
placement,
|
|
41
42
|
showOriginalSource,
|
|
42
43
|
source,
|
|
44
|
+
language,
|
|
43
45
|
...options
|
|
44
46
|
}: ShowSourceOptions = {}): DecoratorFunction<TRenderer, TArgs> {
|
|
45
47
|
if (isRunningInTest()) {
|
|
@@ -64,17 +66,17 @@ export function showSource<TRenderer extends Renderer = Renderer, TArgs = Args>(
|
|
|
64
66
|
|
|
65
67
|
const code = typeof source === 'function' ? source(originalSource) : (source ?? originalSource)
|
|
66
68
|
|
|
67
|
-
const
|
|
69
|
+
const lang = language ?? (code === docs?.source?.originalSource ? undefined : docs?.source?.language)
|
|
68
70
|
|
|
69
71
|
const isOriginalSource = code === docs?.source?.originalSource
|
|
70
72
|
|
|
71
73
|
const sourceContent = useMemo(
|
|
72
74
|
() => (
|
|
73
|
-
<SyntaxHighlighter data-testid="source-content" language={
|
|
75
|
+
<SyntaxHighlighter data-testid="source-content" language={lang}>
|
|
74
76
|
{code}
|
|
75
77
|
</SyntaxHighlighter>
|
|
76
78
|
),
|
|
77
|
-
[code,
|
|
79
|
+
[code, lang]
|
|
78
80
|
)
|
|
79
81
|
|
|
80
82
|
const showBefore = (placement ?? 'before') === 'before'
|
package/styles.css
CHANGED