Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/storybook #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"storybook-addon-designs"
]
}
12 changes: 12 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ThemeProvider } from 'styled-components'
import { theme } from 'resources/theme'
import { GlobalStyle } from '../src/root'

export const decorators = [
(Story) => (
<ThemeProvider theme={theme}>
<GlobalStyle />
<Story />
</ThemeProvider>
)
]
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"lint": "eslint src --ext ts,tsx --no-eslintrc --config .eslintrc-default.json",
"lint:fix": "yarn lint --fix",
"type-check": "tsc --project tsconfig.json --pretty --noEmit",
"prepare": "husky install"
"prepare": "husky install",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
Expand All @@ -33,7 +35,17 @@
"web-vitals": "^1.0.1"
},
"eslintConfig": {
"extends": "./.eslintrc.json"
"extends": "./.eslintrc.json",
"overrides": [
{
"files": [
"**/*.stories.*"
],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
},
"browserslist": {
"production": [
Expand All @@ -48,6 +60,12 @@
]
},
"devDependencies": {
"@storybook/addon-actions": "^6.3.10",
"@storybook/addon-essentials": "^6.3.10",
"@storybook/addon-links": "^6.3.10",
"@storybook/node-logger": "^6.3.10",
"@storybook/preset-create-react-app": "^3.2.0",
"@storybook/react": "^6.3.10",
"@types/marked": "^3.0.1",
"@types/styled-components": "^5.1.14",
"@types/uuid": "^8.3.1",
Expand All @@ -60,6 +78,7 @@
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-promise": "5.1.0",
"eslint-plugin-react": "7.25.2",
"husky": "^7.0.2"
"husky": "^7.0.2",
"storybook-addon-designs": "^6.2.0"
}
}
2 changes: 1 addition & 1 deletion src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ const GlobalStyle = createGlobalStyle`
}
`

export { Root }
export { Root, GlobalStyle }
1 change: 0 additions & 1 deletion src/ui/components/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type ContentProps = {
function Content({
file,
inputRef,

handleUpdateTitle,
handleUpdateFile,
}: ContentProps) {
Expand Down
27 changes: 27 additions & 0 deletions src/ui/screens/addonFigma/test.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// eslint-disable-next-line no-use-before-define
import React from 'react'
import { ComponentMeta } from '@storybook/react'
import { withDesign } from 'storybook-addon-designs'

type ButtonProps = {
children: React.ReactNode
}

function Button({ children }: ButtonProps) {
return <button>{children}</button>
}

export const myStory = () => <Button><span>Hello, World!</span></Button>

myStory.parameters = {
design: {
type: 'figma',
url: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File',
},
}

export default {
title: 'My stories',
component: Button,
decorators: [withDesign],
} as ComponentMeta<typeof Button>
15 changes: 15 additions & 0 deletions src/ui/screens/home/home.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ComponentStory, ComponentMeta } from '@storybook/react'

import { Home } from '.'

export default {
title: 'Example/Home',
component: Home,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof Home>

const Template: ComponentStory<typeof Home> = () => <Home />

export const Example = Template.bind({})
Loading