-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactor Storybook <Button /> #213
Conversation
// TODO: fix warn "Rendered more hooks than during the previous render." | ||
// knobを完全に排除できたタイミングで再度調査 | ||
// strictMode: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo
@@ -58,6 +58,7 @@ export default { | |||
title: "NavigationRail", | |||
parameters: { | |||
component: NavigationRail, | |||
layout: "fullscreen", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
デフォルトではcanvasにpadding
が付与されているが、サイドバーなどのコンポーネントにとっては不要。
argTypes={ | ||
{ onClick: { action: "clicked" } } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Canvas> | ||
<Story | ||
name="something" | ||
args={{}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実際に生成するとargs=
みたいな感じで、何も書かれない。
args={{{{}}}}
みたいに書くとシンタックスエラーみたいなのが出る
@@ -1,5 +1,7 @@ | |||
import * as React from "react"; | |||
import { ThemeProvider, createTheme } from "../src/themes"; | |||
import "@storybook/addon-console"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters: { | ||
docs: { page: null }, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現行の.stories.tsx
はDocsタブ常にデフォルトのものが表示されるが、
- 情報量が足りない
- コンポーネントによっては見辛い
ということで共通で見れないようにした。
<Canvas> | ||
<Story | ||
name="primary" | ||
args={{ | ||
color: "primary", | ||
children: "primary", | ||
}} | ||
> | ||
{(args) => <Button {...args} />} | ||
</Story> | ||
<Story | ||
name="secondary" | ||
args={{ | ||
color: "secondary", | ||
children: "secondary", | ||
}} | ||
> | ||
{(args) => <Button {...args} />} | ||
</Story> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map()
で書きたいが、今の所かけない。
<Fade timeout={{ enter, exit }} in={isOpen}> | ||
<Button>Control in Knob Footer</Button> | ||
</Fade> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storybookアプデの影響か、このコンポーネントにおいてはKnobの操作によってtransitionが発火しなかった。
ので、<Grow />
と同じ構成にした。
"eslint.options": { | ||
"extensions": [".js", ".jsx", ".md", ".mdx", ".ts", ".tsx"] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いずれ.mdx
が対応されるはずなので、あらかじめいれておいた。
@ryokosuge |
component: {{ input }}, | ||
}; | ||
<Meta | ||
title="{{ input | pascal }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
めちゃくちゃ細かいんだけど
https://storybook.js.org/docs/react/writing-docs/mdx#writing-stories
<Meta
title=""
>
のtitleのところを例えば Component/{{ input | pascal }}
みたいにディレクトリ切る感じで書いていくと
こんな感じ(ここだと <Meta title="MDX/Badge">
)になるんだけど、分けていった方がみやすいかな?って思ったんだけどどうでしょう!
- Component
- Layout
とかくらいに分かれるかなーっていうイメージ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ああ、全然良いと思います:+1:
別PRでやりましょうか !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうしましょう!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この辺にちょろっと書いた
#212 (comment)
name="something" | ||
args={{}} | ||
> | ||
{(args) => <{{ input | pascal }} {...args} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<!--- This is your Story template function, shown here in React -->
export const Template = (args) => <Badge {...args } />
Buttonのやつみる限り、複数回 {(args) => <{{ input | pascal }} {...args} />
これを書いてるから、{Template.bind({})}
の方がちょっと楽かな?と思い!
使わなかった理由があったら教えて欲しい!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど、MDXCreateElementは export const Template = (args) => <Badge {...args } />
で出てくるのか!
だったら PreviewのところはちゃんとしたComponent名で出て欲しいから、この記法の方が良さそうだね!
"@storybook/addon-storysource": "^6.1.6", | ||
"@storybook/addon-console": "^1.2.2", | ||
"@storybook/addon-essentials": "^6.1.9", | ||
"@storybook/addon-knobs": "^6.1.9", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こいつ残してるのは、前のやつとの互換とるためかな?
knobsとessentialsに含まれてるcontrolsがほぼ同じやつだと認識してるんだけど、もしかして理解足りてない...?w
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。前のやつと互換を取るためです!
knobsとessentialsに含まれてるcontrolsがほぼ同じやつだと認識
合ってます!がライブラリとしては別モノなので、一気に乗り換えるためには修正は必要でして。。。
https://github.com/storybookjs/storybook/tree/next/addons/controls#how-do-i-migrate-from-addon-knobs
いずれ全て変わるので、一気にやらなくても良いかなという判断です!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
ref: #212
ここを親ブランチとし、**.stories.tsx
をリプレイスする際は別ブランチからこちらにマージする。全てのコンポーネントを書き換えた時点で当PRをマージする。
コンポーネントの数が多いので、随時リリースする方針に変更。
なお、進捗は #212 の方で管理する。
やったこと
@storybook/addon-console
、@storybook/addon-console
の導入Button.stories.mdx
にドキュメンテーション.scaffdog/component.md
を.mdx
に対応させる**.stories.tsx
において、Docsタブをみれないように.mdx
対応できるように