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

fix: Storybook 上で props のドキュメントが表示されない問題を修正 #4719

Merged
merged 5 commits into from
Jun 14, 2024
Merged
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
3 changes: 3 additions & 0 deletions packages/smarthr-ui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const config: StorybookConfig = {
docs: {
autodocs: true,
},
typescript: {
reactDocgen: 'react-docgen-typescript',
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

コンポーネントファイルの静的解析を行ってるツールが、Storybook v7 までは react-docgen-typescript だったんですが、v8 からはデフォルトが react-docgen に代わりました。

react-docgen の強みはパフォーマンスなんですが、機能面ではわずかに react-docgen-typescript に負けます。
基本的には react-docgen でことたりるんですが、どうやら smarthr-ui の Storybook の使い方だと、 react-docgen-typescript を使わないと情報が取得できなかったみたいです。なので使用するツールを明示して復活させます。

このあたりについては、急に手前味噌記事を出しますが、以下記事で深堀りしてます。
Storybook と react-docgen の仕組みを追う

webpackFinal: async (config) => {
const resolve = config.resolve || {}
resolve.alias = {
Expand Down
3 changes: 2 additions & 1 deletion packages/smarthr-ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode, useEffect } from 'react'
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'
import { Title, Subtitle, Description, Primary, Stories } from '@storybook/blocks'
import { Title, Subtitle, Description, Primary, Stories, Controls } from '@storybook/blocks'
import ReactGA from 'react-ga4'

import { Preview } from '@storybook/react'
Expand Down Expand Up @@ -70,6 +70,7 @@ const preview: Preview = {
<Subtitle />
<Description />
<Primary />
<Controls />
<Stories includePrimary={false} />
</>
),
Expand Down