Skip to content

Commit 74bca92

Browse files
authored
chore(tabs): Add matrix comparison to stories (#75181)
this pr adds matrix comparisons for the new variants of tabs
1 parent 8382c67 commit 74bca92

File tree

1 file changed

+86
-40
lines changed

1 file changed

+86
-40
lines changed

static/app/components/tabs/index.stories.tsx

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Fragment, useState} from 'react';
22
import range from 'lodash/range';
33

44
import JSXNode from 'sentry/components/stories/jsxNode';
5-
import Matrix from 'sentry/components/stories/matrix';
5+
import Matrix, {type PropMatrix} from 'sentry/components/stories/matrix';
66
import SideBySide from 'sentry/components/stories/sideBySide';
77
import SizingWindow from 'sentry/components/stories/sizingWindow';
88
import type {TabListProps, TabsProps} from 'sentry/components/tabs';
@@ -188,43 +188,89 @@ export default storyBook(Tabs, story => {
188188
</SideBySide>
189189
));
190190

191-
story('Variants', () => (
192-
<div>
193-
<p>
194-
Use the variant prop to control which tab design to use. The default, "flat", is
195-
used in the above examples, but you can also use "filled" variant, as shown below.
196-
Note that the "filled" variant does not work when the oritentation is vertical
197-
</p>
198-
<SizingWindow>
199-
<Tabs>
200-
<TabList variant={'filled'}>
201-
{TABS.map(tab => (
202-
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
203-
))}
204-
</TabList>
205-
<TabPanels>
206-
{TABS.map(tab => (
207-
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
208-
))}
209-
</TabPanels>
210-
</Tabs>
211-
</SizingWindow>
212-
<br />
213-
<p>You can also use the "floating" variant, which is used below</p>
214-
<SizingWindow>
215-
<Tabs>
216-
<TabList variant="floating" hideBorder>
217-
{TABS.map(tab => (
218-
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
219-
))}
220-
</TabList>
221-
<TabPanels>
222-
{TABS.map(tab => (
223-
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
224-
))}
225-
</TabPanels>
226-
</Tabs>
227-
</SizingWindow>
228-
</div>
229-
));
191+
story('Variants', () => {
192+
const propMatrix: PropMatrix<TabsProps<string> & TabListProps> = {
193+
hideBorder: [undefined, false, true],
194+
orientation: [undefined, 'horizontal', 'vertical'],
195+
variant: [undefined, 'flat', 'filled', 'floating'],
196+
};
197+
return (
198+
<div>
199+
<p>
200+
Use the variant prop to control which tab design to use. The default, "flat", is
201+
used in the above examples, but you can also use "filled" variant, as shown
202+
below. Note that the "filled" variant does not work when the oritentation is
203+
vertical
204+
</p>
205+
<SizingWindow>
206+
<Tabs>
207+
<TabList variant={'filled'}>
208+
{TABS.map(tab => (
209+
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
210+
))}
211+
</TabList>
212+
<TabPanels>
213+
{TABS.map(tab => (
214+
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
215+
))}
216+
</TabPanels>
217+
</Tabs>
218+
</SizingWindow>
219+
<br />
220+
<p>You can also use the "floating" variant, which is used below</p>
221+
<SizingWindow>
222+
<Tabs>
223+
<TabList variant="floating" hideBorder>
224+
{TABS.map(tab => (
225+
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
226+
))}
227+
</TabList>
228+
<TabPanels>
229+
{TABS.map(tab => (
230+
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
231+
))}
232+
</TabPanels>
233+
</Tabs>
234+
</SizingWindow>
235+
<br />
236+
<Matrix<TabsProps<string> & TabListProps>
237+
render={props => (
238+
<Tabs orientation={props.orientation}>
239+
<TabList variant={props.variant}>
240+
{TABS.map(tab => (
241+
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
242+
))}
243+
</TabList>
244+
<TabPanels>
245+
{TABS.map(tab => (
246+
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
247+
))}
248+
</TabPanels>
249+
</Tabs>
250+
)}
251+
propMatrix={propMatrix}
252+
selectedProps={['orientation', 'variant']}
253+
/>
254+
<br />
255+
<Matrix<TabsProps<string> & TabListProps>
256+
render={props => (
257+
<Tabs>
258+
<TabList variant={props.variant} hideBorder={props.hideBorder}>
259+
{TABS.map(tab => (
260+
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
261+
))}
262+
</TabList>
263+
<TabPanels>
264+
{TABS.map(tab => (
265+
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
266+
))}
267+
</TabPanels>
268+
</Tabs>
269+
)}
270+
propMatrix={propMatrix}
271+
selectedProps={['hideBorder', 'variant']}
272+
/>
273+
</div>
274+
);
275+
});
230276
});

0 commit comments

Comments
 (0)