@repobuddy/storybook 1.0.1 → 2.0.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/cjs/components/show_html.d.ts +16 -0
- package/cjs/components/show_html.js +29 -0
- package/cjs/decorators/show_doc_source.d.ts +6 -0
- package/cjs/decorators/show_doc_source.js +38 -0
- package/cjs/index.d.ts +13 -0
- package/cjs/index.js +137 -0
- package/cjs/manager/brand_title.d.ts +35 -0
- package/cjs/manager/brand_title.js +12 -0
- package/cjs/manager/index.d.ts +1 -0
- package/cjs/manager/index.js +16 -0
- package/cjs/parameters/define_actions_param.d.ts +24 -0
- package/cjs/parameters/define_actions_param.js +11 -0
- package/cjs/parameters/define_backgrounds_param.d.ts +45 -0
- package/cjs/parameters/define_backgrounds_param.js +10 -0
- package/cjs/parameters/define_docs_param.d.ts +217 -0
- package/cjs/parameters/define_docs_param.js +11 -0
- package/cjs/parameters/define_layout_param.d.ts +20 -0
- package/cjs/parameters/define_layout_param.js +10 -0
- package/cjs/parameters/define_parameters.d.ts +39 -0
- package/cjs/parameters/define_parameters.js +9 -0
- package/cjs/parameters/define_test_param.d.ts +34 -0
- package/cjs/parameters/define_test_param.js +11 -0
- package/cjs/parameters/define_viewport_param.d.ts +78 -0
- package/cjs/parameters/define_viewport_param.js +11 -0
- package/cjs/parameters/story_sort.d.ts +27 -0
- package/cjs/parameters/story_sort.js +1 -0
- package/cjs/storybook-addon-tag-badges/index.d.ts +2 -0
- package/cjs/storybook-addon-tag-badges/index.js +16 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +41 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.js +179 -0
- package/cjs/storybook-addon-tag-badges/types.d.ts +9 -0
- package/cjs/storybook-addon-tag-badges/types.js +1 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +26 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +23 -0
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +54 -0
- package/cjs/storybook-dark-mode/define_dark_mode.js +11 -0
- package/cjs/storybook-dark-mode/index.d.ts +3 -0
- package/cjs/storybook-dark-mode/index.js +38 -0
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +22 -0
- package/cjs/storybook-dark-mode/with_dark_mode.js +54 -0
- package/cjs/testing/decorators/when_running_in_test.d.ts +5 -0
- package/cjs/testing/decorators/when_running_in_test.js +12 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +3 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.js +10 -0
- package/cjs/types.d.ts +41 -0
- package/cjs/types.js +1 -0
- package/cjs/variants/index.d.ts +1 -0
- package/cjs/variants/index.js +8 -0
- package/cjs/variants/package.json +3 -0
- package/cjs/variants/preset.d.ts +11 -0
- package/cjs/variants/preset.js +3 -0
- package/esm/components/show_html.d.ts +1 -1
- package/esm/components/show_html.js +17 -26
- package/esm/decorators/show_doc_source.js +26 -12
- package/esm/index.d.ts +1 -0
- package/esm/index.js +12 -12
- package/esm/manager/brand_title.js +2 -24
- package/esm/manager/index.js +1 -1
- package/esm/parameters/define_actions_param.js +1 -9
- package/esm/parameters/define_backgrounds_param.js +1 -7
- package/esm/parameters/define_docs_param.d.ts +2 -2
- package/esm/parameters/define_docs_param.js +1 -28
- package/esm/parameters/define_layout_param.js +1 -15
- package/esm/parameters/define_parameters.d.ts +1 -1
- package/esm/parameters/define_parameters.js +1 -30
- package/esm/parameters/define_test_param.js +1 -17
- package/esm/parameters/define_viewport_param.js +1 -28
- package/esm/parameters/story_sort.js +0 -1
- package/esm/storybook-addon-tag-badges/index.js +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.js +153 -172
- package/esm/storybook-addon-tag-badges/types.d.ts +7 -6
- package/esm/storybook-addon-tag-badges/types.js +0 -1
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +2 -2
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +19 -30
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +3 -3
- package/esm/storybook-dark-mode/define_dark_mode.js +1 -17
- package/esm/storybook-dark-mode/index.js +3 -3
- package/esm/storybook-dark-mode/with_dark_mode.js +36 -47
- package/esm/testing/decorators/when_running_in_test.js +4 -8
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +1 -2
- package/esm/testing/decorators/when_running_in_text.ctx.js +2 -2
- package/esm/types.d.ts +41 -0
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +1 -0
- package/esm/variants/index.js +2 -0
- package/esm/variants/package.json +3 -0
- package/esm/variants/preset.d.ts +11 -0
- package/esm/variants/preset.js +1 -0
- package/package.json +51 -34
- package/readme.md +3 -3
- package/src/decorators/show_doc_source.tsx +30 -11
- package/src/index.ts +1 -0
- package/src/parameters/define_docs_param.ts +2 -2
- package/src/storybook-addon-tag-badges/tag_badges.ts +1 -1
- package/src/storybook-addon-tag-badges/types.ts +7 -6
- package/src/storybook-dark-mode/dark_mode_docs_container.tsx +2 -2
- package/src/storybook-dark-mode/define_dark_mode.ts +3 -3
- package/src/storybook-dark-mode/with_dark_mode.tsx +2 -1
- package/src/types.ts +51 -0
- package/src/variants/index.ts +3 -0
- package/src/variants/package.json +3 -0
- package/src/variants/preset.ts +22 -0
- package/src/overview.mdx +0 -7
- package/src/storybook-dark-mode/dark_mode_docs_container.mdx +0 -33
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withDarkMode = withDarkMode;
|
|
7
|
+
var _css = require("@just-web/css");
|
|
8
|
+
var _storybookDarkMode = require("@storybook-community/storybook-dark-mode");
|
|
9
|
+
function withDarkMode(options) {
|
|
10
|
+
return function darkModeDecorator(Story, {
|
|
11
|
+
parameters
|
|
12
|
+
}) {
|
|
13
|
+
const darkMode = parameters.darkMode;
|
|
14
|
+
if (!darkMode) return /* @__PURE__ */React.createElement(Story, null);
|
|
15
|
+
const dark = (0, _storybookDarkMode.useDarkMode)();
|
|
16
|
+
const target = darkMode.classTarget === "html" ? document.documentElement : document.body;
|
|
17
|
+
if (dark) {
|
|
18
|
+
removeStyle(target, darkMode.lightStyle);
|
|
19
|
+
addStyle(target, darkMode.darkStyle);
|
|
20
|
+
} else {
|
|
21
|
+
removeStyle(target, darkMode.darkStyle);
|
|
22
|
+
addStyle(target, darkMode.lightStyle);
|
|
23
|
+
}
|
|
24
|
+
if (options?.bodyClass) {
|
|
25
|
+
addClass(document.body, options.bodyClass);
|
|
26
|
+
}
|
|
27
|
+
if (options?.bodyStyle) {
|
|
28
|
+
addStyle(document.body, options.bodyStyle);
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */React.createElement(Story, null);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function addClass(target, className) {
|
|
34
|
+
if (!className) return;
|
|
35
|
+
if (typeof className === "string") {
|
|
36
|
+
target.classList.add(...className.split(" "));
|
|
37
|
+
} else if (Array.isArray(className)) {
|
|
38
|
+
target.classList.add(...className);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function addStyle(target, style) {
|
|
42
|
+
if (style) {
|
|
43
|
+
for (const [key, value] of Object.entries((0, _css.toDOMStyle)(style))) {
|
|
44
|
+
target.style.setProperty(key, value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function removeStyle(target, style) {
|
|
49
|
+
if (style) {
|
|
50
|
+
for (const key of Object.keys((0, _css.toDOMStyle)(style))) {
|
|
51
|
+
target.style.removeProperty(key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Decorator, StrictArgs } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
4
|
+
*/
|
|
5
|
+
export declare function whenRunningInTest<TArgs = StrictArgs>(decoratorOrHandler: ((...args: Parameters<Decorator<TArgs>>) => ReturnType<Decorator<TArgs>> | undefined | void) | (() => ReturnType<Decorator<TArgs>> | undefined | void)): Decorator<TArgs>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.whenRunningInTest = whenRunningInTest;
|
|
7
|
+
var _when_running_in_textCtx = require("./when_running_in_text.ctx.ts");
|
|
8
|
+
function whenRunningInTest(decoratorOrHandler) {
|
|
9
|
+
return function RunInTest(Story, context) {
|
|
10
|
+
return _when_running_in_textCtx.ctx.isRunningInTest() ? decoratorOrHandler(Story, context) ?? /* @__PURE__ */React.createElement(Story, null) : /* @__PURE__ */React.createElement(Story, null);
|
|
11
|
+
};
|
|
12
|
+
}
|
package/cjs/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* Extends the Storybook Meta type with custom tag types
|
|
4
|
+
* @template TCmpOrArgs - The component or args type
|
|
5
|
+
* @template M - The base Meta type
|
|
6
|
+
* @template E - The extension type containing tagType
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // Create a generic Meta type for a project
|
|
11
|
+
* type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta<TCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
12
|
+
*
|
|
13
|
+
* // Create a specific Meta type for a component
|
|
14
|
+
* type Meta = ExtendMeta<typeof Component, Meta<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type ExtendMeta<TCmpOrArgs, M extends Meta<TCmpOrArgs>, E extends {
|
|
18
|
+
tag: string;
|
|
19
|
+
}> = Omit<M, 'tags'> & {
|
|
20
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Extends the Storybook StoryObj type with custom tag types
|
|
24
|
+
* @template TMetaOrCmpOrArgs - The meta, component or args type
|
|
25
|
+
* @template S - The base StoryObj type
|
|
26
|
+
* @template E - The extension type containing tagType
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // Create a generic StoryObj type for a project
|
|
31
|
+
* type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj<TMetaOrCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
32
|
+
*
|
|
33
|
+
* // Create a specific StoryObj type for a component
|
|
34
|
+
* type StoryObj = ExtendStoryObj<typeof Component, StoryObj<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type ExtendStoryObj<TMetaOrCmpOrArgs, S extends StoryObj<TMetaOrCmpOrArgs>, E extends {
|
|
38
|
+
tag: string;
|
|
39
|
+
}> = Omit<S, 'tags'> & {
|
|
40
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
41
|
+
};
|
package/cjs/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const empty: {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User specifies `@repobuddy/storybook/variants/addon` in the `.storybook/main.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Storybook loads it on the server side.
|
|
5
|
+
*
|
|
6
|
+
* It provides a default export (or in CJS, `module.exports =`) that contains:
|
|
7
|
+
*
|
|
8
|
+
* - `managerEntries` a function that returns an array of strings on where to load the manager (on the client side)
|
|
9
|
+
* - `previewAnnotations` a function that returns an array of strings on where to load the preview (on the client side)
|
|
10
|
+
* - `experimental_serverChannel` a function that handles the server-side channel
|
|
11
|
+
*/
|
|
@@ -13,4 +13,4 @@ export type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
|
13
13
|
* @param props - Additional props (className, style) passed to the pre element
|
|
14
14
|
* @returns A pre element containing the formatted HTML
|
|
15
15
|
*/
|
|
16
|
-
export declare function ShowHtml({ selector, config, ...props }: ShowHtmlProps): import("react
|
|
16
|
+
export declare function ShowHtml({ selector, config, ...props }: ShowHtmlProps): import("react").JSX.Element;
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* A component that displays the HTML of a subject element.
|
|
6
|
-
* Uses `htmlfy` internally to format and prettify the HTML output.
|
|
7
|
-
*
|
|
8
|
-
* @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
|
|
9
|
-
* @param config - Configuration options passed to htmlfy's prettify function
|
|
10
|
-
* @param props - Additional props (className, style) passed to the pre element
|
|
11
|
-
* @returns A pre element containing the formatted HTML
|
|
12
|
-
*/
|
|
1
|
+
import { prettify } from "htmlfy";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
13
3
|
export function ShowHtml({ selector = '[data-testid="subject"]', config, ...props }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
4
|
+
const [html, setHtml] = useState("");
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const subject = document.querySelector(selector);
|
|
7
|
+
if (subject) {
|
|
8
|
+
setHtml(
|
|
9
|
+
prettify(subject.outerHTML, {
|
|
10
|
+
tag_wrap: 40,
|
|
11
|
+
...config
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
} else {
|
|
15
|
+
setHtml("No subject found");
|
|
16
|
+
}
|
|
17
|
+
}, [selector]);
|
|
18
|
+
return /* @__PURE__ */ React.createElement("pre", { ...props }, html);
|
|
28
19
|
}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { SyntaxHighlighter } from "storybook/internal/components";
|
|
3
|
+
import { addons } from "storybook/preview-api";
|
|
4
|
+
import { convert, ThemeProvider, themes } from "storybook/theming";
|
|
5
|
+
const channel = addons.getChannel();
|
|
6
6
|
export function showDocSource() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
return (Story, { parameters: { docs, darkMode } }) => {
|
|
8
|
+
const storedItem = window.localStorage.getItem("sb-addon-themes-3");
|
|
9
|
+
const current = typeof storedItem === "string" ? JSON.parse(storedItem).current : darkMode?.current;
|
|
10
|
+
const [isDark, setIsDark] = useState((darkMode?.stylePreview && current === "dark") ?? false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
channel.on("DARK_MODE", setIsDark);
|
|
13
|
+
return () => channel.off("DARK_MODE", setIsDark);
|
|
14
|
+
}, []);
|
|
15
|
+
return /* @__PURE__ */ React.createElement(ThemeProvider, { theme: convert(docs?.theme ?? (isDark ? themes.dark : themes.light)) }, /* @__PURE__ */ React.createElement(
|
|
16
|
+
"section",
|
|
17
|
+
{
|
|
18
|
+
style: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
gap: "1rem"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
/* @__PURE__ */ React.createElement(SyntaxHighlighter, { language: docs?.source?.language }, docs?.source?.code),
|
|
25
|
+
/* @__PURE__ */ React.createElement(Story, null)
|
|
26
|
+
));
|
|
27
|
+
};
|
|
14
28
|
}
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from "./components/show_html.
|
|
3
|
-
export * from "./decorators/show_doc_source.
|
|
4
|
-
export * from "./parameters/define_actions_param.
|
|
5
|
-
export * from "./parameters/define_backgrounds_param.
|
|
6
|
-
export * from "./parameters/define_docs_param.
|
|
7
|
-
export * from "./parameters/define_layout_param.
|
|
8
|
-
export * from "./parameters/define_parameters.
|
|
9
|
-
export * from "./parameters/define_test_param.
|
|
10
|
-
export * from "./parameters/define_viewport_param.
|
|
11
|
-
export * from "./parameters/story_sort.
|
|
12
|
-
export * from "./testing/decorators/when_running_in_test.
|
|
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";
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a brand title element for the Storybook manager UI.
|
|
3
|
-
*
|
|
4
|
-
* @param options - The options for customizing the brand title
|
|
5
|
-
* @param options.title - The title text or HTML to display
|
|
6
|
-
* @param options.logo - Optional logo HTML to display before the title
|
|
7
|
-
* @returns An HTML string containing the brand title element
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { brandTitle } from '@repobuddy/storybook'
|
|
13
|
-
* import { addons } from 'storybook/manager-api'
|
|
14
|
-
*
|
|
15
|
-
* addons.setConfig({
|
|
16
|
-
* brandTitle: brandTitle({
|
|
17
|
-
* title: 'My Storybook',
|
|
18
|
-
* logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
|
|
19
|
-
* })
|
|
20
|
-
* })
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
1
|
export function brandTitle(options) {
|
|
24
|
-
|
|
25
|
-
${options.logo ??
|
|
2
|
+
return `<span style="display: flex; align-items: center; gap: 2px;">
|
|
3
|
+
${options.logo ?? ""}
|
|
26
4
|
${options.title}
|
|
27
5
|
</span>`;
|
|
28
6
|
}
|
package/esm/manager/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./brand_title.
|
|
1
|
+
export * from "./brand_title.ts";
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines actions parameters for Storybook stories.
|
|
3
|
-
*
|
|
4
|
-
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
5
|
-
*
|
|
6
|
-
* @param actions - Configuration for actions parameters
|
|
7
|
-
* @returns An object containing the actions parameter configuration
|
|
8
|
-
*/
|
|
9
1
|
export function defineActionsParam(actions) {
|
|
10
|
-
|
|
2
|
+
return { actions };
|
|
11
3
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines backgrounds parameters for Storybook stories.
|
|
3
|
-
*
|
|
4
|
-
* @param backgrounds - The backgrounds configuration
|
|
5
|
-
* @returns An object containing the backgrounds parameter configuration
|
|
6
|
-
*/
|
|
7
1
|
export const defineBackgroundsParam = (backgrounds) => ({
|
|
8
|
-
|
|
2
|
+
backgrounds
|
|
9
3
|
});
|
|
@@ -88,12 +88,12 @@ export interface DocsParam {
|
|
|
88
88
|
/**
|
|
89
89
|
* `docs.description.story` can be used to describe the story in doc.
|
|
90
90
|
*/
|
|
91
|
-
story?: string |
|
|
91
|
+
story?: string | undefined;
|
|
92
92
|
/**
|
|
93
93
|
* `docs.description.component` can be used to describe the component in meta.
|
|
94
94
|
* It has no effect on the stories.
|
|
95
95
|
*/
|
|
96
|
-
component?: string |
|
|
96
|
+
component?: string | undefined;
|
|
97
97
|
} | undefined;
|
|
98
98
|
/**
|
|
99
99
|
* Determines whether to show the code panel.
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines docs parameters for Storybook stories.
|
|
3
|
-
*
|
|
4
|
-
* @param docs - Configuration for docs parameters including options for:
|
|
5
|
-
* - Controls display and sorting
|
|
6
|
-
* - Story rendering (autoplay, height, inline vs iframe)
|
|
7
|
-
* - And other docs-related settings
|
|
8
|
-
* @returns An object containing the docs parameter configuration
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
13
|
-
*
|
|
14
|
-
* export default {
|
|
15
|
-
* parameters: defineDocsParam({
|
|
16
|
-
* controls: {
|
|
17
|
-
* sort: 'alpha',
|
|
18
|
-
* exclude: ['internal*']
|
|
19
|
-
* },
|
|
20
|
-
* story: {
|
|
21
|
-
* inline: true,
|
|
22
|
-
* height: '400px'
|
|
23
|
-
* }
|
|
24
|
-
* })
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
1
|
export function defineDocsParam(docs) {
|
|
29
|
-
|
|
2
|
+
return { docs };
|
|
30
3
|
}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper function to define the layout parameter for a story
|
|
3
|
-
*
|
|
4
|
-
* @see https://storybook.js.org/docs/api/parameters#layout
|
|
5
|
-
*
|
|
6
|
-
* @param layout - The layout type to use ('padded', 'fullscreen', or 'centered')
|
|
7
|
-
* @returns An object containing the layout parameter
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* export const MyStory = {
|
|
11
|
-
* parameters: defineLayoutParam('centered')
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
1
|
export const defineLayoutParam = (layout) => ({
|
|
16
|
-
|
|
2
|
+
layout
|
|
17
3
|
});
|
|
@@ -36,4 +36,4 @@ export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgro
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export declare function defineParameters<P extends Record<string, any>>(param: P & StorybookBuiltInParams, ...rest: Array<StorybookBuiltInParams>):
|
|
39
|
+
export declare function defineParameters<P extends Record<string, any>>(param: P & StorybookBuiltInParams, ...rest: Array<StorybookBuiltInParams>): any;
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
3
|
-
*
|
|
4
|
-
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
5
|
-
* @returns The combined parameters object
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { defineParameters } from '@repobuddy/storybook'
|
|
10
|
-
*
|
|
11
|
-
* export default {
|
|
12
|
-
* parameters: defineParameters({
|
|
13
|
-
* // Built-in parameters
|
|
14
|
-
* layout: 'centered',
|
|
15
|
-
* backgrounds: {
|
|
16
|
-
* default: 'light',
|
|
17
|
-
* values: [
|
|
18
|
-
* { name: 'light', value: '#ffffff' },
|
|
19
|
-
* { name: 'dark', value: '#333333' }
|
|
20
|
-
* ]
|
|
21
|
-
* },
|
|
22
|
-
* // Custom parameters
|
|
23
|
-
* myCustomParam: {
|
|
24
|
-
* someValue: true
|
|
25
|
-
* }
|
|
26
|
-
* })
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
1
|
export function defineParameters(param, ...rest) {
|
|
31
|
-
|
|
2
|
+
return rest.reduce((acc, param2) => Object.assign(acc, param2), param);
|
|
32
3
|
}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines test parameters for Storybook stories.
|
|
3
|
-
*
|
|
4
|
-
* @see https://storybook.js.org/docs/api/parameters#test
|
|
5
|
-
*
|
|
6
|
-
* @param test - Configuration for test parameters
|
|
7
|
-
* @returns An object containing the test parameter configuration
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* defineTestParam({
|
|
11
|
-
* clearMocks: true,
|
|
12
|
-
* mockReset: true,
|
|
13
|
-
* restoreMocks: true,
|
|
14
|
-
* dangerouslyIgnoreUnhandledErrors: true
|
|
15
|
-
* })
|
|
16
|
-
*/
|
|
17
1
|
export function defineTestParam(test) {
|
|
18
|
-
|
|
2
|
+
return { test };
|
|
19
3
|
}
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines viewport parameters for Storybook stories.
|
|
3
|
-
*
|
|
4
|
-
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
5
|
-
*
|
|
6
|
-
* @param viewport - Configuration for viewport parameters including:
|
|
7
|
-
* - viewports: Custom viewport definitions
|
|
8
|
-
* - defaultViewport: The default viewport to use
|
|
9
|
-
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
10
|
-
* - disabled: Whether viewport controls are disabled
|
|
11
|
-
* @returns An object containing the viewport parameter configuration
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* defineViewportParam({
|
|
16
|
-
* viewports: {
|
|
17
|
-
* mobile: {
|
|
18
|
-
* name: 'Mobile',
|
|
19
|
-
* styles: { width: '320px', height: '568px' },
|
|
20
|
-
* type: 'mobile'
|
|
21
|
-
* }
|
|
22
|
-
* },
|
|
23
|
-
* defaultViewport: 'mobile',
|
|
24
|
-
* defaultOrientation: 'portrait'
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
1
|
export function defineViewportParam(viewport) {
|
|
29
|
-
|
|
2
|
+
return { viewport };
|
|
30
3
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./tag_badges.
|
|
1
|
+
export * from "./tag_badges.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TagBadgeParameters } from 'storybook-addon-tag-badges';
|
|
1
|
+
import { type TagBadgeParameters } from 'storybook-addon-tag-badges/manager-helpers';
|
|
2
2
|
type TagBadgeParameter = TagBadgeParameters[0];
|
|
3
3
|
/**
|
|
4
4
|
* Type representing the names of predefined tags used in Storybook stories.
|