Skip to content

Commit 4315e2d

Browse files
committed
feat: add basic local storybook implementation for newspack-ui
1 parent 01c34f8 commit 4315e2d

File tree

10 files changed

+15749
-1916
lines changed

10 files changed

+15749
-1916
lines changed

.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@ module.exports = {
77
newspack_aux_data: 'readonly',
88
},
99
ignorePatterns: [ '*/dist/', '*/node_modules/', '*/release' ],
10+
overrides: [
11+
{
12+
files: [ '.storybook/**/*.js' ],
13+
rules: {
14+
'import/no-unresolved': 'off',
15+
'import/no-extraneous-dependencies': 'off'
16+
}
17+
}
18+
]
1019
};

.storybook/main.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const config = {
2+
stories: [
3+
'../storybook/**/*.mdx',
4+
'../storybook/**/*.stories.@(js|jsx|mjs|ts|tsx)',
5+
'../src/**/*.mdx',
6+
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
7+
],
8+
addons: [
9+
'@storybook/addon-links',
10+
'@storybook/addon-essentials',
11+
'@storybook/addon-interactions',
12+
],
13+
framework: {
14+
name: '@storybook/react-webpack5',
15+
options: {},
16+
},
17+
docs: {
18+
autodocs: 'tag',
19+
},
20+
webpackFinal: async (config) => {
21+
// Add SASS support
22+
config.module.rules.push({
23+
test: /\.scss$/,
24+
use: ['style-loader', 'css-loader', 'sass-loader'],
25+
});
26+
27+
return config;
28+
},
29+
};
30+
31+
export default config;

.storybook/preview.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import '../src/newspack-ui/style.scss';
2+
3+
/** @type { import('@storybook/react').Preview } */
4+
const preview = {
5+
parameters: {
6+
actions: { argTypesRegex: "^on[A-Z].*" },
7+
controls: {
8+
matchers: {
9+
color: /(background|color)$/i,
10+
date: /Date$/,
11+
},
12+
},
13+
},
14+
decorators: [
15+
(Story) => (
16+
<div style={{ margin: '2em' }}>
17+
<Story />
18+
</div>
19+
),
20+
],
21+
};
22+
23+
export default preview;

0 commit comments

Comments
 (0)