Skip to content

Commit 718a1e7

Browse files
committed
refactor: Add storybook + initial story
1 parent bf90ded commit 718a1e7

File tree

5 files changed

+8198
-180
lines changed

5 files changed

+8198
-180
lines changed

.storybook/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
"stories": [
5+
"../site/**/*.stories.mdx",
6+
"../site/**/*.stories.@(js|jsx|ts|tsx)"
7+
],
8+
"addons": [
9+
"@storybook/addon-links",
10+
"@storybook/addon-essentials",
11+
],
12+
babel: async (options) => ({
13+
...options,
14+
"plugins": ["@babel/plugin-proposal-class-properties"]
15+
// any extra options you want to set
16+
}),
17+
webpackFinal: async (config) => {
18+
config.resolve.modules = [
19+
path.resolve(__dirname, ".."),
20+
"node_modules",
21+
]
22+
23+
return config;
24+
}
25+
}

.storybook/preview.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import ThemeProvider from "@material-ui/styles/ThemeProvider"
2+
import { withThemes } from '@react-theming/storybook-addon'
3+
import { light, dark } from '../site/theme'
4+
import { addDecorator } from 'node_modules/@storybook/react'
5+
6+
addDecorator(withThemes(
7+
ThemeProvider,
8+
[light, dark]
9+
))
10+
11+
export const parameters = {
12+
actions: {
13+
argTypesRegex: "^on[A-Z].*",
14+
argTypesRegex: "^handle[A-Z].*",
15+
},
16+
controls: {
17+
expanded: true,
18+
matchers: {
19+
color: /(background|color)$/i,
20+
date: /Date$/,
21+
},
22+
},
23+
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
"format:write": "prettier --write '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}' && sql-formatter -l postgresql ./database/query.sql -o ./database/query.sql",
1313
"lint": "jest --selectProjects lint",
1414
"lint:fix": "FIX=true yarn lint",
15+
"storybook": "start-storybook -p 6006 -s ./site/static",
1516
"test": "jest --selectProjects test",
1617
"test:coverage": "jest --selectProjects test --collectCoverage"
1718
},
1819
"devDependencies": {
1920
"@material-ui/core": "4.9.4",
2021
"@material-ui/icons": "4.5.1",
2122
"@material-ui/lab": "4.0.0-alpha.42",
23+
"@react-theming/storybook-addon": "1.1.3",
24+
"@storybook/addon-actions": "6.3.12",
25+
"@storybook/addon-essentials": "6.3.12",
26+
"@storybook/addon-links": "6.3.12",
27+
"@storybook/react": "6.3.12",
2228
"@testing-library/react": "12.1.2",
2329
"@types/express": "4.17.13",
2430
"@types/jest": "27.4.0",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Story } from "@storybook/react"
2+
import React from "react"
3+
import { LoadingButton, LoadingButtonProps } from "./LoadingButton"
4+
5+
export default {
6+
title: "Button/LoadingButton",
7+
component: LoadingButton,
8+
argTypes: {
9+
loading: { control: { type: "boolean" } },
10+
children: { control: "text", defaultValue: "Create workspace" },
11+
},
12+
}
13+
14+
const Template: Story<LoadingButtonProps> = (args) => <LoadingButton {...args} />
15+
16+
export const Loading = Template.bind({})
17+
Loading.args = {
18+
variant: "contained",
19+
loading: true,
20+
}
21+
22+
export const NotLoading = Template.bind({})
23+
NotLoading.args = {
24+
variant: "contained",
25+
loading: false
26+
}

0 commit comments

Comments
 (0)