-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add storybook + initial story (#118)
This hooks up `storybook`, which the front-end team has enjoyed using in the v1 codebase - it makes it quick and easy to view and test components in isolation. The `<LoadingButton />` has a simple story added now, so if you run `yarn storybook`, you can preview it in various states: ![2022-01-31 19 24 24](https://user-images.githubusercontent.com/88213859/151908656-27dac0a8-9c6e-4353-ad25-3eafee979bd4.gif) This will be helpful as we bring more front-end devs to help build v2 out.
- Loading branch information
1 parent
c65850b
commit 94f71fe
Showing
10 changed files
with
8,146 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules | |
vendor | ||
out | ||
coverage | ||
.next | ||
.next | ||
storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ yarn-error.log | |
.next/ | ||
coverage/ | ||
out/ | ||
storybook-static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require("path") | ||
|
||
module.exports = { | ||
stories: ["../**/*.stories.mdx", "../**/*.stories.@(js|jsx|ts|tsx)"], | ||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"], | ||
babel: async (options) => ({ | ||
...options, | ||
plugins: ["@babel/plugin-proposal-class-properties"], | ||
// any extra options you want to set | ||
}), | ||
webpackFinal: async (config) => { | ||
config.resolve.modules = [path.resolve(__dirname, ".."), "node_modules"] | ||
|
||
return config | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ThemeProvider from "@material-ui/styles/ThemeProvider" | ||
import { withThemes } from "@react-theming/storybook-addon" | ||
import { light, dark } from "../theme" | ||
import { addDecorator } from "node_modules/@storybook/react" | ||
|
||
addDecorator(withThemes(ThemeProvider, [light, dark])) | ||
|
||
export const parameters = { | ||
actions: { | ||
argTypesRegex: "^on[A-Z].*", | ||
argTypesRegex: "^handle[A-Z].*", | ||
}, | ||
controls: { | ||
expanded: true, | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Story } from "@storybook/react" | ||
import React from "react" | ||
import { LoadingButton, LoadingButtonProps } from "./LoadingButton" | ||
|
||
export default { | ||
title: "Button/LoadingButton", | ||
component: LoadingButton, | ||
argTypes: { | ||
loading: { control: { type: "boolean" } }, | ||
children: { control: "text", defaultValue: "Create workspace" }, | ||
}, | ||
} | ||
|
||
const Template: Story<LoadingButtonProps> = (args) => <LoadingButton {...args} /> | ||
|
||
export const Loading = Template.bind({}) | ||
Loading.args = { | ||
variant: "contained", | ||
loading: true, | ||
} | ||
|
||
export const NotLoading = Template.bind({}) | ||
NotLoading.args = { | ||
variant: "contained", | ||
loading: false, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.