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

refactor: Convert Select stories to csf format #7470

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
stories: [
'../app/component-library/components/Cards/Card/**/*.stories.?(ts|tsx|js|jsx)',
'../app/component-library/components/Banners/Banner/variants/BannerAlert/**/*.stories.?(ts|tsx|js|jsx)',
'../app/component-library/components/Select/**/*.stories.?(ts|tsx|js|jsx)',
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
'../app/component-library/components/Pickers/**/*.stories.?(ts|tsx|js|jsx)',
'../app/component-library/components/Cells/**/*.stories.?(ts|tsx|js|jsx)',
'../app/component-library/components/HeaderBase/**/*.stories.?(ts|tsx|js|jsx)',
Expand Down
9 changes: 9 additions & 0 deletions .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ global.STORIES = [
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Banners\\/Banner\\/variants\\/BannerAlert(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
},
{
titlePrefix: "",
directory: "./app/component-library/components/Select",
files: "**/*.stories.?(ts|tsx|js|jsx)",
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Select(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
},
{
titlePrefix: "",
directory: "./app/component-library/components/Pickers",
Expand Down Expand Up @@ -113,6 +120,8 @@ const getStories = () => {
return {
"./app/component-library/components/Cards/Card/Card.stories.tsx": require("../app/component-library/components/Cards/Card/Card.stories.tsx"),
"./app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx": require("../app/component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.stories.tsx"),
"./app/component-library/components/Select/MultiSelect/MultiSelectItem/MultiSelectItem.stories.tsx": require("../app/component-library/components/Select/MultiSelect/MultiSelectItem/MultiSelectItem.stories.tsx"),
"./app/component-library/components/Select/Select/SelectItem/SelectItem.stories.tsx": require("../app/component-library/components/Select/Select/SelectItem/SelectItem.stories.tsx"),
"./app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx": require("../app/component-library/components/Pickers/PickerAccount/PickerAccount.stories.tsx"),
"./app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx": require("../app/component-library/components/Pickers/PickerNetwork/PickerNetwork.stories.tsx"),
"./app/component-library/components/Cells/Cell/Cell.stories.tsx": require("../app/component-library/components/Cells/Cell/Cell.stories.tsx"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
/* eslint-disable no-console */

// Third party dependencies.
/* eslint-disable react/display-name */
import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { boolean } from '@storybook/addon-knobs';

// External dependencies.
import { storybookPropsGroupID } from '../../../../constants/storybook.constants';
import ListItemColumn, { WidthType } from '../../../List/ListItemColumn';
import Icon, { IconName } from '../../../Icons/Icon';
import Text, { TextVariant } from '../../../Texts/Text';
import { getListItemStoryProps } from '../../../List/ListItem/ListItem.stories';

// Internal dependencies.
import MultiSelectItem from './MultiSelectItem';
import { MultiSelectItemProps } from './MultiSelectItem.types';

export const getMultiSelectItemStoryProps = (): MultiSelectItemProps => {
const isSelected = boolean('isSelected', false, storybookPropsGroupID);
const isDisabled = boolean('isDisabled', false, storybookPropsGroupID);

return {
isSelected,
isDisabled,
...getListItemStoryProps(),
};
import { default as MultiSelectItemComponent } from './MultiSelectItem';
import { SAMPLE_MULTISELECTITEM_PROPS } from './MultiSelectItem.constants';

const MultiSelectItemMeta = {
title: 'Component Library / Select',
component: MultiSelectItemComponent,
argTypes: {
isSelected: {
control: { type: 'boolean' },
defaultValue: SAMPLE_MULTISELECTITEM_PROPS.isSelected,
},
isDisabled: {
control: { type: 'boolean' },
defaultValue: SAMPLE_MULTISELECTITEM_PROPS.isDisabled,
},
},
};
brianacnguyen marked this conversation as resolved.
Show resolved Hide resolved
export default MultiSelectItemMeta;

export const MultiSelectItem = {
render: (args: any) => (
<MultiSelectItemComponent {...args}>
<ListItemColumn>
<Icon name={IconName.Clock} />
</ListItemColumn>
<ListItemColumn widthType={WidthType.Fill}>
<Text numberOfLines={1} variant={TextVariant.HeadingSMRegular}>
{'Sample Title'}
</Text>
<Text variant={TextVariant.BodyMD}>{'Sample Description'}</Text>
</ListItemColumn>
<ListItemColumn>
<Icon name={IconName.Arrow2Right} />
</ListItemColumn>
</MultiSelectItemComponent>
),
};

const MultiSelectItemStory = () => (
<MultiSelectItem {...getMultiSelectItemStoryProps()}>
<ListItemColumn>
<Icon name={IconName.Clock} />
</ListItemColumn>
<ListItemColumn widthType={WidthType.Fill}>
<Text numberOfLines={1} variant={TextVariant.HeadingSMRegular}>
{'Sample Title'}
</Text>
<Text variant={TextVariant.BodyMD}>{'Sample Description'}</Text>
</ListItemColumn>
<ListItemColumn>
<Icon name={IconName.Arrow2Right} />
</ListItemColumn>
</MultiSelectItem>
);

storiesOf('Component Library / Select', module).add(
'MultiSelectItem',
MultiSelectItemStory,
);

export default MultiSelectItemStory;
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
/* eslint-disable no-console */

// Third party dependencies.
/* eslint-disable react/display-name */
import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { boolean } from '@storybook/addon-knobs';

// External dependencies.
import { storybookPropsGroupID } from '../../../../constants/storybook.constants';
import ListItemColumn, { WidthType } from '../../../List/ListItemColumn/';
import ListItemColumn, { WidthType } from '../../../List/ListItemColumn';
import Icon, { IconName } from '../../../Icons/Icon';
import Text, { TextVariant } from '../../../Texts/Text';
import { getListItemStoryProps } from '../../../List/ListItem/ListItem.stories';

// Internal dependencies.
import SelectItem from './SelectItem';
import { SelectItemProps } from './SelectItem.types';

export const getSelectItemStoryProps = (): SelectItemProps => {
const isSelected = boolean('isSelected', false, storybookPropsGroupID);
const isDisabled = boolean('isDisabled', false, storybookPropsGroupID);

return {
isSelected,
isDisabled,
...getListItemStoryProps(),
};
import { default as SelectItemComponent } from './SelectItem';
import { SAMPLE_SELECTITEM_PROPS } from './SelectItem.constants';

const SelectItemMeta = {
title: 'Component Library / Select',
component: SelectItemComponent,
argTypes: {
isSelected: {
control: { type: 'boolean' },
defaultValue: SAMPLE_SELECTITEM_PROPS.isSelected,
},
isDisabled: {
control: { type: 'boolean' },
defaultValue: SAMPLE_SELECTITEM_PROPS.isDisabled,
},
},
};
export default SelectItemMeta;

export const SelectItem = {
render: (args: any) => (
<SelectItemComponent {...args}>
<ListItemColumn>
<Icon name={IconName.Clock} />
</ListItemColumn>
<ListItemColumn widthType={WidthType.Fill}>
<Text numberOfLines={1} variant={TextVariant.HeadingSMRegular}>
{'Sample Title'}
</Text>
<Text variant={TextVariant.BodyMD}>{'Sample Description'}</Text>
</ListItemColumn>
<ListItemColumn>
<Icon name={IconName.Arrow2Right} />
</ListItemColumn>
</SelectItemComponent>
),
};

const SelectItemStory = () => (
<SelectItem {...getSelectItemStoryProps()}>
<ListItemColumn>
<Icon name={IconName.Clock} />
</ListItemColumn>
<ListItemColumn widthType={WidthType.Fill}>
<Text numberOfLines={1} variant={TextVariant.HeadingSMRegular}>
{'Sample Title'}
</Text>
<Text variant={TextVariant.BodyMD}>{'Sample Description'}</Text>
</ListItemColumn>
<ListItemColumn>
<Icon name={IconName.Arrow2Right} />
</ListItemColumn>
</SelectItem>
);

storiesOf('Component Library / Select', module).add(
'SelectItem',
SelectItemStory,
);

export default SelectItemStory;
Loading