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

chore: Badge の Story を見直し #4988

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
93 changes: 0 additions & 93 deletions packages/smarthr-ui/src/components/Badge/Badge.stories.tsx

This file was deleted.

40 changes: 0 additions & 40 deletions packages/smarthr-ui/src/components/Badge/VRTBadge.stories.tsx

This file was deleted.

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: {},
}
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',
/* ペアワイズ法は使わずにすべての組み合わせを網羅する */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ペアワイズ法をゴニョゴニョして色々試しはしたんですけど、このコンポーネントならペアワイズ使うまでもなく全描画パターン洗い出せるなと気づいたので使わなかったです。

というのもありですかね? Button みたいに全網羅は不可能な組み合わせ爆発が起こる場合のみ pict を導入するみたいな。

Copy link
Collaborator

Choose a reason for hiding this comment

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

ありだと思います! pict の運用はそれなりに手間がかかりそうなので、必要な時だけで良さそうですね。

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' },
},
}