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 Overlay story to csf format #7412

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/Overlay/**/*.stories.?(ts|tsx|js|jsx)',
],
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
addons: ['@storybook/addon-ondevice-controls'],
framework: '@storybook/react-native',
Expand Down
8 changes: 8 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/Overlay",
files: "**/*.stories.?(ts|tsx|js|jsx)",
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Overlay(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
},
];

import "@storybook/addon-ondevice-controls/register";
Expand All @@ -50,6 +57,7 @@ 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/Overlay/Overlay.stories.tsx": require("../app/component-library/components/Overlay/Overlay.stories.tsx"),
};
};

Expand Down
43 changes: 17 additions & 26 deletions app/component-library/components/Overlay/Overlay.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
/* eslint-disable no-console, react-native/no-inline-styles */

// Third party dependencies.
import React from 'react';
import { color } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react-native';

/* eslint-disable no-console */
// External dependencies.
import { mockTheme } from '../../../util/theme';
import { storybookPropsGroupID } from '../../constants/storybook.constants';

// Internal dependencies.
import Overlay from './Overlay';
import { OverlayProps } from './Overlay.types';

export const getOverlayStoryProps = (): OverlayProps => {
const colorSelector = color(
'color',
mockTheme.colors.overlay.default,
storybookPropsGroupID,
);
import { default as OverlayComponent } from './Overlay';

const OverlayMeta = {
title: 'Component Library / Overlay',
component: OverlayComponent,
argTypes: {
color: {
control: { type: 'color' },
defaultValue: mockTheme.colors.overlay.default,
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
},
},
};
export default OverlayMeta;

return {
color: colorSelector,
export const Overlay = {
args: {
onPress: () => console.log("I'm clicked!"),
};
},
};

const OverlayStory = () => <Overlay {...getOverlayStoryProps()} />;

storiesOf('Component Library / Overlay', module).add('Overlay', OverlayStory);

export default OverlayStory;
Loading