Skip to content

Commit b6aedef

Browse files
committed
feat(example): add Storybook for example app
Add storybook and stories for example app Resolves #71 Signed-off-by: Niloy Sikdar <niloysikdar30@gmail.com>
1 parent aae13a6 commit b6aedef

File tree

7 files changed

+9865
-3
lines changed

7 files changed

+9865
-3
lines changed

example/.babelrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// .babelrc
2+
3+
{
4+
"presets": [
5+
"@babel/preset-env",
6+
"@babel/preset-typescript",
7+
["@babel/preset-react", { "runtime": "automatic" }]
8+
]
9+
}

example/.storybook/main.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
3+
addons: [
4+
'@storybook/addon-links',
5+
'@storybook/addon-essentials',
6+
'@storybook/addon-interactions',
7+
],
8+
framework: '@storybook/react',
9+
};

example/.storybook/preview.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: '^on[A-Z].*' },
3+
controls: {
4+
matchers: {
5+
color: /(background|color)$/i,
6+
date: /Date$/,
7+
},
8+
},
9+
};

example/package.json

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@
66
"prepare": "yarn build",
77
"build": "rm -rf lib && yarn build:esm && yarn build:cjs",
88
"build:esm": "tsc -p tsconfig.json",
9-
"build:cjs": "tsc -p tsconfig.json --module commonjs --outDir lib/cjs --target es2015"
9+
"build:cjs": "tsc -p tsconfig.json --module commonjs --outDir lib/cjs --target es2015",
10+
"storybook": "start-storybook -p 6006",
11+
"build-storybook": "build-storybook -o docs-build"
1012
},
1113
"dependencies": {
1214
"@leopardslab/react-email": "file:leopardslab-react-email-1.7.0.tgz"
1315
},
1416
"devDependencies": {
17+
"@babel/core": "^7.18.10",
18+
"@babel/preset-env": "^7.18.10",
19+
"@babel/preset-react": "^7.18.6",
20+
"@babel/preset-typescript": "^7.18.6",
21+
"@storybook/addon-actions": "^6.5.10",
22+
"@storybook/addon-essentials": "^6.5.10",
23+
"@storybook/addon-interactions": "^6.5.10",
24+
"@storybook/addon-links": "^6.5.10",
25+
"@storybook/builder-webpack4": "^6.5.10",
26+
"@storybook/manager-webpack4": "^6.5.10",
27+
"@storybook/react": "^6.5.10",
28+
"@storybook/testing-library": "^0.0.13",
29+
"babel-loader": "^8.2.5",
30+
"react": "^18.2.0",
31+
"react-dom": "^18.2.0",
1532
"typescript": "^4.7.4"
1633
}
1734
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { ComponentStory, ComponentMeta } from '@storybook/react';
3+
4+
import { HelloEmail } from './HelloEmail';
5+
6+
export default {
7+
component: HelloEmail,
8+
} as ComponentMeta<typeof HelloEmail>;
9+
10+
//“template” of how args map to rendering
11+
const Template: ComponentStory<typeof HelloEmail> = (args) => <HelloEmail {...args} />;
12+
13+
export const Default = Template.bind({});

example/tsconfig.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818
"allowSyntheticDefaultImports": true
1919
},
2020
"include": ["src/**/*"],
21-
"exclude": ["node_modules", "lib"]
21+
"exclude": [
22+
"node_modules",
23+
"**/*.test.ts",
24+
"**/*.test.tsx",
25+
"**/*.stories.ts",
26+
"**/*.stories.tsx"
27+
]
2228
}

0 commit comments

Comments
 (0)