@repobuddy/storybook 2.0.1 → 2.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/esm/index.d.ts +574 -13
- package/esm/index.js +251 -12
- package/esm/manager/index.d.ts +38 -1
- package/esm/manager/index.js +32 -1
- package/esm/storybook-addon-tag-badges/index.d.ts +95 -2
- package/esm/storybook-addon-tag-badges/index.js +207 -1
- package/esm/storybook-dark-mode/index.d.ts +110 -3
- package/esm/storybook-dark-mode/index.js +102 -3
- package/package.json +4 -12
- package/cjs/components/show_html.d.ts +0 -16
- package/cjs/components/show_html.js +0 -29
- package/cjs/decorators/show_doc_source.d.ts +0 -6
- package/cjs/decorators/show_doc_source.js +0 -38
- package/cjs/index.d.ts +0 -13
- package/cjs/index.js +0 -137
- package/cjs/manager/brand_title.d.ts +0 -35
- package/cjs/manager/brand_title.js +0 -12
- package/cjs/manager/index.d.ts +0 -1
- package/cjs/manager/index.js +0 -16
- package/cjs/parameters/define_actions_param.d.ts +0 -24
- package/cjs/parameters/define_actions_param.js +0 -11
- package/cjs/parameters/define_backgrounds_param.d.ts +0 -45
- package/cjs/parameters/define_backgrounds_param.js +0 -10
- package/cjs/parameters/define_docs_param.d.ts +0 -217
- package/cjs/parameters/define_docs_param.js +0 -11
- package/cjs/parameters/define_layout_param.d.ts +0 -20
- package/cjs/parameters/define_layout_param.js +0 -10
- package/cjs/parameters/define_parameters.d.ts +0 -39
- package/cjs/parameters/define_parameters.js +0 -9
- package/cjs/parameters/define_test_param.d.ts +0 -34
- package/cjs/parameters/define_test_param.js +0 -11
- package/cjs/parameters/define_viewport_param.d.ts +0 -78
- package/cjs/parameters/define_viewport_param.js +0 -11
- package/cjs/parameters/story_sort.d.ts +0 -27
- package/cjs/parameters/story_sort.js +0 -1
- package/cjs/storybook-addon-tag-badges/index.d.ts +0 -2
- package/cjs/storybook-addon-tag-badges/index.js +0 -16
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/cjs/storybook-addon-tag-badges/tag_badges.js +0 -179
- package/cjs/storybook-addon-tag-badges/types.d.ts +0 -9
- package/cjs/storybook-addon-tag-badges/types.js +0 -1
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +0 -23
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/cjs/storybook-dark-mode/define_dark_mode.js +0 -11
- package/cjs/storybook-dark-mode/index.d.ts +0 -3
- package/cjs/storybook-dark-mode/index.js +0 -38
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/cjs/storybook-dark-mode/with_dark_mode.js +0 -54
- package/cjs/testing/decorators/when_running_in_test.d.ts +0 -5
- package/cjs/testing/decorators/when_running_in_test.js +0 -12
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/cjs/testing/decorators/when_running_in_text.ctx.js +0 -10
- package/cjs/types.d.ts +0 -41
- package/cjs/types.js +0 -1
- package/cjs/variants/index.d.ts +0 -1
- package/cjs/variants/index.js +0 -8
- package/cjs/variants/package.json +0 -3
- package/cjs/variants/preset.d.ts +0 -11
- package/cjs/variants/preset.js +0 -3
- package/esm/components/show_html.d.ts +0 -16
- package/esm/components/show_html.js +0 -19
- package/esm/decorators/show_doc_source.d.ts +0 -6
- package/esm/decorators/show_doc_source.js +0 -28
- package/esm/manager/brand_title.d.ts +0 -35
- package/esm/manager/brand_title.js +0 -6
- package/esm/parameters/define_actions_param.d.ts +0 -24
- package/esm/parameters/define_actions_param.js +0 -3
- package/esm/parameters/define_backgrounds_param.d.ts +0 -45
- package/esm/parameters/define_backgrounds_param.js +0 -3
- package/esm/parameters/define_docs_param.d.ts +0 -217
- package/esm/parameters/define_docs_param.js +0 -3
- package/esm/parameters/define_layout_param.d.ts +0 -20
- package/esm/parameters/define_layout_param.js +0 -3
- package/esm/parameters/define_parameters.d.ts +0 -39
- package/esm/parameters/define_parameters.js +0 -3
- package/esm/parameters/define_test_param.d.ts +0 -34
- package/esm/parameters/define_test_param.js +0 -3
- package/esm/parameters/define_viewport_param.d.ts +0 -78
- package/esm/parameters/define_viewport_param.js +0 -3
- package/esm/parameters/story_sort.d.ts +0 -27
- package/esm/parameters/story_sort.js +0 -0
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/esm/storybook-addon-tag-badges/tag_badges.js +0 -189
- package/esm/storybook-addon-tag-badges/types.d.ts +0 -9
- package/esm/storybook-addon-tag-badges/types.js +0 -0
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +0 -21
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/esm/storybook-dark-mode/define_dark_mode.js +0 -3
- package/esm/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/esm/storybook-dark-mode/with_dark_mode.js +0 -46
- package/esm/testing/decorators/when_running_in_test.d.ts +0 -5
- package/esm/testing/decorators/when_running_in_test.js +0 -6
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/esm/testing/decorators/when_running_in_text.ctx.js +0 -4
- package/esm/types.d.ts +0 -41
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +0 -1
- package/esm/variants/index.js +0 -2
- package/esm/variants/package.json +0 -3
- package/esm/variants/preset.d.ts +0 -11
- package/esm/variants/preset.js +0 -1
|
@@ -1,3 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DocsContextProps } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { ThemeVars } from "storybook/theming";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import { CSSProperties } from "@just-web/css";
|
|
6
|
+
import { DecoratorFunction } from "storybook/internal/types";
|
|
7
|
+
|
|
8
|
+
//#region src/storybook-dark-mode/dark_mode_docs_container.d.ts
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a `DocsContainer` for `storybook` that works with `@storybook-community/storybook-dark-mode`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/hipstersmoothie/storybook-dark-mode/issues/282
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // .storybook/preview.tsx
|
|
18
|
+
* const preview: Preview = {
|
|
19
|
+
* parameters: {
|
|
20
|
+
* docs: {
|
|
21
|
+
* container: createDarkModeDocsContainer()
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function createDarkModeDocsContainer(customThemes?: {
|
|
28
|
+
light?: ThemeVars | undefined;
|
|
29
|
+
dark?: ThemeVars | undefined;
|
|
30
|
+
} | undefined): (props: PropsWithChildren<{
|
|
31
|
+
context: DocsContextProps;
|
|
32
|
+
}>) => react_jsx_runtime0.JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/storybook-dark-mode/define_dark_mode.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* Configuration parameters for `@storybook-community/storybook-dark-mode`.
|
|
37
|
+
*/
|
|
38
|
+
interface DarkModeParam {
|
|
39
|
+
/** The current theme ('dark' or 'light') */
|
|
40
|
+
current?: 'dark' | 'light' | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* CSS class(es) to apply in dark mode.
|
|
43
|
+
*/
|
|
44
|
+
darkClass?: string | string[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* CSS style(s) to apply in dark mode.
|
|
47
|
+
*
|
|
48
|
+
* This only works when using `withStoryRoot`.
|
|
49
|
+
*/
|
|
50
|
+
darkStyle?: CSSProperties | undefined;
|
|
51
|
+
/** CSS class(es) to apply in light mode */
|
|
52
|
+
lightClass?: string | string[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* CSS style(s) to apply in light mode.
|
|
55
|
+
*
|
|
56
|
+
* This only works when using `withStoryRoot`.
|
|
57
|
+
*/
|
|
58
|
+
lightStyle?: CSSProperties | undefined;
|
|
59
|
+
/** Dark theme variables */
|
|
60
|
+
dark?: ThemeVars;
|
|
61
|
+
/** Light theme variables */
|
|
62
|
+
light?: ThemeVars;
|
|
63
|
+
/** Element to apply theme classes to ('html' or 'body') */
|
|
64
|
+
classTarget?: 'html' | 'body' | undefined;
|
|
65
|
+
/** Whether to apply theme styles to preview iframe */
|
|
66
|
+
stylePreview?: boolean | undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Defines `@storybook-community/storybook-dark-mode` parameters for Storybook stories.
|
|
70
|
+
*
|
|
71
|
+
* @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
|
|
72
|
+
* @returns An object containing the dark mode parameter configuration
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // ./storybook/preview.tsx
|
|
77
|
+
*
|
|
78
|
+
* export const preview = {
|
|
79
|
+
* parameters: {
|
|
80
|
+
* ...defineDarkModeParam({ darkClass: 'dark' })
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
declare function defineDarkModeParam(darkMode: DarkModeParam): {
|
|
85
|
+
darkMode: DarkModeParam;
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/storybook-dark-mode/with_dark_mode.d.ts
|
|
89
|
+
/**
|
|
90
|
+
* Applies additional dark mode behavior.
|
|
91
|
+
*
|
|
92
|
+
* @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
|
|
93
|
+
* @returns A decorator function that applies additional dark mode behavior.
|
|
94
|
+
*/
|
|
95
|
+
declare function withDarkMode(options?: {
|
|
96
|
+
/**
|
|
97
|
+
* CSS class(es) to apply to the body element.
|
|
98
|
+
*
|
|
99
|
+
* Useful when using Tailwind CSS and `classTarget: 'html'`
|
|
100
|
+
*/
|
|
101
|
+
bodyClass?: string | string[] | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* CSS style(s) to apply to the body element.
|
|
104
|
+
*
|
|
105
|
+
* Useful when using Tailwind CSS and `classTarget: 'html'`
|
|
106
|
+
*/
|
|
107
|
+
bodyStyle?: CSSProperties | undefined;
|
|
108
|
+
} | undefined): DecoratorFunction<any, any>;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { DarkModeParam, createDarkModeDocsContainer, defineDarkModeParam, withDarkMode };
|
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DARK_MODE_EVENT_NAME, useDarkMode } from "@storybook-community/storybook-dark-mode";
|
|
2
|
+
import { DocsContainer } from "@storybook/addon-docs/blocks";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { themes } from "storybook/theming";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { toDOMStyle } from "@just-web/css";
|
|
7
|
+
|
|
8
|
+
//#region src/storybook-dark-mode/dark_mode_docs_container.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `DocsContainer` for `storybook` that works with `@storybook-community/storybook-dark-mode`.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/hipstersmoothie/storybook-dark-mode/issues/282
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* // .storybook/preview.tsx
|
|
17
|
+
* const preview: Preview = {
|
|
18
|
+
* parameters: {
|
|
19
|
+
* docs: {
|
|
20
|
+
* container: createDarkModeDocsContainer()
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function createDarkModeDocsContainer(customThemes) {
|
|
27
|
+
return function DarkModeDocsContainer(props) {
|
|
28
|
+
const [isDark, setDark] = useState(true);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
props.context.channel.on(DARK_MODE_EVENT_NAME, setDark);
|
|
31
|
+
return () => props.context.channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
|
|
32
|
+
}, [props.context.channel]);
|
|
33
|
+
return /* @__PURE__ */ jsx(DocsContainer, {
|
|
34
|
+
...props,
|
|
35
|
+
theme: isDark ? customThemes?.dark ?? themes.dark : customThemes?.light ?? themes.light,
|
|
36
|
+
children: props.children
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/storybook-dark-mode/define_dark_mode.ts
|
|
43
|
+
/**
|
|
44
|
+
* Defines `@storybook-community/storybook-dark-mode` parameters for Storybook stories.
|
|
45
|
+
*
|
|
46
|
+
* @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
|
|
47
|
+
* @returns An object containing the dark mode parameter configuration
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* // ./storybook/preview.tsx
|
|
52
|
+
*
|
|
53
|
+
* export const preview = {
|
|
54
|
+
* parameters: {
|
|
55
|
+
* ...defineDarkModeParam({ darkClass: 'dark' })
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
function defineDarkModeParam(darkMode) {
|
|
60
|
+
return { darkMode };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/storybook-dark-mode/with_dark_mode.tsx
|
|
65
|
+
/**
|
|
66
|
+
* Applies additional dark mode behavior.
|
|
67
|
+
*
|
|
68
|
+
* @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
|
|
69
|
+
* @returns A decorator function that applies additional dark mode behavior.
|
|
70
|
+
*/
|
|
71
|
+
function withDarkMode(options) {
|
|
72
|
+
return function darkModeDecorator(Story, { parameters }) {
|
|
73
|
+
const darkMode = parameters.darkMode;
|
|
74
|
+
if (!darkMode) return /* @__PURE__ */ jsx(Story, {});
|
|
75
|
+
const dark = useDarkMode();
|
|
76
|
+
const target = darkMode.classTarget === "html" ? document.documentElement : document.body;
|
|
77
|
+
if (dark) {
|
|
78
|
+
removeStyle(target, darkMode.lightStyle);
|
|
79
|
+
addStyle(target, darkMode.darkStyle);
|
|
80
|
+
} else {
|
|
81
|
+
removeStyle(target, darkMode.darkStyle);
|
|
82
|
+
addStyle(target, darkMode.lightStyle);
|
|
83
|
+
}
|
|
84
|
+
if (options?.bodyClass) addClass(document.body, options.bodyClass);
|
|
85
|
+
if (options?.bodyStyle) addStyle(document.body, options.bodyStyle);
|
|
86
|
+
return /* @__PURE__ */ jsx(Story, {});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function addClass(target, className) {
|
|
90
|
+
if (!className) return;
|
|
91
|
+
if (typeof className === "string") target.classList.add(...className.split(" "));
|
|
92
|
+
else if (Array.isArray(className)) target.classList.add(...className);
|
|
93
|
+
}
|
|
94
|
+
function addStyle(target, style) {
|
|
95
|
+
if (style) for (const [key, value] of Object.entries(toDOMStyle(style))) target.style.setProperty(key, value);
|
|
96
|
+
}
|
|
97
|
+
function removeStyle(target, style) {
|
|
98
|
+
if (style) for (const key of Object.keys(toDOMStyle(style))) target.style.removeProperty(key);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { createDarkModeDocsContainer, defineDarkModeParam, withDarkMode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -38,15 +38,7 @@
|
|
|
38
38
|
"./storybook-dark-mode": {
|
|
39
39
|
"types": "./esm/storybook-dark-mode/index.d.ts",
|
|
40
40
|
"default": "./esm/storybook-dark-mode/index.js"
|
|
41
|
-
}
|
|
42
|
-
"./variants": {
|
|
43
|
-
"import": {
|
|
44
|
-
"types": "./esm/variants/index.d.ts",
|
|
45
|
-
"default": "./esm/variants/index.js"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"./variants/package.json": "./esm/variants/package.json",
|
|
49
|
-
"./variants/preset": "./esm/variants/preset.js"
|
|
41
|
+
}
|
|
50
42
|
},
|
|
51
43
|
"files": [
|
|
52
44
|
"cjs",
|
|
@@ -81,7 +73,7 @@
|
|
|
81
73
|
"storybook": "^10.0.8",
|
|
82
74
|
"storybook-addon-tag-badges": "^3.0.2",
|
|
83
75
|
"tailwindcss": "^4.1.17",
|
|
84
|
-
"
|
|
76
|
+
"tsdown": "^0.16.6",
|
|
85
77
|
"vite": "^7.2.2",
|
|
86
78
|
"vitest": "^4.0.9"
|
|
87
79
|
},
|
|
@@ -98,7 +90,7 @@
|
|
|
98
90
|
}
|
|
99
91
|
},
|
|
100
92
|
"scripts": {
|
|
101
|
-
"build": "
|
|
93
|
+
"build": "tsdown",
|
|
102
94
|
"clean": "rimraf .turbo coverage cjs esm storybook-static *.tsbuildinfo",
|
|
103
95
|
"coverage": "vitest run --coverage",
|
|
104
96
|
"sb": "storybook dev -p 6006",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ClassNameProps, StyleProps } from '@just-web/css';
|
|
2
|
-
import { type UserConfig } from 'htmlfy';
|
|
3
|
-
export type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
4
|
-
selector?: string | undefined;
|
|
5
|
-
config?: UserConfig | undefined;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A component that displays the HTML of a subject element.
|
|
9
|
-
* Uses `htmlfy` internally to format and prettify the HTML output.
|
|
10
|
-
*
|
|
11
|
-
* @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
|
|
12
|
-
* @param config - Configuration options passed to htmlfy's prettify function
|
|
13
|
-
* @param props - Additional props (className, style) passed to the pre element
|
|
14
|
-
* @returns A pre element containing the formatted HTML
|
|
15
|
-
*/
|
|
16
|
-
export declare function ShowHtml({ selector, config, ...props }: ShowHtmlProps): import("react").JSX.Element;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ShowHtml = ShowHtml;
|
|
7
|
-
var _htmlfy = require("htmlfy");
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
function ShowHtml({
|
|
10
|
-
selector = '[data-testid="subject"]',
|
|
11
|
-
config,
|
|
12
|
-
...props
|
|
13
|
-
}) {
|
|
14
|
-
const [html, setHtml] = (0, _react.useState)("");
|
|
15
|
-
(0, _react.useEffect)(() => {
|
|
16
|
-
const subject = document.querySelector(selector);
|
|
17
|
-
if (subject) {
|
|
18
|
-
setHtml((0, _htmlfy.prettify)(subject.outerHTML, {
|
|
19
|
-
tag_wrap: 40,
|
|
20
|
-
...config
|
|
21
|
-
}));
|
|
22
|
-
} else {
|
|
23
|
-
setHtml("No subject found");
|
|
24
|
-
}
|
|
25
|
-
}, [selector]);
|
|
26
|
-
return /* @__PURE__ */React.createElement("pre", {
|
|
27
|
-
...props
|
|
28
|
-
}, html);
|
|
29
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Args, DecoratorFunction, Renderer } from 'storybook/internal/csf';
|
|
2
|
-
/**
|
|
3
|
-
* A decorator that shows the source code of a story above the rendered story.
|
|
4
|
-
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
5
|
-
*/
|
|
6
|
-
export declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.showDocSource = showDocSource;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _components = require("storybook/internal/components");
|
|
9
|
-
var _previewApi = require("storybook/preview-api");
|
|
10
|
-
var _theming = require("storybook/theming");
|
|
11
|
-
const channel = _previewApi.addons.getChannel();
|
|
12
|
-
function showDocSource() {
|
|
13
|
-
return (Story, {
|
|
14
|
-
parameters: {
|
|
15
|
-
docs,
|
|
16
|
-
darkMode
|
|
17
|
-
}
|
|
18
|
-
}) => {
|
|
19
|
-
const storedItem = window.localStorage.getItem("sb-addon-themes-3");
|
|
20
|
-
const current = typeof storedItem === "string" ? JSON.parse(storedItem).current : darkMode?.current;
|
|
21
|
-
const [isDark, setIsDark] = (0, _react.useState)((darkMode?.stylePreview && current === "dark") ?? false);
|
|
22
|
-
(0, _react.useEffect)(() => {
|
|
23
|
-
channel.on("DARK_MODE", setIsDark);
|
|
24
|
-
return () => channel.off("DARK_MODE", setIsDark);
|
|
25
|
-
}, []);
|
|
26
|
-
return /* @__PURE__ */React.createElement(_theming.ThemeProvider, {
|
|
27
|
-
theme: (0, _theming.convert)(docs?.theme ?? (isDark ? _theming.themes.dark : _theming.themes.light))
|
|
28
|
-
}, /* @__PURE__ */React.createElement("section", {
|
|
29
|
-
style: {
|
|
30
|
-
display: "flex",
|
|
31
|
-
flexDirection: "column",
|
|
32
|
-
gap: "1rem"
|
|
33
|
-
}
|
|
34
|
-
}, /* @__PURE__ */React.createElement(_components.SyntaxHighlighter, {
|
|
35
|
-
language: docs?.source?.language
|
|
36
|
-
}, docs?.source?.code), /* @__PURE__ */React.createElement(Story, null)));
|
|
37
|
-
};
|
|
38
|
-
}
|
package/cjs/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from '@repobuddy/test';
|
|
2
|
-
export * from './components/show_html.tsx';
|
|
3
|
-
export * from './decorators/show_doc_source.tsx';
|
|
4
|
-
export * from './parameters/define_actions_param.ts';
|
|
5
|
-
export * from './parameters/define_backgrounds_param.ts';
|
|
6
|
-
export * from './parameters/define_docs_param.ts';
|
|
7
|
-
export * from './parameters/define_layout_param.ts';
|
|
8
|
-
export * from './parameters/define_parameters.ts';
|
|
9
|
-
export * from './parameters/define_test_param.ts';
|
|
10
|
-
export * from './parameters/define_viewport_param.ts';
|
|
11
|
-
export * from './parameters/story_sort.ts';
|
|
12
|
-
export * from './testing/decorators/when_running_in_test.tsx';
|
|
13
|
-
export type * from './types.ts';
|
package/cjs/index.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _test = require("@repobuddy/test");
|
|
7
|
-
Object.keys(_test).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _test[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _test[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _show_html = require("./components/show_html.tsx");
|
|
18
|
-
Object.keys(_show_html).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _show_html[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _show_html[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _show_doc_source = require("./decorators/show_doc_source.tsx");
|
|
29
|
-
Object.keys(_show_doc_source).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _show_doc_source[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _show_doc_source[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _define_actions_param = require("./parameters/define_actions_param.ts");
|
|
40
|
-
Object.keys(_define_actions_param).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _define_actions_param[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _define_actions_param[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _define_backgrounds_param = require("./parameters/define_backgrounds_param.ts");
|
|
51
|
-
Object.keys(_define_backgrounds_param).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _define_backgrounds_param[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _define_backgrounds_param[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _define_docs_param = require("./parameters/define_docs_param.ts");
|
|
62
|
-
Object.keys(_define_docs_param).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _define_docs_param[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _define_docs_param[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _define_layout_param = require("./parameters/define_layout_param.ts");
|
|
73
|
-
Object.keys(_define_layout_param).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _define_layout_param[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _define_layout_param[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _define_parameters = require("./parameters/define_parameters.ts");
|
|
84
|
-
Object.keys(_define_parameters).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _define_parameters[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _define_parameters[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
var _define_test_param = require("./parameters/define_test_param.ts");
|
|
95
|
-
Object.keys(_define_test_param).forEach(function (key) {
|
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
|
97
|
-
if (key in exports && exports[key] === _define_test_param[key]) return;
|
|
98
|
-
Object.defineProperty(exports, key, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return _define_test_param[key];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
var _define_viewport_param = require("./parameters/define_viewport_param.ts");
|
|
106
|
-
Object.keys(_define_viewport_param).forEach(function (key) {
|
|
107
|
-
if (key === "default" || key === "__esModule") return;
|
|
108
|
-
if (key in exports && exports[key] === _define_viewport_param[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () {
|
|
112
|
-
return _define_viewport_param[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
var _story_sort = require("./parameters/story_sort.ts");
|
|
117
|
-
Object.keys(_story_sort).forEach(function (key) {
|
|
118
|
-
if (key === "default" || key === "__esModule") return;
|
|
119
|
-
if (key in exports && exports[key] === _story_sort[key]) return;
|
|
120
|
-
Object.defineProperty(exports, key, {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function () {
|
|
123
|
-
return _story_sort[key];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
var _when_running_in_test = require("./testing/decorators/when_running_in_test.tsx");
|
|
128
|
-
Object.keys(_when_running_in_test).forEach(function (key) {
|
|
129
|
-
if (key === "default" || key === "__esModule") return;
|
|
130
|
-
if (key in exports && exports[key] === _when_running_in_test[key]) return;
|
|
131
|
-
Object.defineProperty(exports, key, {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () {
|
|
134
|
-
return _when_running_in_test[key];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface BrandTitleOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The title to display in the brand title.
|
|
4
|
-
* It can be a simple string or raw HTML.
|
|
5
|
-
*/
|
|
6
|
-
title: string;
|
|
7
|
-
/**
|
|
8
|
-
* The logo to display in the brand title.
|
|
9
|
-
* It can be a simple string or raw HTML (e.g. `<svg>`).
|
|
10
|
-
*/
|
|
11
|
-
logo?: string | undefined;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Creates a brand title element for the Storybook manager UI.
|
|
15
|
-
*
|
|
16
|
-
* @param options - The options for customizing the brand title
|
|
17
|
-
* @param options.title - The title text or HTML to display
|
|
18
|
-
* @param options.logo - Optional logo HTML to display before the title
|
|
19
|
-
* @returns An HTML string containing the brand title element
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { brandTitle } from '@repobuddy/storybook'
|
|
25
|
-
* import { addons } from 'storybook/manager-api'
|
|
26
|
-
*
|
|
27
|
-
* addons.setConfig({
|
|
28
|
-
* brandTitle: brandTitle({
|
|
29
|
-
* title: 'My Storybook',
|
|
30
|
-
* logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
|
|
31
|
-
* })
|
|
32
|
-
* })
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function brandTitle(options: BrandTitleOptions): string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.brandTitle = brandTitle;
|
|
7
|
-
function brandTitle(options) {
|
|
8
|
-
return `<span style="display: flex; align-items: center; gap: 2px;">
|
|
9
|
-
${options.logo ?? ""}
|
|
10
|
-
${options.title}
|
|
11
|
-
</span>`;
|
|
12
|
-
}
|
package/cjs/manager/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './brand_title.js';
|
package/cjs/manager/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _brand_title = require("./brand_title.js");
|
|
7
|
-
Object.keys(_brand_title).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _brand_title[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _brand_title[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface ActionsParam {
|
|
2
|
-
actions: {
|
|
3
|
-
argTypesRegex?: string | undefined;
|
|
4
|
-
disable?: boolean | undefined;
|
|
5
|
-
handles?: string[] | undefined;
|
|
6
|
-
[k: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Defines actions parameters for Storybook stories.
|
|
11
|
-
*
|
|
12
|
-
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
13
|
-
*
|
|
14
|
-
* @param actions - Configuration for actions parameters
|
|
15
|
-
* @returns An object containing the actions parameter configuration
|
|
16
|
-
*/
|
|
17
|
-
export declare function defineActionsParam(actions: ActionsParam['actions']): {
|
|
18
|
-
actions: {
|
|
19
|
-
[k: string]: unknown;
|
|
20
|
-
argTypesRegex?: string | undefined;
|
|
21
|
-
disable?: boolean | undefined;
|
|
22
|
-
handles?: string[] | undefined;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export interface BackgroundsParam {
|
|
2
|
-
backgrounds: {
|
|
3
|
-
default?: string | undefined;
|
|
4
|
-
values?: Array<{
|
|
5
|
-
name: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}>;
|
|
8
|
-
disable?: boolean | undefined;
|
|
9
|
-
grid?: {
|
|
10
|
-
cellAmount?: number | undefined;
|
|
11
|
-
cellSize?: number | undefined;
|
|
12
|
-
disable?: boolean | undefined;
|
|
13
|
-
offsetX?: number | undefined;
|
|
14
|
-
offsetY?: number | undefined;
|
|
15
|
-
opacity?: number | undefined;
|
|
16
|
-
} | undefined;
|
|
17
|
-
[k: string]: unknown;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export interface GlobalApiBackgroundsParam {
|
|
21
|
-
backgrounds: {
|
|
22
|
-
default?: string | undefined;
|
|
23
|
-
options?: Array<{
|
|
24
|
-
name: string;
|
|
25
|
-
value: string;
|
|
26
|
-
}>;
|
|
27
|
-
disabled?: boolean | undefined;
|
|
28
|
-
grid?: {
|
|
29
|
-
cellAmount?: number | undefined;
|
|
30
|
-
cellSize?: number | undefined;
|
|
31
|
-
disable?: boolean | undefined;
|
|
32
|
-
offsetX?: number | undefined;
|
|
33
|
-
offsetY?: number | undefined;
|
|
34
|
-
opacity?: number | undefined;
|
|
35
|
-
} | undefined;
|
|
36
|
-
[k: string]: unknown;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Defines backgrounds parameters for Storybook stories.
|
|
41
|
-
*
|
|
42
|
-
* @param backgrounds - The backgrounds configuration
|
|
43
|
-
* @returns An object containing the backgrounds parameter configuration
|
|
44
|
-
*/
|
|
45
|
-
export declare const defineBackgroundsParam: (backgrounds: BackgroundsParam["backgrounds"] | GlobalApiBackgroundsParam["backgrounds"]) => BackgroundsParam;
|