Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
.cache
dist
.parcel-cache
.yalc
.yalc
*storybook.log
45 changes: 45 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import type { WebpackConfiguration } from '@storybook/core-webpack';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-webpack5-compiler-swc',
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-styling-webpack',
'@storybook/preset-scss'
],
framework: {
name: '@storybook/react-webpack5',
options: {
strictMode: true,
},
},
webpackFinal: async (currentConfig: WebpackConfiguration, { configType }) => {
// get index of css rule
const ruleCssIndex = currentConfig.module.rules.findIndex(
(rule) => rule.test?.toString() === "/\\.css$/"
);

// map over the 'use' array of the css rule and set the 'module' option to true
currentConfig.module.rules[ruleCssIndex].use.map((item) => {
if (item.loader && item.loader.includes("/css-loader/")) {
item.options.modules = {
mode: "local",
localIdentName:
configType === "PRODUCTION"
? "[local]__[hash:base64:5]"
: "[name]__[local]__[hash:base64:5]",
};
}

return item;
});

return currentConfig;
},
};
export default config;
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
tags: ['autodocs']
};

export default preview;
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ To run tests, use `npm test` or `yarn test`.

Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.

### Storybook commands

```bash
npm run storybook
```

```bash
npm run build-storybook
```

### Jest

Jest tests are set up to run with `npm test` or `yarn test`.
Expand Down
Loading