@newhighsco/storybook-preset 10.2.32 → 10.2.34
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/dist/index.d.ts +20 -13
- package/dist/index.js +6 -7
- package/dist/preset.mjs +59 -0
- package/dist/preview-Ba_0JMth.js +104 -0
- package/dist/preview.d.ts +4 -3
- package/dist/preview.js +2 -1
- package/package.json +4 -5
- package/preset.js +1 -1
- package/dist/chunk-IHI4SI5P.js +0 -81
- package/dist/preset.js +0 -65
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { PreviewAddon } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Viewport } from
|
|
1
|
+
import { PreviewAddon } from "storybook/internal/csf";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import { Decorator, Parameters, StoryObj } from "@storybook/react-webpack5";
|
|
4
|
+
import { Viewport } from "storybook/viewport";
|
|
5
5
|
|
|
6
|
+
//#region src/utils.d.ts
|
|
6
7
|
type Story<T> = StoryObj<ComponentProps<T>>;
|
|
7
8
|
interface Options<T> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
args?: ComponentProps<T>;
|
|
10
|
+
decorator?: Decorator<T>;
|
|
11
|
+
parameters?: Parameters;
|
|
12
|
+
tags?: string[];
|
|
12
13
|
}
|
|
13
14
|
declare const viewports: Record<string, Viewport>;
|
|
14
15
|
declare const modes: (breakpoints?: string[]) => Record<string, {
|
|
15
|
-
|
|
16
|
+
viewport: string;
|
|
16
17
|
}>;
|
|
17
|
-
declare function snapshot<T>(story: Story<T> | Array<Story<T>>, {
|
|
18
|
-
|
|
18
|
+
declare function snapshot<T>(story: Story<T> | Array<Story<T>>, {
|
|
19
|
+
args,
|
|
20
|
+
decorator,
|
|
21
|
+
parameters,
|
|
22
|
+
tags
|
|
23
|
+
}?: Options<T>): Story<T>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/index.d.ts
|
|
19
26
|
declare const _default: () => PreviewAddon;
|
|
20
|
-
|
|
21
|
-
export { _default as default, modes, snapshot, viewports };
|
|
27
|
+
//#endregion
|
|
28
|
+
export { _default as default, modes, snapshot, viewports };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { preview_exports } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { index_default as default };
|
|
1
|
+
import { a as snapshot, i as modes, o as viewports, r as preview_exports } from "./preview-Ba_0JMth.js";
|
|
2
|
+
import { definePreviewAddon } from "storybook/internal/csf";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
var src_default = () => definePreviewAddon(preview_exports);
|
|
5
|
+
//#endregion
|
|
6
|
+
export { src_default as default, modes, snapshot, viewports };
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/loaders.ts
|
|
2
|
+
const filter = (url) => {
|
|
3
|
+
if (url.startsWith("/")) return false;
|
|
4
|
+
return true;
|
|
5
|
+
};
|
|
6
|
+
const cssLoaders = (test = /\.css$/, importLoaders = []) => {
|
|
7
|
+
importLoaders = [{
|
|
8
|
+
loader: "postcss-loader",
|
|
9
|
+
options: { implementation: "postcss" }
|
|
10
|
+
}, ...importLoaders];
|
|
11
|
+
return {
|
|
12
|
+
test,
|
|
13
|
+
sideEffects: true,
|
|
14
|
+
use: [
|
|
15
|
+
"style-loader",
|
|
16
|
+
{
|
|
17
|
+
loader: "css-loader",
|
|
18
|
+
options: {
|
|
19
|
+
esModule: false,
|
|
20
|
+
import: { filter },
|
|
21
|
+
importLoaders: importLoaders.length,
|
|
22
|
+
modules: {
|
|
23
|
+
exportLocalsConvention: "as-is",
|
|
24
|
+
localIdentName: "[name]_[local]__[hash:base64:5]"
|
|
25
|
+
},
|
|
26
|
+
url: { filter }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
...importLoaders
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/preset.ts
|
|
35
|
+
const addons = [
|
|
36
|
+
"@storybook/addon-webpack5-compiler-swc",
|
|
37
|
+
"@storybook/addon-a11y",
|
|
38
|
+
"@storybook/addon-docs",
|
|
39
|
+
{
|
|
40
|
+
name: "@storybook/addon-styling-webpack",
|
|
41
|
+
options: { rules: [cssLoaders(), cssLoaders(/\.s[ac]ss$/, [{
|
|
42
|
+
loader: "sass-loader",
|
|
43
|
+
options: { implementation: "sass" }
|
|
44
|
+
}])] }
|
|
45
|
+
},
|
|
46
|
+
"storybook-addon-pseudo-states",
|
|
47
|
+
"@newhighsco/storybook-addon-svgr",
|
|
48
|
+
{
|
|
49
|
+
name: "@newhighsco/storybook-addon-transpile-modules",
|
|
50
|
+
options: { transpileModules: ["@newhighsco/chipset", "@newhighsco/press-start"] }
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const core = (config) => ({
|
|
54
|
+
...config,
|
|
55
|
+
disableTelemetry: true,
|
|
56
|
+
enableCrashReports: false
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
export { addons, core };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Controls, Description, Primary, Source, Stories, Subtitle, Title } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import React, { Fragment } from "react";
|
|
3
|
+
import { Spaced, TabWrapper } from "storybook/internal/components";
|
|
4
|
+
import { ThemeProvider, convert, ensure, themes } from "storybook/theming";
|
|
5
|
+
import { breakpoints } from "@newhighsco/chipset";
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/DocsPage/index.tsx
|
|
19
|
+
const DocsPage = () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Title, null), /* @__PURE__ */ React.createElement(Subtitle, null), /* @__PURE__ */ React.createElement(Description, null), /* @__PURE__ */ React.createElement(Source, null), /* @__PURE__ */ React.createElement(TabWrapper, null, /* @__PURE__ */ React.createElement(Primary, null)), /* @__PURE__ */ React.createElement(Controls, null), /* @__PURE__ */ React.createElement(Stories, { includePrimary: false }));
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/decorators/snapshot.jsx
|
|
22
|
+
const isSnapshotStory = (context) => {
|
|
23
|
+
const { parameters, viewMode } = context;
|
|
24
|
+
return parameters?.chromatic?.disableSnapshot === false && viewMode === "story";
|
|
25
|
+
};
|
|
26
|
+
const WithSnapshot = (Story, context) => {
|
|
27
|
+
if (!isSnapshotStory(context)) return /* @__PURE__ */ React.createElement(Story, null);
|
|
28
|
+
return /* @__PURE__ */ React.createElement(ThemeProvider, { theme: ensure(themes.normal) }, /* @__PURE__ */ React.createElement(Spaced, null, /* @__PURE__ */ React.createElement(Story, null)));
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/utils.tsx
|
|
32
|
+
const useDarkMode = () => {
|
|
33
|
+
const dark = convert().base === themes.dark.base;
|
|
34
|
+
return [dark, dark ? themes.dark : themes.light];
|
|
35
|
+
};
|
|
36
|
+
const viewports = Object.entries(breakpoints).reduce((viewports, [name, width]) => {
|
|
37
|
+
viewports[name] = {
|
|
38
|
+
name,
|
|
39
|
+
styles: {
|
|
40
|
+
width: `${width}px`,
|
|
41
|
+
height: "100%"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return viewports;
|
|
45
|
+
}, {});
|
|
46
|
+
const modes = (breakpoints) => Object.keys(viewports).reduce((modes, viewport) => {
|
|
47
|
+
if (!breakpoints?.length || breakpoints?.includes(viewport)) modes[viewport] = { viewport };
|
|
48
|
+
return modes;
|
|
49
|
+
}, {});
|
|
50
|
+
function snapshot(story, { args, decorator, parameters, tags = [] } = {}) {
|
|
51
|
+
const stories = Array.isArray(story) ? story : [story];
|
|
52
|
+
return {
|
|
53
|
+
render: (_, context) => stories.map((Story, key) => {
|
|
54
|
+
const props = {
|
|
55
|
+
...Story.args,
|
|
56
|
+
...args
|
|
57
|
+
};
|
|
58
|
+
const Component = context.component;
|
|
59
|
+
const children = Story.render?.(props, context) ?? /* @__PURE__ */ React.createElement(Component, props);
|
|
60
|
+
return /* @__PURE__ */ React.createElement(Fragment, { key }, decorator?.(children, context) ?? children);
|
|
61
|
+
}),
|
|
62
|
+
parameters: {
|
|
63
|
+
...parameters,
|
|
64
|
+
chromatic: {
|
|
65
|
+
...parameters?.chromatic,
|
|
66
|
+
disableSnapshot: false
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
tags: [
|
|
70
|
+
...tags,
|
|
71
|
+
"!autodocs",
|
|
72
|
+
"!test"
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/preview.ts
|
|
78
|
+
var preview_exports = /* @__PURE__ */ __exportAll({
|
|
79
|
+
decorators: () => decorators,
|
|
80
|
+
parameters: () => parameters
|
|
81
|
+
});
|
|
82
|
+
const [dark, theme] = useDarkMode();
|
|
83
|
+
const decorators = [WithSnapshot];
|
|
84
|
+
const parameters = {
|
|
85
|
+
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
86
|
+
chromatic: { modes: modes(["desktopLarge"]) },
|
|
87
|
+
controls: { matchers: {
|
|
88
|
+
color: /(background|color)$/i,
|
|
89
|
+
date: /Date$/
|
|
90
|
+
} },
|
|
91
|
+
docs: {
|
|
92
|
+
canvas: {
|
|
93
|
+
className: theme.base,
|
|
94
|
+
withToolbar: true
|
|
95
|
+
},
|
|
96
|
+
page: DocsPage,
|
|
97
|
+
source: { dark: !dark },
|
|
98
|
+
theme
|
|
99
|
+
},
|
|
100
|
+
viewMode: "docs",
|
|
101
|
+
viewport: { options: viewports }
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
104
|
+
export { snapshot as a, modes as i, parameters as n, viewports as o, preview_exports as r, decorators as t };
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Preview } from
|
|
1
|
+
import { Preview } from "@storybook/react-webpack5";
|
|
2
2
|
|
|
3
|
+
//#region src/preview.d.ts
|
|
3
4
|
declare const decorators: Preview['decorators'];
|
|
4
5
|
declare const parameters: Preview['parameters'];
|
|
5
|
-
|
|
6
|
-
export { decorators, parameters };
|
|
6
|
+
//#endregion
|
|
7
|
+
export { decorators, parameters };
|
package/dist/preview.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { n as parameters, t as decorators } from "./preview-Ba_0JMth.js";
|
|
2
|
+
export { decorators, parameters };
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newhighsco/storybook-preset",
|
|
3
3
|
"description": "New High Score shareable Storybook preset",
|
|
4
|
-
"version": "10.2.
|
|
4
|
+
"version": "10.2.34",
|
|
5
5
|
"author": "New High Score",
|
|
6
6
|
"license": "ISC",
|
|
7
|
-
"private": false,
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "https://github.com/newhighsco/storybook.git",
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
"types": "./dist/preview.d.ts",
|
|
25
24
|
"default": "./dist/preview.js"
|
|
26
25
|
},
|
|
27
|
-
"./preset": "./dist/preset.
|
|
26
|
+
"./preset": "./dist/preset.mjs",
|
|
28
27
|
"./package.json": "./package.json",
|
|
29
28
|
"./*.md?raw": "./*.md"
|
|
30
29
|
},
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
"scripts": {
|
|
36
35
|
"prepublishOnly": "yarn build",
|
|
37
36
|
"prebuild": "rm -rf dist",
|
|
38
|
-
"build": "
|
|
37
|
+
"build": "tsdown --log-level error"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
40
|
"@newhighsco/chipset": "7.0.0",
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
"@storybook/addon-styling-webpack": "3.0.2",
|
|
47
46
|
"@storybook/addon-webpack5-compiler-swc": "4.0.3",
|
|
48
47
|
"css-loader": "7.1.4",
|
|
49
|
-
"postcss": "8.5.
|
|
48
|
+
"postcss": "8.5.10",
|
|
50
49
|
"postcss-loader": "8.2.1",
|
|
51
50
|
"sass": "1.99.0",
|
|
52
51
|
"sass-loader": "16.0.7",
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/preset.
|
|
1
|
+
export * from './dist/preset.mjs'
|
package/dist/chunk-IHI4SI5P.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Title, Subtitle, Description, Source, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
|
|
2
|
-
import React, { Fragment } from 'react';
|
|
3
|
-
import { TabWrapper, Spaced } from 'storybook/internal/components';
|
|
4
|
-
import { convert, themes, ThemeProvider, ensure } from 'storybook/theming';
|
|
5
|
-
import { breakpoints } from '@newhighsco/chipset';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/preview.ts
|
|
14
|
-
var preview_exports = {};
|
|
15
|
-
__export(preview_exports, {
|
|
16
|
-
decorators: () => decorators,
|
|
17
|
-
parameters: () => parameters
|
|
18
|
-
});
|
|
19
|
-
var DocsPage = () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Title, null), /* @__PURE__ */ React.createElement(Subtitle, null), /* @__PURE__ */ React.createElement(Description, null), /* @__PURE__ */ React.createElement(Source, null), /* @__PURE__ */ React.createElement(TabWrapper, null, /* @__PURE__ */ React.createElement(Primary, null)), /* @__PURE__ */ React.createElement(Controls, null), /* @__PURE__ */ React.createElement(Stories, { includePrimary: false }));
|
|
20
|
-
var DocsPage_default = DocsPage;
|
|
21
|
-
var isSnapshotStory = (context) => {
|
|
22
|
-
const { parameters: parameters2, viewMode } = context;
|
|
23
|
-
return parameters2?.chromatic?.disableSnapshot === false && viewMode === "story";
|
|
24
|
-
};
|
|
25
|
-
var WithSnapshot = (Story, context) => {
|
|
26
|
-
if (!isSnapshotStory(context)) {
|
|
27
|
-
return /* @__PURE__ */ React.createElement(Story, null);
|
|
28
|
-
}
|
|
29
|
-
return /* @__PURE__ */ React.createElement(ThemeProvider, { theme: ensure(themes.normal) }, /* @__PURE__ */ React.createElement(Spaced, null, /* @__PURE__ */ React.createElement(Story, null)));
|
|
30
|
-
};
|
|
31
|
-
var useDarkMode = () => {
|
|
32
|
-
const dark2 = convert().base === themes.dark.base;
|
|
33
|
-
return [dark2, dark2 ? themes.dark : themes.light];
|
|
34
|
-
};
|
|
35
|
-
var viewports = Object.entries(
|
|
36
|
-
breakpoints
|
|
37
|
-
).reduce((viewports2, [name, width]) => {
|
|
38
|
-
viewports2[name] = { name, styles: { width: `${width}px`, height: "100%" } };
|
|
39
|
-
return viewports2;
|
|
40
|
-
}, {});
|
|
41
|
-
var modes = (breakpoints2) => Object.keys(viewports).reduce((modes2, viewport) => {
|
|
42
|
-
if (!breakpoints2?.length || breakpoints2?.includes(viewport)) {
|
|
43
|
-
modes2[viewport] = { viewport };
|
|
44
|
-
}
|
|
45
|
-
return modes2;
|
|
46
|
-
}, {});
|
|
47
|
-
function snapshot(story, { args, decorator, parameters: parameters2, tags = [] } = {}) {
|
|
48
|
-
const stories = Array.isArray(story) ? story : [story];
|
|
49
|
-
return {
|
|
50
|
-
render: (_, context) => stories.map((Story, key) => {
|
|
51
|
-
const props = { ...Story.args, ...args };
|
|
52
|
-
const Component = context.component;
|
|
53
|
-
const children = Story.render?.(props, context) ?? /* @__PURE__ */ React.createElement(Component, { ...props });
|
|
54
|
-
return /* @__PURE__ */ React.createElement(Fragment, { key }, decorator?.(children, context) ?? children);
|
|
55
|
-
}),
|
|
56
|
-
parameters: {
|
|
57
|
-
...parameters2,
|
|
58
|
-
chromatic: { ...parameters2?.chromatic, disableSnapshot: false }
|
|
59
|
-
},
|
|
60
|
-
tags: [...tags, "!autodocs", "!test"]
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// src/preview.ts
|
|
65
|
-
var [dark, theme] = useDarkMode();
|
|
66
|
-
var decorators = [WithSnapshot];
|
|
67
|
-
var parameters = {
|
|
68
|
-
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
69
|
-
chromatic: { modes: modes(["desktopLarge"]) },
|
|
70
|
-
controls: { matchers: { color: /(background|color)$/i, date: /Date$/ } },
|
|
71
|
-
docs: {
|
|
72
|
-
canvas: { className: theme.base, withToolbar: true },
|
|
73
|
-
page: DocsPage_default,
|
|
74
|
-
source: { dark: !dark },
|
|
75
|
-
theme
|
|
76
|
-
},
|
|
77
|
-
viewMode: "docs",
|
|
78
|
-
viewport: { options: viewports }
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { decorators, modes, parameters, preview_exports, snapshot, viewports };
|
package/dist/preset.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/loaders.ts
|
|
2
|
-
var filter = (url) => {
|
|
3
|
-
if (url.startsWith("/")) return false;
|
|
4
|
-
return true;
|
|
5
|
-
};
|
|
6
|
-
var cssLoaders = (test = /\.css$/, importLoaders = []) => {
|
|
7
|
-
importLoaders = [
|
|
8
|
-
{ loader: "postcss-loader", options: { implementation: "postcss" } },
|
|
9
|
-
...importLoaders
|
|
10
|
-
];
|
|
11
|
-
return {
|
|
12
|
-
test,
|
|
13
|
-
sideEffects: true,
|
|
14
|
-
use: [
|
|
15
|
-
"style-loader",
|
|
16
|
-
{
|
|
17
|
-
loader: "css-loader",
|
|
18
|
-
options: {
|
|
19
|
-
esModule: false,
|
|
20
|
-
import: { filter },
|
|
21
|
-
importLoaders: importLoaders.length,
|
|
22
|
-
modules: {
|
|
23
|
-
exportLocalsConvention: "as-is",
|
|
24
|
-
localIdentName: "[name]_[local]__[hash:base64:5]"
|
|
25
|
-
},
|
|
26
|
-
url: { filter }
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
...importLoaders
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/preset.ts
|
|
35
|
-
var addons = [
|
|
36
|
-
"@storybook/addon-webpack5-compiler-swc",
|
|
37
|
-
"@storybook/addon-a11y",
|
|
38
|
-
"@storybook/addon-docs",
|
|
39
|
-
{
|
|
40
|
-
name: "@storybook/addon-styling-webpack",
|
|
41
|
-
options: {
|
|
42
|
-
rules: [
|
|
43
|
-
cssLoaders(),
|
|
44
|
-
cssLoaders(/\.s[ac]ss$/, [
|
|
45
|
-
{ loader: "sass-loader", options: { implementation: "sass" } }
|
|
46
|
-
])
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"storybook-addon-pseudo-states",
|
|
51
|
-
"@newhighsco/storybook-addon-svgr",
|
|
52
|
-
{
|
|
53
|
-
name: "@newhighsco/storybook-addon-transpile-modules",
|
|
54
|
-
options: {
|
|
55
|
-
transpileModules: ["@newhighsco/chipset", "@newhighsco/press-start"]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
|
-
var core = (config) => ({
|
|
60
|
-
...config,
|
|
61
|
-
disableTelemetry: true,
|
|
62
|
-
enableCrashReports: false
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export { addons, core };
|