Skip to content

Commit

Permalink
Merge pull request #48 from kash9350/create-user-button-component
Browse files Browse the repository at this point in the history
Storybook configuration with 2 stories added
  • Loading branch information
lakhansamani authored Aug 24, 2024
2 parents 0f0e2af + 10086ff commit 9c756b7
Show file tree
Hide file tree
Showing 24 changed files with 19,456 additions and 8,875 deletions.
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

0 comments on commit 9c756b7

Please sign in to comment.