Skip to content

Commit 9f485e4

Browse files
committed
fix: fixed storybook
1 parent 82851e8 commit 9f485e4

File tree

6 files changed

+2448
-425
lines changed

6 files changed

+2448
-425
lines changed

packages/react/.storybook/main.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { StorybookConfig } from "@storybook/react-webpack5";
2+
3+
import { join, dirname } from "path";
4+
5+
/**
6+
* This function is used to resolve the absolute path of a package.
7+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
8+
*/
9+
function getAbsolutePath(value: string): any {
10+
return dirname(require.resolve(join(value, "package.json")));
11+
}
12+
const config: StorybookConfig = {
13+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
14+
addons: [
15+
getAbsolutePath("@storybook/addon-webpack5-compiler-swc"),
16+
getAbsolutePath("@storybook/addon-onboarding"),
17+
getAbsolutePath("@storybook/addon-links"),
18+
getAbsolutePath("@storybook/addon-essentials"),
19+
getAbsolutePath("@chromatic-com/storybook"),
20+
getAbsolutePath("@storybook/addon-interactions"),
21+
getAbsolutePath("@storybook/addon-storysource"),
22+
],
23+
framework: {
24+
name: getAbsolutePath("@storybook/react-webpack5"),
25+
options: {},
26+
},
27+
};
28+
export default config;

packages/react/.storybook/preview.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
const preview: Preview = {
4+
parameters: {
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/i,
9+
},
10+
},
11+
},
12+
};
13+
14+
export default preview;

packages/react/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,44 @@
1010
"@babel/preset-env": "^7.10.4",
1111
"@babel/preset-react": "^7.10.4",
1212
"@babel/preset-typescript": "^7.10.4",
13+
"@chromatic-com/storybook": "1.6.1",
1314
"@storybook/addon-essentials": "^8.1.11",
1415
"@storybook/addon-interactions": "^8.1.11",
1516
"@storybook/addon-links": "^8.1.11",
1617
"@storybook/addon-onboarding": "^8.1.11",
18+
"@storybook/addon-storysource": "^8.1.11",
19+
"@storybook/addon-webpack5-compiler-swc": "1.0.4",
1720
"@storybook/blocks": "^8.1.11",
1821
"@storybook/react": "^8.1.11",
19-
"@storybook/react-vite": "^8.1.11",
22+
"@storybook/react-webpack5": "^8.1.11",
2023
"@storybook/test": "^8.1.11",
2124
"@testing-library/jest-dom": "^5.11.1",
2225
"@testing-library/react": "^10.4.7",
2326
"@types/jest": "^26.0.7",
2427
"@types/react": "^16.9.43",
2528
"babel-loader": "^8.1.0",
26-
"chromatic": "^11.5.5",
2729
"jest": "^26.1.0",
2830
"react": "^16.13.1",
2931
"rollup": "^2.22.1",
3032
"rollup-plugin-typescript2": "^0.27.1",
33+
"storybook": "^8.1.11",
3134
"typescript": "^5.4.5"
3235
},
3336
"scripts": {
3437
"build": "rollup -c",
3538
"dev": "yarn build --watch",
3639
"test": "jest --verbose",
3740
"test:watch": "yarn test --watch",
38-
"test:chromatic": "chromatic --project-token=\"$CHROMATIC_PROJECT_TOKEN\""
41+
"test:chromatic": "chromatic --project-token=\"$CHROMATIC_PROJECT_TOKEN\"",
42+
"storybook": "storybook dev -p 6006",
43+
"build-storybook": "storybook build"
3944
},
4045
"publishConfig": {
4146
"access": "public"
4247
},
4348
"dependencies": {
44-
"@storybook/addon-knobs": "^8.0.1",
45-
"@test.ds.e/foundation": "^1.0.2"
49+
"@test.ds.e/foundation": "^1.0.2",
50+
"@test.ds.e/scss": "^1.0.2"
4651
},
4752
"gitHead": "ed66e502dd009938406950b3d81f0d16c41b51b7"
4853
}
Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
11
import React from 'react'
2-
import Color from './Color'
3-
import { text, select } from '@storybook/addon-knobs'
2+
import Color, { ColorProps } from './Color'
43

54
import { Spacing } from '@test.ds.e/foundation'
65

76
// css
8-
import '@ds.e/scss/lib/Utilities.css'
7+
import '@test.ds.e/scss/lib/Utilities.css'
98

109
export default {
1110
title: 'Atoms|Color'
1211
}
1312

14-
export const Common = () => <Color hexCode={text('HexCode', 'pink')} />
13+
export const Common = (args: React.JSX.IntrinsicAttributes & ColorProps & { children?: React.ReactNode }) => (
14+
<Color {...args} />
15+
)
16+
Common.args = {
17+
primary: true,
18+
hexCode: 'pink'
19+
}
20+
21+
export const CustomDimensions = (args: React.JSX.IntrinsicAttributes & ColorProps & { children?: React.ReactNode }) => (
22+
<Color {...args} />
23+
)
24+
25+
CustomDimensions.args = {
26+
primary: true,
27+
hexCode: 'pink',
28+
width: 'xxl',
29+
height: 'xxl',
30+
}
31+
32+
CustomDimensions.argTypes = {
33+
width: {
34+
control: 'select',
35+
options: Object.values(Spacing),
36+
},
37+
height: {
38+
control: 'select',
39+
options: Object.values(Spacing),
40+
},
41+
hexCode: {
42+
control: 'color',
43+
}
44+
}
45+
46+
47+
// export const Common = () => <Color hexCode={text('HexCode', 'pink')} />
1548

16-
export const CustomDimensions = () => <Color
17-
hexCode={text('HexCode', 'pink')}
18-
width={select('Width', Object.values(Spacing), 'xxl')}
19-
height={select('Height', Object.values(Spacing), 'xxl')} />
49+
// export const CustomDimensions = () => <Color
50+
// hexCode={text('HexCode', 'pink')}
51+
// width={select('Width', Object.values(Spacing), 'xxl')}
52+
// height={select('Height', Object.values(Spacing), 'xxl')} />

packages/react/src/molecules/Select/Select.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Select from './Select'
33
// import { withA11Y } from '@storybook/addon-a11y'
44

55
// css
6-
import '@ds.e/scss/lib/Select.css'
6+
import '@test.ds.e/scss/lib/Select.css'
77

88
const options = [{
99
label: 'Strict Black',

0 commit comments

Comments
 (0)