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

Bump @storybook/react to ^7.4.2 #1656

Merged
merged 19 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ab3c0de
chore(deps): bump storybook to ^7.4.2 from ^6.5.16
yangwooseong Sep 19, 2023
600eb1f
feat(storybook/config): auto migrate main file
yangwooseong Sep 19, 2023
f402821
feat(storybook): get rid of dynamic title and use optional title feature
yangwooseong Sep 21, 2023
c17235c
feat(storybook): resolve errors caused by component absense
yangwooseong Sep 21, 2023
9c15669
fix(storybook): fix typo in Typography story
yangwooseong Sep 21, 2023
daa42b7
feat(storybook): run codemod to migrate to CSF3
yangwooseong Sep 22, 2023
f4751c4
feat(storybook): resolves type error caused by type inference
yangwooseong Sep 22, 2023
363c394
feat(storybook): remove type assertion
yangwooseong Sep 22, 2023
04420bc
feat(storybook): move options filed to be sibling of control field
yangwooseong Sep 28, 2023
41c453b
chore(bezier-react): add changeset
yangwooseong Oct 4, 2023
07b28c1
style(storybook): fix lint error
yangwooseong Oct 4, 2023
6103b87
refactor(storybook): migrate main config file to typescript
yangwooseong Oct 5, 2023
6b5dad9
chore(storybook): rm @storybook/addon-mdx-gfm since it is not used an…
yangwooseong Oct 5, 2023
3aca1b3
refactor(storybook): use satisfies and enhance type inference in Alph…
yangwooseong Oct 11, 2023
3b13193
feat(storybook): migrate preview to ts file
yangwooseong Oct 16, 2023
e89027b
refactor(storybook): rm duplication in config
yangwooseong Oct 24, 2023
0c85f07
style(storybook): add new line
yangwooseong Oct 24, 2023
4dad50d
Revert "chore(bezier-react): add changeset"
yangwooseong Oct 24, 2023
7ea1b34
Merge branch 'main' into feat/migrate-to-storybook-7
yangwooseong Oct 27, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,6 @@ const FoundationKeyword = {
Dark: 'dark',
}

export const parameters = {
layout: 'centered',
backgrounds: {
default: 'light',
values: [
{
name: 'light',
value: 'white',
},
{
name: 'dark',
value: '#2f3233',
},
],
}
}

export const globalTypes = {
Foundation: {
name: 'Foundation',
description: 'Global Foundation for components',
defaultValue: 'light',
toolbar: {
icon: 'circlehollow',
items: [FoundationKeyword.Light, FoundationKeyword.Dark],
},
},
};

