@repobuddy/storybook 2.19.1 → 2.20.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/esm/index.d.ts
CHANGED
|
@@ -110,12 +110,12 @@ declare function StoryCard({
|
|
|
110
110
|
* @param options - Options for the showDocSource decorator
|
|
111
111
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
112
112
|
* @param options.className - Class name to apply to the card
|
|
113
|
-
* @param options.source - Source code to show
|
|
113
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
114
114
|
* @param options.placement - Where to show the source code relative to the story.
|
|
115
115
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
116
116
|
*/
|
|
117
117
|
declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(options?: Pick<StoryCardProps, 'className'> & {
|
|
118
|
-
source?: string | undefined;
|
|
118
|
+
source?: ((source: string | undefined) => string) | string | undefined;
|
|
119
119
|
showOriginalSource?: boolean | undefined;
|
|
120
120
|
/**
|
|
121
121
|
* Where to show the source code relative to the story.
|
package/esm/index.js
CHANGED
|
@@ -168,7 +168,7 @@ const channel = addons.getChannel();
|
|
|
168
168
|
* @param options - Options for the showDocSource decorator
|
|
169
169
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
170
170
|
* @param options.className - Class name to apply to the card
|
|
171
|
-
* @param options.source - Source code to show
|
|
171
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
172
172
|
* @param options.placement - Where to show the source code relative to the story.
|
|
173
173
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
174
174
|
*/
|
|
@@ -181,7 +181,8 @@ function showDocSource(options) {
|
|
|
181
181
|
channel.on("DARK_MODE", setIsDark);
|
|
182
182
|
return () => channel.off("DARK_MODE", setIsDark);
|
|
183
183
|
}, []);
|
|
184
|
-
const
|
|
184
|
+
const originalSource = options?.showOriginalSource ? docs?.source?.originalSource : docs?.source?.code ?? docs?.source?.originalSource;
|
|
185
|
+
const code = typeof options?.source === "function" ? options?.source(originalSource) : options?.source ?? originalSource;
|
|
185
186
|
const language = code === docs?.source?.originalSource ? void 0 : docs?.source?.language;
|
|
186
187
|
const isOriginalSource = code === docs?.source?.originalSource;
|
|
187
188
|
const sourceContent = /* @__PURE__ */ jsx(SyntaxHighlighter, {
|
|
@@ -104,7 +104,21 @@ const removeBadge = {
|
|
|
104
104
|
},
|
|
105
105
|
tooltip: version === "next" ? "Will be removed in the next major release" : `Will be removed in version ${version}`
|
|
106
106
|
};
|
|
107
|
-
}
|
|
107
|
+
},
|
|
108
|
+
display: { sidebar: [
|
|
109
|
+
{
|
|
110
|
+
type: "component",
|
|
111
|
+
skipInherited: false
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "story",
|
|
115
|
+
skipInherited: false
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: "docs",
|
|
119
|
+
skipInherited: false
|
|
120
|
+
}
|
|
121
|
+
] }
|
|
108
122
|
};
|
|
109
123
|
/** Badge (⚠️) for stories that need updating. */
|
|
110
124
|
const outdatedBadge = {
|
|
@@ -205,7 +219,13 @@ const sourceBadge = {
|
|
|
205
219
|
},
|
|
206
220
|
tooltip: "Source Code"
|
|
207
221
|
},
|
|
208
|
-
display: {
|
|
222
|
+
display: {
|
|
223
|
+
mdx: false,
|
|
224
|
+
sidebar: {
|
|
225
|
+
type: "story",
|
|
226
|
+
skipInherited: false
|
|
227
|
+
}
|
|
228
|
+
}
|
|
209
229
|
};
|
|
210
230
|
/** Badge (📸) for stories with snapshot tests. Shown in toolbar only, not in sidebar. */
|
|
211
231
|
const snapshotBadge = {
|
|
@@ -234,7 +254,10 @@ const unitBadge = {
|
|
|
234
254
|
},
|
|
235
255
|
tooltip: "Unit Test"
|
|
236
256
|
},
|
|
237
|
-
display: { sidebar:
|
|
257
|
+
display: { sidebar: {
|
|
258
|
+
type: "story",
|
|
259
|
+
skipInherited: false
|
|
260
|
+
} }
|
|
238
261
|
};
|
|
239
262
|
/** Badge (🔗) for stories with integration tests. Hidden in sidebar. */
|
|
240
263
|
const integrationBadge = {
|
|
@@ -247,7 +270,10 @@ const integrationBadge = {
|
|
|
247
270
|
},
|
|
248
271
|
tooltip: "Integration Test"
|
|
249
272
|
},
|
|
250
|
-
display: { sidebar:
|
|
273
|
+
display: { sidebar: {
|
|
274
|
+
type: "story",
|
|
275
|
+
skipInherited: false
|
|
276
|
+
} }
|
|
251
277
|
};
|
|
252
278
|
/** Badge (⌨️) for stories that demonstrate or test keyboard interaction. */
|
|
253
279
|
const keyboardBadge = {
|
|
@@ -283,7 +309,11 @@ const useCaseBadge = {
|
|
|
283
309
|
borderColor: "transparent"
|
|
284
310
|
},
|
|
285
311
|
tooltip: "Use Case"
|
|
286
|
-
}
|
|
312
|
+
},
|
|
313
|
+
display: { sidebar: {
|
|
314
|
+
type: "story",
|
|
315
|
+
skipInherited: false
|
|
316
|
+
} }
|
|
287
317
|
};
|
|
288
318
|
/** Badge (✨) for example or demo stories. */
|
|
289
319
|
const exampleBadge = {
|
|
@@ -295,7 +325,11 @@ const exampleBadge = {
|
|
|
295
325
|
borderColor: "transparent"
|
|
296
326
|
},
|
|
297
327
|
tooltip: "Example"
|
|
298
|
-
}
|
|
328
|
+
},
|
|
329
|
+
display: { sidebar: {
|
|
330
|
+
type: "story",
|
|
331
|
+
skipInherited: false
|
|
332
|
+
} }
|
|
299
333
|
};
|
|
300
334
|
/**
|
|
301
335
|
* Configuration for story tag badges that appear in the Storybook sidebar.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.1",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -100,12 +100,16 @@
|
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"@storybook-community/storybook-dark-mode": "^7.0.0",
|
|
102
102
|
"@storybook/addon-docs": "^10.2.4",
|
|
103
|
+
"@types/react": ">= 16",
|
|
103
104
|
"storybook-addon-tag-badges": "^3.0.2"
|
|
104
105
|
},
|
|
105
106
|
"peerDependenciesMeta": {
|
|
106
107
|
"@storybook-community/storybook-dark-mode": {
|
|
107
108
|
"optional": true
|
|
108
109
|
},
|
|
110
|
+
"@types/react": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
109
113
|
"storybook-addon-tag-badges": {
|
|
110
114
|
"optional": true
|
|
111
115
|
}
|
|
@@ -16,13 +16,13 @@ const channel = addons.getChannel()
|
|
|
16
16
|
* @param options - Options for the showDocSource decorator
|
|
17
17
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
18
18
|
* @param options.className - Class name to apply to the card
|
|
19
|
-
* @param options.source - Source code to show
|
|
19
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
20
20
|
* @param options.placement - Where to show the source code relative to the story.
|
|
21
21
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
22
22
|
*/
|
|
23
23
|
export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(
|
|
24
24
|
options?: Pick<StoryCardProps, 'className'> & {
|
|
25
|
-
source?: string | undefined
|
|
25
|
+
source?: ((source: string | undefined) => string) | string | undefined
|
|
26
26
|
showOriginalSource?: boolean | undefined
|
|
27
27
|
/**
|
|
28
28
|
* Where to show the source code relative to the story.
|
|
@@ -44,11 +44,12 @@ export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Arg
|
|
|
44
44
|
return () => channel.off('DARK_MODE', setIsDark)
|
|
45
45
|
}, [])
|
|
46
46
|
|
|
47
|
+
const originalSource = options?.showOriginalSource
|
|
48
|
+
? docs?.source?.originalSource
|
|
49
|
+
: (docs?.source?.code ?? docs?.source?.originalSource)
|
|
50
|
+
|
|
47
51
|
const code =
|
|
48
|
-
options?.source ??
|
|
49
|
-
(options?.showOriginalSource
|
|
50
|
-
? docs?.source?.originalSource
|
|
51
|
-
: (docs?.source?.code ?? docs?.source?.originalSource))
|
|
52
|
+
typeof options?.source === 'function' ? options?.source(originalSource) : (options?.source ?? originalSource)
|
|
52
53
|
|
|
53
54
|
const language = code === docs?.source?.originalSource ? undefined : docs?.source?.language
|
|
54
55
|
|
|
@@ -152,6 +152,22 @@ export const removeBadge: TagBadgeParameter = {
|
|
|
152
152
|
tooltip:
|
|
153
153
|
version === 'next' ? 'Will be removed in the next major release' : `Will be removed in version ${version}`
|
|
154
154
|
}
|
|
155
|
+
},
|
|
156
|
+
display: {
|
|
157
|
+
sidebar: [
|
|
158
|
+
{
|
|
159
|
+
type: 'component',
|
|
160
|
+
skipInherited: false
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: 'story',
|
|
164
|
+
skipInherited: false
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
type: 'docs',
|
|
168
|
+
skipInherited: false
|
|
169
|
+
}
|
|
170
|
+
]
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
173
|
|
|
@@ -270,7 +286,11 @@ export const sourceBadge: TagBadgeParameter = {
|
|
|
270
286
|
tooltip: 'Source Code'
|
|
271
287
|
},
|
|
272
288
|
display: {
|
|
273
|
-
mdx: false
|
|
289
|
+
mdx: false,
|
|
290
|
+
sidebar: {
|
|
291
|
+
type: 'story',
|
|
292
|
+
skipInherited: false
|
|
293
|
+
}
|
|
274
294
|
}
|
|
275
295
|
}
|
|
276
296
|
|
|
@@ -303,7 +323,10 @@ export const unitBadge: TagBadgeParameter = {
|
|
|
303
323
|
tooltip: 'Unit Test'
|
|
304
324
|
},
|
|
305
325
|
display: {
|
|
306
|
-
sidebar:
|
|
326
|
+
sidebar: {
|
|
327
|
+
type: 'story',
|
|
328
|
+
skipInherited: false
|
|
329
|
+
}
|
|
307
330
|
}
|
|
308
331
|
}
|
|
309
332
|
|
|
@@ -319,7 +342,10 @@ export const integrationBadge: TagBadgeParameter = {
|
|
|
319
342
|
tooltip: 'Integration Test'
|
|
320
343
|
},
|
|
321
344
|
display: {
|
|
322
|
-
sidebar:
|
|
345
|
+
sidebar: {
|
|
346
|
+
type: 'story',
|
|
347
|
+
skipInherited: false
|
|
348
|
+
}
|
|
323
349
|
}
|
|
324
350
|
}
|
|
325
351
|
|
|
@@ -359,6 +385,12 @@ export const useCaseBadge: TagBadgeParameter = {
|
|
|
359
385
|
borderColor: 'transparent'
|
|
360
386
|
},
|
|
361
387
|
tooltip: 'Use Case'
|
|
388
|
+
},
|
|
389
|
+
display: {
|
|
390
|
+
sidebar: {
|
|
391
|
+
type: 'story',
|
|
392
|
+
skipInherited: false
|
|
393
|
+
}
|
|
362
394
|
}
|
|
363
395
|
}
|
|
364
396
|
|
|
@@ -372,6 +404,12 @@ export const exampleBadge: TagBadgeParameter = {
|
|
|
372
404
|
borderColor: 'transparent'
|
|
373
405
|
},
|
|
374
406
|
tooltip: 'Example'
|
|
407
|
+
},
|
|
408
|
+
display: {
|
|
409
|
+
sidebar: {
|
|
410
|
+
type: 'story',
|
|
411
|
+
skipInherited: false
|
|
412
|
+
}
|
|
375
413
|
}
|
|
376
414
|
}
|
|
377
415
|
|