-
Notifications
You must be signed in to change notification settings - Fork 3
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
mdx 形式で Story の Docs を書くようにする #53
Conversation
@@ -10,7 +10,6 @@ const Template: Story<ComponentProps<typeof CommonTable>> = (props) => ( | |||
) | |||
|
|||
export const Default = Template.bind({}) | |||
Default.storyName = '基本' |
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.
これは <Story story={Default} name="基本" />
が代替してくれる認識であってますか?
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.
名前は Story の近くに合ったほうが管理しやすいかも。Docs にすべてを記述しない場合もありそう。
<Heading>パターン</Heading> | ||
|
||
<Subheading>基本</Subheading> | ||
|
||
<Canvas> | ||
<Story story={Default} name="基本" /> | ||
</Canvas> | ||
|
||
<Subheading>初期状態</Subheading> | ||
|
||
<Canvas> | ||
<Story story={InitialState} name="初期状態" /> | ||
</Canvas> | ||
|
||
<Subheading>検索結果なし</Subheading> | ||
|
||
<Canvas> | ||
<Story story={NoSearchResult} name="検索結果なし" /> | ||
</Canvas> | ||
|
||
<Subheading>1ページ未満</Subheading> | ||
|
||
<Canvas> | ||
<Story story={LessThanOnePage} name="1ページ未満" /> | ||
</Canvas> | ||
|
||
<Subheading>テーブルの説明なし</Subheading> | ||
|
||
<Canvas> | ||
<Story story={NoDescription} name="テーブルの説明なし" /> | ||
</Canvas> |
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 の方で確認した方が良いもするので、一旦各プロダクトへのリンクだけでも良い気がしました!
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.
import { Canvas, Story, Title, Primary, Stories, Heading, Subheading } from '@storybook/addon-docs' | ||
|
||
<Title /> | ||
<br /> | ||
<Heading>プロダクトごとの実装</Heading> | ||
|
||
<Subheading>従業員サーベイ</Subheading> | ||
|
||
- [コード](https://github.com/kufu/meyasu/blob/staging/client/src/app/components/presentations/blocks/CommonTable/CommonTable.tsx) | ||
- [Storybook](https://staging--618dc41b452a67003aa1fedb.chromatic.com/?path=/story/blocks-commontable--default) | ||
|
||
<Heading>Story</Heading> | ||
|
||
<Primary /> | ||
<Stories /> |
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.
各コンポーネントの役割
- Title
- Story のタイトルを自動で表示してくれる(
.stories.tsx
のexport default
で指定しているtitle
の値)
- Story のタイトルを自動で表示してくれる(
- Heading, Subheading
- markdown の
#
,##
と同等だが、見出しごとにハッシュ付きのリンクを生成してくれる
- markdown の
- Primary
- 先頭の Story を表示
- Stories
- 戦闘以外の Story を列挙して表示
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, |
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 で docs を書く場合はこんな感じで .mdx
ファイルを定義しつつ、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.
よさそう
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点だけ細かいんですが消したいのがあります!
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, |
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.
よさそう
import { Canvas, Story, Title, Primary, Stories, Heading, Subheading } from '@storybook/addon-docs' | ||
|
||
<Title /> | ||
<br /> |
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.
HTML でレイアウト調整したくないので、消したい!
やるなら CSS あてたい。
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.
スマセン、消しました!
2f16c69
<Primary /> | ||
<Stories /> |
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!
表題の通りです。
スマパタの Storybook の Docs から、各プロダクトの実装のリンクや、その他自由にマークダウンでドキュメンテーションするために、mdx 形式で Story の Docs を書くようにしてみました。
書きっぷりはこの辺を参考にしました。
https://github.com/storybookjs/storybook/blob/next/code/addons/docs/docs/recipes.md#csf-stories-with-mdx-docs
とりあえず「よくあるテーブル」の Story で試してみたので、良さそうであれば scaffold の作成と、他 Story への適用も行おうと思っています。
relates #6