function getFoundation(keyword) {
const isDarkFoundation = keyword === FoundationKeyword.Dark
return {
Expand Down Expand Up @@ -87,7 +58,7 @@ const innerWrapperStyle = {
borderRadius: 20,
}

function withFoundationProvider(Story, context) {
export function WithFoundationProvider(Story, context) {
Copy link
Collaborator Author

@yangwooseong yangwooseong Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WithFoundationProvider.jsx 를 tsx 로 변경하려면 tsconfig.include 에 파일을 포함시키고 rootDir를 '.' 로 해야되는데, 그러면 타입 빌드 결과가 달라지게 되서 jsx 그대로 두었습니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

복잡한 설정 없이 타이핑 이점을 누리기 위해서 아예 preview.ts 내부로 옮기는 건 어떤가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 src/ 폴더를 의미하신 걸까요?

Copy link
Contributor

@sungik-choi sungik-choi Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.storybook/preview.ts 에요. 해당 파일안에 직접 작성하면 컴파일하지 않아도 괜찮지 않을까? 싶었습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preview.ts 로 넣으면 path alias 를 사용못하게 되서 ../src/... 이런 식으로 import 를 해야하는데, 그렇게 하면 Text 컴포넌트 타입을 다르게 읽어서 타입 에러가 뜹니다. 이 부분에 대한 원인을 찾지 못했습니다.

image

const {
isDarkFoundation,
foundation,
Expand Down Expand Up @@ -143,5 +114,3 @@ function withFoundationProvider(Story, context) {
</FeatureProvider>
)
}

export const decorators = [withFoundationProvider]
55 changes: 0 additions & 55 deletions packages/bezier-react/.storybook/main.js

This file was deleted.

80 changes: 80 additions & 0 deletions packages/bezier-react/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { dirname, join } from "path"

import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
import { type StorybookConfig } from '@storybook/react-webpack5'

function getAbsolutePath(value) {
return dirname(require.resolve(join(value, "package.json")))
}

const config: StorybookConfig = {
stories: [
'../src/**/*.stories.(tsx|mdx)',
],

addons: [
getAbsolutePath("@storybook/addon-controls"),
getAbsolutePath("@storybook/addon-actions"),
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/addon-toolbars"),
getAbsolutePath("@storybook/addon-docs"),
getAbsolutePath("@storybook/addon-backgrounds"),
],

typescript: {
/**
* @note
*
* `react-docgen-typescript-plugin` introduces significant overhead
* when HMR is enabled, so we enable it only in production.
*/
reactDocgen: process.env.NODE_ENV === 'production' && 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldRemoveUndefinedFromOptional: true,
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},

webpackFinal: async (config) => {
config.resolve = {
...config.resolve,
// Apply tsconfig alias path
plugins: [
...(config?.resolve?.plugins ?? []),
new TsconfigPathsPlugin({}),
],
extensions: [
...(config.resolve?.extensions ?? []),
'.ts',
'.tsx',
]
}
Comment on lines +39 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중요하진 않지만, 나중에 Vite로 마이그레이션도 해볼만할 거 같아요.


config.module = {
...config.module,
rules: [
...(config.module?.rules ?? []), {
test: /\.(ts|tsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [['react-app', { flow: false, typescript: true }]],
}
}
]
}

return config
},

framework: {
name: '@storybook/react-webpack5',
options: {}
},

docs: {
autodocs: true
}
}

export default config
9 changes: 9 additions & 0 deletions packages/bezier-react/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Preview } from "@storybook/react"

import { WithFoundationProvider } from './WithFoundationProvider'

const preview: Preview = {
decorators: [WithFoundationProvider],
}

export default preview
22 changes: 11 additions & 11 deletions packages/bezier-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"clean:build": "rm -rf dist",
"clean:cache": "rm -rf node_modules .turbo .eslintcache .stylelintcache tsconfig.tsbuildinfo coverage .jestcache",
"prebuild": "yarn clean:build",
"storybook": "start-storybook -p 4101",
"build-storybook": "build-storybook",
"storybook": "storybook dev -p 4101",
"build-storybook": "storybook build",
"chromatic": "chromatic --project-token=06157a6fbe6f"
},
"keywords": [
Expand Down Expand Up @@ -70,15 +70,14 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.3",
"@rollup/plugin-url": "^8.0.1",
"@storybook/addon-a11y": "^6.5.16",
"@storybook/addon-actions": "^6.5.16",
"@storybook/addon-backgrounds": "^6.5.16",
"@storybook/addon-controls": "^6.5.16",
"@storybook/addon-docs": "^6.5.16",
"@storybook/addon-toolbars": "^6.5.16",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/addon-a11y": "^7.4.2",
"@storybook/addon-actions": "^7.4.2",
"@storybook/addon-backgrounds": "^7.4.2",
"@storybook/addon-controls": "^7.4.2",
"@storybook/addon-docs": "^7.4.2",
"@storybook/addon-toolbars": "^7.4.2",
"@storybook/react": "^7.4.2",
"@storybook/react-webpack5": "^7.4.2",
"@storybook/storybook-deployer": "^2.8.16",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
Expand All @@ -103,6 +102,7 @@
"rollup": "^3.29.1",
"rollup-plugin-node-externals": "^6.1.1",
"rollup-plugin-visualizer": "^5.9.2",
"storybook": "^7.4.2",
"styled-components": "^5.3.11",
"ts-prune": "^0.10.3",
"tsconfig": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@ import React from 'react'

import {
type Meta,
type Story,
type StoryFn,
} from '@storybook/react'
import base from 'paths.macro'

import { getTitle } from '~/src/utils/storyUtils'

import { Text } from '~/src/components/Text'

import { AlphaCenter } from './AlphaCenter'
import { type AlphaCenterProps } from './AlphaCenter.types'

export default {
title: getTitle(base),
const meta: Meta<typeof AlphaCenter> = {
component: AlphaCenter,
} as Meta<AlphaCenterProps>
}
export default meta

const Template: Story<AlphaCenterProps> = ({ children, ...rest }) => (
const Template: StoryFn<AlphaCenterProps> = ({ children, ...rest }) => (
<AlphaCenter {...rest}>
<Text color="txt-black-darkest">
{ children }
</Text>
</AlphaCenter>
)

export const Primary = Template.bind({})
export const Primary = {
render: Template,

Primary.args = {
style: {
width: '200px',
height: '200px',
args: {
style: {
width: '200px',
height: '200px',
},
children: 'Centered content',
},
children: 'Centered content',
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import React from 'react'

import {
type Meta,
type Story,
type StoryFn,
} from '@storybook/react'
import { base } from 'paths.macro'

import { getTitle } from '~/src/utils/storyUtils'

import { AlphaSmoothCornersBox } from './AlphaSmoothCornersBox'
import { type AlphaSmoothCornersBoxProps } from './AlphaSmoothCornersBox.types'

export default {
title: getTitle(base),
const meta:Meta = {
component: AlphaSmoothCornersBox,
} as Meta
}
export default meta

const Template: Story<AlphaSmoothCornersBoxProps> = ({ children, ...otherCheckboxProps }) => (
const Template: StoryFn<AlphaSmoothCornersBoxProps> = ({
children,
...otherCheckboxProps
}) => (
<AlphaSmoothCornersBox
style={{ width: 200, height: 200 }}
{...otherCheckboxProps}
Expand All @@ -25,18 +25,21 @@ const Template: Story<AlphaSmoothCornersBoxProps> = ({ children, ...otherCheckbo
</AlphaSmoothCornersBox>
)

export const Primary = Template.bind({})
Primary.args = {
disabled: false,
borderRadius: '42%',
shadow: {
offsetX: 0,
offsetY: 0,
blurRadius: 10,
spreadRadius: 10,
color: 'bg-black-dark',
export const Primary = {
render: Template,

args: {
disabled: false,
borderRadius: '42%',
shadow: {
offsetX: 0,
offsetY: 0,
blurRadius: 10,
spreadRadius: 10,
color: 'bg-black-dark',
},
margin: 0,
backgroundColor: 'bgtxt-absolute-white-normal',
backgroundImage: '',
},
margin: 0,
backgroundColor: 'bgtxt-absolute-white-normal',
backgroundImage: '',
}
Loading