Skip to content

Commit 0f1a1ef

Browse files
authored
Add stories
1 parent 1b0a508 commit 0f1a1ef

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import type {Meta, StoryFn} from '@storybook/react-vite'
2+
import React from 'react'
3+
import {SegmentedControl} from './SegmentedControl'
4+
import {EyeIcon, FileCodeIcon, PeopleIcon} from '@primer/octicons-react'
5+
6+
const meta: Meta = {
7+
title: 'Components/SegmentedControl/Responsive Tests',
8+
parameters: {
9+
layout: 'padded',
10+
controls: {expanded: true},
11+
},
12+
}
13+
14+
export default meta
15+
16+
/**
17+
* Test responsive fullWidth behavior.
18+
* Resize the viewport to see the control change width at different breakpoints.
19+
*/
20+
export const FullWidthResponsive: StoryFn = () => (
21+
<SegmentedControl aria-label="File view" fullWidth={{narrow: true, regular: false, wide: false}}>
22+
<SegmentedControl.Button defaultSelected leadingVisual={EyeIcon}>
23+
Preview
24+
</SegmentedControl.Button>
25+
<SegmentedControl.Button leadingVisual={FileCodeIcon}>Raw</SegmentedControl.Button>
26+
<SegmentedControl.Button leadingVisual={PeopleIcon}>Blame</SegmentedControl.Button>
27+
</SegmentedControl>
28+
)
29+
30+
FullWidthResponsive.parameters = {
31+
docs: {
32+
description: {
33+
story:
34+
'The control fills the full width on **narrow** viewports and uses inline width on **regular** and **wide** viewports.',
35+
},
36+
},
37+
}
38+
39+
/**
40+
* Test responsive variant behavior with hideLabels.
41+
* Resize the viewport to see labels hide/show at different breakpoints.
42+
*/
43+
export const VariantHideLabelsResponsive: StoryFn = () => (
44+
<SegmentedControl aria-label="File view" variant={{narrow: 'hideLabels', regular: 'default', wide: 'default'}}>
45+
<SegmentedControl.Button defaultSelected leadingVisual={EyeIcon}>
46+
Preview
47+
</SegmentedControl.Button>
48+
<SegmentedControl.Button leadingVisual={FileCodeIcon}>Raw</SegmentedControl.Button>
49+
<SegmentedControl.Button leadingVisual={PeopleIcon}>Blame</SegmentedControl.Button>
50+
</SegmentedControl>
51+
)
52+
53+
VariantHideLabelsResponsive.parameters = {
54+
docs: {
55+
description: {
56+
story:
57+
'Labels are **hidden** (icon-only) on narrow viewports and **visible** on regular and wide viewports. Note: leadingVisual prop is required for hideLabels variant.',
58+
},
59+
},
60+
}
61+
62+
/**
63+
* Test responsive variant behavior with dropdown.
64+
* Resize the viewport to see the control switch between dropdown and buttons.
65+
*/
66+
export const VariantDropdownResponsive: StoryFn = () => (
67+
<SegmentedControl aria-label="File view" variant={{narrow: 'dropdown', regular: 'default', wide: 'default'}}>
68+
<SegmentedControl.Button defaultSelected leadingVisual={EyeIcon}>
69+
Preview
70+
</SegmentedControl.Button>
71+
<SegmentedControl.Button leadingVisual={FileCodeIcon}>Raw</SegmentedControl.Button>
72+
<SegmentedControl.Button leadingVisual={PeopleIcon}>Blame</SegmentedControl.Button>
73+
</SegmentedControl>
74+
)
75+
76+
VariantDropdownResponsive.parameters = {
77+
docs: {
78+
description: {
79+
story:
80+
'Renders as a **dropdown menu** on narrow viewports and as **segmented buttons** on regular and wide viewports.',
81+
},
82+
},
83+
}
84+
85+
/**
86+
* Test complex responsive behavior combining fullWidth and variant.
87+
*/
88+
export const ComplexResponsive: StoryFn = () => (
89+
<SegmentedControl
90+
aria-label="File view"
91+
fullWidth={{narrow: true, regular: true, wide: false}}
92+
variant={{narrow: 'hideLabels', regular: 'default', wide: 'default'}}
93+
>
94+
<SegmentedControl.Button defaultSelected leadingVisual={EyeIcon}>
95+
Preview
96+
</SegmentedControl.Button>
97+
<SegmentedControl.Button leadingVisual={FileCodeIcon}>Raw</SegmentedControl.Button>
98+
<SegmentedControl.Button leadingVisual={PeopleIcon}>Blame</SegmentedControl.Button>
99+
</SegmentedControl>
100+
)
101+
102+
ComplexResponsive.parameters = {
103+
docs: {
104+
description: {
105+
story:
106+
'Complex: **full-width + icon-only** (narrow) → **full-width + labels** (regular) → **inline + labels** (wide)',
107+
},
108+
},
109+
}

0 commit comments

Comments
 (0)