-
Notifications
You must be signed in to change notification settings - Fork 141
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
chore: Badge の Story を見直し #4988
Merged
+136
−133
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
93 changes: 0 additions & 93 deletions
93
packages/smarthr-ui/src/components/Badge/Badge.stories.tsx
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
packages/smarthr-ui/src/components/Badge/VRTBadge.stories.tsx
This file was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
packages/smarthr-ui/src/components/Badge/stories/Badge.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,92 @@ | ||
import React from 'react' | ||
|
||
import { Cluster, Stack } from '../../Layout' | ||
import { Text } from '../../Text' | ||
import { Badge } from '../Badge' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
export default { | ||
title: 'States(状態)/Badge', | ||
component: Badge, | ||
render: (args) => <Badge {...args} />, | ||
args: { | ||
count: 0, | ||
overflowCount: 99, | ||
showZero: true, | ||
type: 'blue', | ||
dot: false, | ||
}, | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
}, | ||
} as Meta<typeof Badge> | ||
|
||
export const BadgeControl: StoryObj<typeof Badge> = { | ||
name: 'Playground', | ||
args: {}, | ||
} | ||
|
||
export const Count: StoryObj<typeof Badge> = { | ||
name: 'count', | ||
render: (args) => ( | ||
<Cluster> | ||
{new Array(10).fill(0).map((_, i) => ( | ||
<Badge {...args} count={i + 1} key={i} /> | ||
))} | ||
</Cluster> | ||
), | ||
args: {}, | ||
} | ||
|
||
export const OverflowCount: StoryObj<typeof Badge> = { | ||
name: 'overflowCount', | ||
render: (args) => ( | ||
<Cluster> | ||
<Badge {...args} count={98} /> | ||
<Badge {...args} count={99} /> | ||
<Badge {...args} count={100} /> | ||
</Cluster> | ||
), | ||
args: { | ||
overflowCount: 99, | ||
}, | ||
} | ||
|
||
export const ShowZero: StoryObj<typeof Badge> = { | ||
name: 'showZero', | ||
render: (args) => ( | ||
<Stack> | ||
<Cluster> | ||
<Text>true</Text> | ||
<Badge {...args} showZero={true} count={0} /> | ||
</Cluster> | ||
<Cluster> | ||
<Text>false</Text> | ||
<Badge {...args} showZero={false} count={0} /> | ||
</Cluster> | ||
</Stack> | ||
), | ||
args: { | ||
showZero: true, | ||
}, | ||
} | ||
|
||
export const Type: StoryObj<typeof Badge> = { | ||
name: 'type', | ||
render: (args) => ( | ||
<Cluster> | ||
<Badge {...args} type="blue" /> | ||
<Badge {...args} type="yellow" /> | ||
<Badge {...args} type="red" /> | ||
<Badge {...args} type="grey" /> | ||
</Cluster> | ||
), | ||
args: {}, | ||
} | ||
|
||
export const Dot: StoryObj<typeof Badge> = { | ||
name: 'dot', | ||
render: (args) => <Badge {...args} dot={true} />, | ||
args: {}, | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/smarthr-ui/src/components/Badge/stories/VRTBadge.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,44 @@ | ||
import { fireEvent, within } from '@storybook/test' | ||
import React from 'react' | ||
|
||
import { Cluster, Stack } from '../../Layout' | ||
import { Badge } from '../Badge' | ||
|
||
import type { StoryObj } from '@storybook/react' | ||
|
||
export default { | ||
title: 'States(状態)/Badge/VRT', | ||
/* ペアワイズ法は使わずにすべての組み合わせを網羅する */ | ||
render: (args: any) => { | ||
const types = ['grey', 'blue', 'red', 'yellow'] as const | ||
return ( | ||
<Stack {...args}> | ||
{types.map((type, i) => ( | ||
<Cluster key={i}> | ||
<> | ||
<Badge type={type} count={0} showZero={false} /> | ||
<Badge type={type} count={0} showZero={true} /> | ||
<Badge type={type} count={1} /> | ||
<Badge type={type} count={10} overflowCount={10} /> | ||
<Badge type={type} count={10} overflowCount={9} /> | ||
<Badge type={type} dot={true} /> | ||
</> | ||
</Cluster> | ||
))} | ||
</Stack> | ||
) | ||
}, | ||
parameters: { | ||
chromatic: { disableSnapshot: false }, | ||
}, | ||
tags: ['!autodocs'], | ||
} | ||
|
||
export const VRT = {} | ||
|
||
export const VRTForcedColors: StoryObj = { | ||
...VRT, | ||
parameters: { | ||
chromatic: { forcedColors: 'active' }, | ||
}, | ||
} |
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.
ペアワイズ法をゴニョゴニョして色々試しはしたんですけど、このコンポーネントならペアワイズ使うまでもなく全描画パターン洗い出せるなと気づいたので使わなかったです。
というのもありですかね? Button みたいに全網羅は不可能な組み合わせ爆発が起こる場合のみ pict を導入するみたいな。
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.
ありだと思います! pict の運用はそれなりに手間がかかりそうなので、必要な時だけで良さそうですね。