-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1302 from sgratch/add-storybook-for-SearchableEnu…
…mFilter-SearchableGroupedEnumFilter 🐾 Add Storybook entries for the two new Searchable enum filters components
- Loading branch information
Showing
6 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
packages/common/src/components-stories/Filter/SearchableEnumFilter.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,75 @@ | ||
import React from 'react'; | ||
|
||
import { Toolbar, ToolbarContent } from '@patternfly/react-core'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { SearchableEnumFilter } from '../../components/Filter/SearchableEnumFilter'; | ||
|
||
const meta: Meta<typeof SearchableEnumFilter> = { | ||
title: 'Common package components/Filter/SearchableEnumFilter', | ||
component: SearchableEnumFilter, | ||
tags: ['autodocs'], | ||
decorators: [ | ||
(Story) => ( | ||
<Toolbar style={{ padding: 0, paddingBottom: 150 }}> | ||
<ToolbarContent> | ||
<Story /> | ||
{' (<-- Click the toggle for expanding it and displaying the type-ahead search field,'} | ||
<br /> | ||
| ||
{'to filter down from the list of menu options.)'} | ||
</ToolbarContent> | ||
</Toolbar> | ||
), | ||
], | ||
parameters: { | ||
componentSubtitle: | ||
'Filters allow users to narrow down content from data in tables, data lists or card views, among many others.', | ||
}, | ||
argTypes: { | ||
supportedGroups: { table: { disable: true } }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof SearchableEnumFilter>; | ||
|
||
/** | ||
* This example is used when there are a number of selected filter values ``'China', 'Japan', 'France'``. | ||
* | ||
*/ | ||
export const SelectedFewValues: Story = { | ||
args: { | ||
placeholderLabel: 'Country names', | ||
title: 'Filter Country names', | ||
showFilter: true, | ||
supportedValues: [ | ||
{ id: 'china', label: 'China' }, | ||
{ id: 'india', label: 'India' }, | ||
{ id: 'japan', label: 'Japan' }, | ||
{ id: 'cyprus', label: 'Cyprus' }, | ||
{ id: 'france', label: 'France' }, | ||
], | ||
selectedFilters: ['china', 'japan', 'france', 'cyprus'], | ||
}, | ||
}; | ||
|
||
/** | ||
* This example is used when the selected filters list is empty, | ||
* i.e. no values are selected, the result of clicking on *``Clear all filters``* button | ||
* | ||
*/ | ||
export const NoSelectedValues: Story = { | ||
args: { | ||
placeholderLabel: 'Country names', | ||
title: 'Filter Country names', | ||
showFilter: true, | ||
supportedValues: [ | ||
{ id: 'china', label: 'China' }, | ||
{ id: 'india', label: 'India' }, | ||
{ id: 'japan', label: 'Japan' }, | ||
{ id: 'france', label: 'France' }, | ||
], | ||
selectedFilters: [], | ||
}, | ||
}; |
107 changes: 107 additions & 0 deletions
107
packages/common/src/components-stories/Filter/SearchableGroupedEnumFilter.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,107 @@ | ||
import React from 'react'; | ||
|
||
import { Toolbar, ToolbarContent } from '@patternfly/react-core'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { SearchableGroupedEnumFilter } from '../../components/Filter/SearchableGroupedEnumFilter'; | ||
|
||
const meta: Meta<typeof SearchableGroupedEnumFilter> = { | ||
title: 'Common package components/Filter/SearchableGroupedEnumFilter', | ||
component: SearchableGroupedEnumFilter, | ||
tags: ['autodocs'], | ||
decorators: [ | ||
(Story) => ( | ||
<Toolbar style={{ padding: 0, paddingBottom: 260 }}> | ||
<ToolbarContent> | ||
<Story /> | ||
{' (<-- Click the toggle for expanding it and displaying the type-ahead search field,'} | ||
<br /> | ||
| ||
{'to filter down from the list of menu options.)'} | ||
</ToolbarContent> | ||
</Toolbar> | ||
), | ||
], | ||
parameters: { | ||
componentSubtitle: | ||
'Filters allow users to narrow down content from data in tables, data lists or card views, among many others.', | ||
}, | ||
argTypes: { | ||
title: { table: { disable: true } }, | ||
resolvedLanguage: { table: { disable: true } }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof SearchableGroupedEnumFilter>; | ||
|
||
/** | ||
* This example is used when the selected filter values ``'India', 'Japan', 'France'`` include values from different groups: | ||
* | ||
*/ | ||
export const SelectedValuesFromDifferentGroups: Story = { | ||
args: { | ||
placeholderLabel: 'Country names', | ||
showFilter: true, | ||
supportedGroups: [ | ||
{ groupId: 'europe', label: 'Europe' }, | ||
{ groupId: 'asia', label: 'Asia' }, | ||
], | ||
supportedValues: [ | ||
{ id: 'china', groupId: 'asia', label: 'China' }, | ||
{ id: 'india', groupId: 'asia', label: 'India' }, | ||
{ id: 'japan', groupId: 'asia', label: 'Japan' }, | ||
{ id: 'cyprus', groupId: 'asia', label: 'Cyprus' }, | ||
{ id: 'france', groupId: 'europe', label: 'France' }, | ||
], | ||
selectedFilters: ['india', 'japan', 'france'], | ||
}, | ||
}; | ||
|
||
/** | ||
* This example is used when the selected filter values ``'India', 'Japan'`` include values from only one group: | ||
* | ||
*/ | ||
export const SelectedValuesFromOneGroup: Story = { | ||
args: { | ||
placeholderLabel: 'Country names', | ||
showFilter: true, | ||
supportedGroups: [ | ||
{ groupId: 'europe', label: 'Europe' }, | ||
{ groupId: 'asia', label: 'Asia' }, | ||
], | ||
supportedValues: [ | ||
{ id: 'china', groupId: 'asia', label: 'China' }, | ||
{ id: 'india', groupId: 'asia', label: 'India' }, | ||
{ id: 'japan', groupId: 'asia', label: 'Japan' }, | ||
{ id: 'cyprus', groupId: 'asia', label: 'Cyprus' }, | ||
{ id: 'thailand', groupId: 'asia', label: 'Thailand' }, | ||
{ id: 'france', groupId: 'europe', label: 'France' }, | ||
], | ||
selectedFilters: ['india', 'japan', 'china', 'cyprus'], | ||
}, | ||
}; | ||
|
||
/** | ||
* This example is used when the selected filters list is empty, | ||
* i.e. no values are selected, the result of clicking on *``Clear all filters``* button | ||
* | ||
*/ | ||
export const NoSelectedValues: Story = { | ||
args: { | ||
placeholderLabel: 'Country names', | ||
showFilter: true, | ||
supportedGroups: [ | ||
{ groupId: 'europe', label: 'Europe' }, | ||
{ groupId: 'asia', label: 'Asia' }, | ||
], | ||
supportedValues: [ | ||
{ id: 'China', groupId: 'asia', label: 'China' }, | ||
{ id: 'India', groupId: 'asia', label: 'India' }, | ||
{ id: 'Japan', groupId: 'asia', label: 'Japan' }, | ||
{ id: 'cyprus', groupId: 'asia', label: 'Cyprus' }, | ||
{ id: 'France', groupId: 'europe', label: 'France' }, | ||
], | ||
selectedFilters: [], | ||
}, | ||
}; |
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
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
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
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