-
Notifications
You must be signed in to change notification settings - Fork 140
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
docs: TabBar の Story を見直し #4949
Merged
+226
−170
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9adfbb0
chore: Autodocs の指定を変更
uknmr e348c0b
docs: TabBar の Story を見直し
uknmr 827c5ec
fix: 1 Story 1 コンポーネントの構成に変更
uknmr 5a2e98a
chore: Story Docs のコードをデフォルト表示
uknmr ec6ad37
test: TabItem のアクセシビリティチェックを除外
uknmr abb7d6d
chore: Chromatic 上で storybook-addon-pseudo-states 機能していないため調整
uknmr e2ee5ca
chore: Story に型を追加
uknmr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/smarthr-ui/src/components/TabBar/TabBar-bordered.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import TabBarStories from './TabBar.stories' | ||
|
||
import type { StoryObj } from '@storybook/react' | ||
|
||
export default { | ||
...TabBarStories, | ||
title: 'Navigation(ナビゲーション)/TabBar/bordered', | ||
tags: ['!autodocs'], | ||
} | ||
|
||
export const True: StoryObj = { | ||
name: 'true', | ||
args: { | ||
bordered: true, | ||
}, | ||
} | ||
|
||
export const False = { | ||
name: 'false', | ||
args: { | ||
bordered: false, | ||
}, | ||
} |
68 changes: 26 additions & 42 deletions
68
packages/smarthr-ui/src/components/TabBar/TabBar.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,38 @@ | ||
import { action } from '@storybook/addon-actions' | ||
import { StoryFn } from '@storybook/react' | ||
import { userEvent } from '@storybook/test' | ||
import React from 'react' | ||
|
||
import { Badge } from '../Badge' | ||
import { Stack } from '../Layout' | ||
|
||
import { TabBar } from './TabBar' | ||
import { TabItem } from './TabItem' | ||
|
||
import type { Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'Navigation(ナビゲーション)/TabBar', | ||
component: TabBar, | ||
subcomponents: { TabItem }, | ||
} | ||
|
||
export const All: StoryFn = () => ( | ||
<Stack as="ul" className="shr-list-none"> | ||
<li> | ||
<p>標準</p> | ||
<Template subid={1} /> | ||
</li> | ||
<li> | ||
<p>下線なし</p> | ||
<Template subid={2} bordered={false} /> | ||
</li> | ||
</Stack> | ||
) | ||
render: (args) => ( | ||
<TabBar {...args}> | ||
<TabItem id="tab1" onClick={action('tab1')} selected> | ||
タブ1 | ||
</TabItem> | ||
<TabItem id="tab2" onClick={action('tab2')}> | ||
タブ2 | ||
</TabItem> | ||
</TabBar> | ||
), | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
}, | ||
} as Meta<typeof TabBar> | ||
|
||
const Template: StoryFn = ({ subid, ...props }) => ( | ||
<TabBar {...props}> | ||
<TabItem id={`border-${subid}-1`} onClick={action('clicked')} selected> | ||
基本情報 | ||
</TabItem> | ||
<TabItem id={`border-${subid}-2`} onClick={action('clicked')} suffix={<Badge count={7} />}> | ||
コメント | ||
</TabItem> | ||
<TabItem | ||
id={`border-${subid}-3`} | ||
onClick={action('clicked')} | ||
disabled | ||
disabledDetail={{ message: 'この機能は使用できません。' }} | ||
> | ||
分析対象 | ||
</TabItem> | ||
</TabBar> | ||
) | ||
|
||
export const RegFocusBorder = All.bind({}) | ||
RegFocusBorder.play = () => userEvent.tab() | ||
export const Default = { | ||
args: { | ||
bordered: true, | ||
}, | ||
} | ||
|
||
export const RegFocusNoBorder = All.bind({}) | ||
RegFocusNoBorder.play = () => [...Array(4)].forEach((_) => userEvent.tab()) | ||
export const Playground = { | ||
args: { | ||
bordered: true, | ||
}, | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/smarthr-ui/src/components/TabBar/TabItem.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { action } from '@storybook/addon-actions' | ||
import React from 'react' | ||
|
||
import { Badge } from '../Badge' | ||
|
||
import { TabItem } from './TabItem' | ||
|
||
import type { Meta } from '@storybook/react' | ||
|
||
export default { | ||
title: 'Navigation(ナビゲーション)/TabBar/TabItem', | ||
component: TabItem, | ||
render: (args) => <TabItem {...args} />, | ||
args: { | ||
children: 'タブ', | ||
id: 'tab1', | ||
onClick: action('clicked'), | ||
}, | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
}, | ||
} as Meta<typeof TabItem> | ||
|
||
export const TabItemControl = { | ||
name: 'Playground', | ||
args: { | ||
selected: true, | ||
disabled: false, | ||
}, | ||
} | ||
|
||
export const Selected = { | ||
name: 'selected', | ||
args: { | ||
selected: true, | ||
}, | ||
} | ||
|
||
export const Suffix = { | ||
name: 'suffix', | ||
args: { | ||
suffix: <Badge count={1} />, | ||
}, | ||
} | ||
|
||
export const Disabled = { | ||
name: 'disabled', | ||
args: { | ||
disabled: true, | ||
}, | ||
} | ||
|
||
export const DisabledDetail = { | ||
name: 'disabledDetail', | ||
args: { | ||
disabled: true, | ||
disabledDetail: { | ||
message: '無効な理由', | ||
}, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[nits]
細かいですが、StoryObj は T にコンポーネントの型を渡してあげると props が型安全になるので書き心地が良くなります!
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.
e2ee5ca で対応しました!
すべての Story に書くの面倒だなぁ、default に指定した型でよしなにやってほしいなぁ、と思ってました😇
雛形作る時に自動生成させても良さそうですね。