@repobuddy/storybook 2.6.0 → 2.7.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 +2 -1
- package/package.json +1 -1
- package/src/decorators/show_doc_source.tsx +7 -3
package/esm/index.d.ts
CHANGED
|
@@ -79,9 +79,11 @@ type StoryCardProps = {
|
|
|
79
79
|
* @param options - Options for the showDocSource decorator
|
|
80
80
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
81
81
|
* @param options.className - Class name to apply to the card
|
|
82
|
+
* @param options.source - Source code to show if provided.
|
|
82
83
|
* @returns A decorator function that shows the source code of a story above the rendered story
|
|
83
84
|
*/
|
|
84
85
|
declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(options?: Pick<StoryCardProps, 'className'> & {
|
|
86
|
+
source?: string | undefined;
|
|
85
87
|
showOriginalSource?: boolean | undefined;
|
|
86
88
|
}): DecoratorFunction<TRenderer, TArgs>;
|
|
87
89
|
//#endregion
|
package/esm/index.js
CHANGED
|
@@ -81,6 +81,7 @@ const channel = addons.getChannel();
|
|
|
81
81
|
* @param options - Options for the showDocSource decorator
|
|
82
82
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
83
83
|
* @param options.className - Class name to apply to the card
|
|
84
|
+
* @param options.source - Source code to show if provided.
|
|
84
85
|
* @returns A decorator function that shows the source code of a story above the rendered story
|
|
85
86
|
*/
|
|
86
87
|
function showDocSource(options) {
|
|
@@ -92,7 +93,7 @@ function showDocSource(options) {
|
|
|
92
93
|
channel.on("DARK_MODE", setIsDark);
|
|
93
94
|
return () => channel.off("DARK_MODE", setIsDark);
|
|
94
95
|
}, []);
|
|
95
|
-
const code = options?.showOriginalSource ? docs?.source?.originalSource : docs?.source?.code ?? docs?.source?.originalSource;
|
|
96
|
+
const code = options?.source ?? (options?.showOriginalSource ? docs?.source?.originalSource : docs?.source?.code ?? docs?.source?.originalSource);
|
|
96
97
|
const language = code === docs?.source?.originalSource ? void 0 : docs?.source?.language;
|
|
97
98
|
const isOriginalSource = code === docs?.source?.originalSource;
|
|
98
99
|
const content = /* @__PURE__ */ jsx(SyntaxHighlighter, {
|
package/package.json
CHANGED
|
@@ -15,10 +15,12 @@ const channel = addons.getChannel()
|
|
|
15
15
|
* @param options - Options for the showDocSource decorator
|
|
16
16
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
17
17
|
* @param options.className - Class name to apply to the card
|
|
18
|
+
* @param options.source - Source code to show if provided.
|
|
18
19
|
* @returns A decorator function that shows the source code of a story above the rendered story
|
|
19
20
|
*/
|
|
20
21
|
export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(
|
|
21
22
|
options?: Pick<StoryCardProps, 'className'> & {
|
|
23
|
+
source?: string | undefined
|
|
22
24
|
showOriginalSource?: boolean | undefined
|
|
23
25
|
}
|
|
24
26
|
): DecoratorFunction<TRenderer, TArgs> {
|
|
@@ -34,9 +36,11 @@ export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Arg
|
|
|
34
36
|
return () => channel.off('DARK_MODE', setIsDark)
|
|
35
37
|
}, [])
|
|
36
38
|
|
|
37
|
-
const code =
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
const code =
|
|
40
|
+
options?.source ??
|
|
41
|
+
(options?.showOriginalSource
|
|
42
|
+
? docs?.source?.originalSource
|
|
43
|
+
: (docs?.source?.code ?? docs?.source?.originalSource))
|
|
40
44
|
|
|
41
45
|
const language = code === docs?.source?.originalSource ? undefined : docs?.source?.language
|
|
42
46
|
|