Skip to content

Commit 032f9b7

Browse files
authoredOct 25, 2024··
fix: TabBar が margin を持たないように修正 (#5054)
1 parent 57c708a commit 032f9b7

File tree

5 files changed

+63
-76
lines changed

5 files changed

+63
-76
lines changed
 

‎packages/smarthr-ui/src/components/TabBar/TabBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Reel } from '../Layout'
66
const tabBar = tv({
77
slots: {
88
wrapper: 'smarthr-ui-TabBar',
9-
inner: 'shr-grow shr-m-0.25',
9+
inner: 'shr-grow',
1010
},
1111
variants: {
1212
bordered: {

‎packages/smarthr-ui/src/components/TabBar/TabItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const tabItem = tv({
1313
'shr-group/tabitem',
1414
'shr-relative shr-px-1 shr-py-0.75 shr-inline-flex shr-items-center shr-gap-0.5',
1515
'hover:shr-bg-white-darken',
16-
'focus-visible:shr-z-1',
16+
'focus-visible:shr-z-1 focus-visible:shr-focus-indicator--inner',
1717
'disabled:shr-cursor-not-allowed disabled:shr-bg-transparent',
1818
'aria-selected:before:shr-absolute aria-selected:before:shr-inset-x-0 aria-selected:before:shr-bottom-0 aria-selected:before:shr-content-[""] aria-selected:before:shr-block aria-selected:before:shr-h-0.25 aria-selected:before:shr-bg-main aria-selected:before:shr-z-1',
1919
'forced-colors:aria-selected:before:shr-bg-[Highlight]',

‎packages/smarthr-ui/src/components/TabBar/stories/TabBar.stories.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ export default {
2525
},
2626
} as Meta<typeof TabBar>
2727

28-
export const Default: StoryObj<typeof TabBar> = {
29-
args: {
30-
bordered: true,
31-
},
32-
}
33-
3428
export const Playground: StoryObj<typeof TabBar> = {
3529
args: {
3630
bordered: true,

‎packages/smarthr-ui/src/components/TabBar/stories/VRTTabBar.stories.tsx

+55-68
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Stack } from '../../Layout'
88
import { TabBar } from '../TabBar'
99
import { TabItem } from '../TabItem'
1010

11-
import type { StoryObj } from '@storybook/react'
11+
import type { Meta, StoryObj } from '@storybook/react'
1212

1313
export default {
1414
title: 'Navigation(ナビゲーション)/TabBar/VRT',
@@ -20,84 +20,71 @@ export default {
2020
* true false true なし あり
2121
* true true false あり あり
2222
* true false false なし なし */
23-
render: (args: any) => (
24-
<Stack {...args}>
25-
<TabBar bordered={false}>
26-
<TabItem id="tab1" onClick={action('clicked')} suffix={<Badge count={100} />}>
27-
タブ1
28-
</TabItem>
29-
<TabItem
30-
id="tab2"
31-
onClick={action('clicked')}
32-
selected
33-
disabled
34-
disabledDetail={{ message: 'タブが無効な理由' }}
35-
>
36-
タブ2
37-
</TabItem>
38-
</TabBar>
39-
<TabBar>
40-
<TabItem
41-
id="tab3"
42-
onClick={action('clicked')}
43-
selected
44-
disabled
45-
suffix={<Badge count={100} />}
46-
>
47-
タブ3
48-
</TabItem>
49-
<TabItem
50-
id="tab4"
51-
onClick={action('clicked')}
52-
disabled
53-
disabledDetail={{ message: 'タブが無効な理由' }}
54-
>
55-
タブ4
56-
</TabItem>
57-
<TabItem
58-
id="tab5"
59-
onClick={action('clicked')}
60-
selected
61-
suffix={<FaCircleExclamationIcon color="DANGER" />}
62-
disabledDetail={{ message: 'タブが無効な理由' }}
63-
>
64-
タブ5
65-
</TabItem>
66-
<TabItem id="tab6" onClick={action('clicked')}>
67-
タブ6
68-
</TabItem>
69-
</TabBar>
23+
render: (args) => (
24+
<Stack>
25+
{[undefined, 'hover', 'focus-visible'].map((variant) => (
26+
<Stack id={variant} key={variant}>
27+
<TabBar {...args} bordered={false}>
28+
<TabItem id="tab1" onClick={action('clicked')} suffix={<Badge count={100} />}>
29+
タブ1
30+
</TabItem>
31+
<TabItem
32+
id="tab2"
33+
onClick={action('clicked')}
34+
selected
35+
disabled
36+
disabledDetail={{ message: 'タブが無効な理由' }}
37+
>
38+
タブ2
39+
</TabItem>
40+
</TabBar>
41+
<TabBar>
42+
<TabItem
43+
id="tab3"
44+
onClick={action('clicked')}
45+
selected
46+
disabled
47+
suffix={<Badge count={100} />}
48+
>
49+
タブ3
50+
</TabItem>
51+
<TabItem
52+
id="tab4"
53+
onClick={action('clicked')}
54+
disabled
55+
disabledDetail={{ message: 'タブが無効な理由' }}
56+
>
57+
タブ4
58+
</TabItem>
59+
<TabItem
60+
id="tab5"
61+
onClick={action('clicked')}
62+
selected
63+
suffix={<FaCircleExclamationIcon color="DANGER" />}
64+
disabledDetail={{ message: 'タブが無効な理由' }}
65+
>
66+
タブ5
67+
</TabItem>
68+
<TabItem id="tab6" onClick={action('clicked')}>
69+
タブ6
70+
</TabItem>
71+
</TabBar>
72+
</Stack>
73+
))}
7074
</Stack>
7175
),
7276
parameters: {
7377
chromatic: { disableSnapshot: false },
7478
},
7579
tags: ['!autodocs'],
76-
}
77-
78-
export const VRT = {}
80+
} satisfies Meta<typeof TabBar>
7981

80-
export const VRTHover = {
81-
...VRT,
82-
args: {
83-
id: 'hover',
84-
},
82+
export const VRT = {
8583
parameters: {
8684
pseudo: {
8785
hover: ['#hover .smarthr-ui-TabItem'],
86+
focusVisible: ['#focus-visible .smarthr-ui-TabItem'],
8887
},
89-
// MEMO: VRT として機能していないので、解決するまでスナップショットを無効化
90-
chromatic: { disableSnapshot: true },
91-
},
92-
}
93-
94-
export const VRTKeyboardFocus: StoryObj = {
95-
...VRT,
96-
play: async ({ canvasElement }) => {
97-
const canvas = within(canvasElement)
98-
const tabs = canvas.getAllByRole('tab')
99-
// bordered で disabledDetail が存在するアイテムにフォーカス
100-
tabs[3].focus()
10188
},
10289
}
10390

‎packages/smarthr-ui/src/smarthr-ui-preset.ts

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ defaultConfig.twMergeConfig = {
4444
],
4545
},
4646
],
47+
focus: ['focus-indicator', 'focus-indicator--inner'],
4748
},
4849
}
4950

@@ -386,6 +387,11 @@ export default {
386387
isolation: 'isolate',
387388
boxShadow: `0 0 0 2px ${theme('colors.white')}, 0 0 0 4px ${theme('colors.outline')}`,
388389
},
390+
'.focus-indicator--inner': {
391+
outline: 'none',
392+
isolation: 'isolate',
393+
boxShadow: `inset 0 0 0 2px ${theme('colors.outline')}, inset 0 0 0 4px ${theme('colors.white')}`,
394+
},
389395
'.border-shorthand': {
390396
borderWidth: theme('borderWidth.DEFAULT'),
391397
borderStyle: 'solid',

0 commit comments

Comments
 (0)
Please sign in to comment.