Skip to content

Commit

Permalink
refactor: Convert Overlay story to csf format (#7412)
Browse files Browse the repository at this point in the history
## **Description**
-Converted Overlay story to csf format

## **Screenshots/Recordings**
![Simulator Screen Shot - iPhone 14 Pro - 2023-10-07 at 16 51
09](https://github.com/MetaMask/metamask-mobile/assets/14355083/19d03094-40b5-46ee-9b33-08d91f3b3537)
![Simulator Screen Shot - iPhone 14 Pro - 2023-10-07 at 16 51
28](https://github.com/MetaMask/metamask-mobile/assets/14355083/dcfe89d4-64ef-4826-88c9-03e79fe185ad)


## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've clearly explained:
  - [ ] What problem this PR is solving.
  - [ ] How this problem was solved.
  - [ ] How reviewers can test my changes.
- [ ] I’ve indicated what issue this PR is linked to: Fixes #???
- [ ] I’ve included tests if applicable.
- [ ] I’ve documented any added code.
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
brianacnguyen authored Oct 25, 2023
1 parent 3c395f6 commit 289d1fe
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
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)',
'../app/component-library/components/Icons/**/*.stories.?(ts|tsx|js|jsx)',
'../app/component-library/components/Checkbox/**/*.stories.?(ts|tsx|js|jsx)',
],
Expand Down
58 changes: 33 additions & 25 deletions .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,56 @@ import {
addParameters,
addArgsEnhancer,
clearDecorators,
} from "@storybook/react-native";
} from '@storybook/react-native';

global.STORIES = [
{
titlePrefix: "",
directory: "./app/component-library/components/Cards/Card",
files: "**/*.stories.?(ts|tsx|js|jsx)",
titlePrefix: '',
directory: './app/component-library/components/Cards/Card',
files: '**/*.stories.?(ts|tsx|js|jsx)',
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Cards\\/Card(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
'^\\.[\\\\/](?:app\\/component-library\\/components\\/Cards\\/Card(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
},
{
titlePrefix: "",
titlePrefix: '',
directory:
"./app/component-library/components/Banners/Banner/variants/BannerAlert",
files: "**/*.stories.?(ts|tsx|js|jsx)",
'./app/component-library/components/Banners/Banner/variants/BannerAlert',
files: '**/*.stories.?(ts|tsx|js|jsx)',
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Banners\\/Banner\\/variants\\/BannerAlert(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
'^\\.[\\\\/](?:app\\/component-library\\/components\\/Banners\\/Banner\\/variants\\/BannerAlert(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
},
{
titlePrefix: "",
directory: "./app/component-library/components/Icons",
files: "**/*.stories.?(ts|tsx|js|jsx)",
titlePrefix: '',
directory: './app/component-library/components/Overlay',
files: '**/*.stories.?(ts|tsx|js|jsx)',
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Icons(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
'^\\.[\\\\/](?:app\\/component-library\\/components\\/Overlay(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
},
{
titlePrefix: "",
directory: "./app/component-library/components/Checkbox",
files: "**/*.stories.?(ts|tsx|js|jsx)",
titlePrefix: '',
directory: './app/component-library/components/Icons',
files: '**/*.stories.?(ts|tsx|js|jsx)',
importPathMatcher:
"^\\.[\\\\/](?:app\\/component-library\\/components\\/Checkbox(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$",
'^\\.[\\\\/](?:app\\/component-library\\/components\\/Icons(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
},
{
titlePrefix: '',
directory: './app/component-library/components/Checkbox',
files: '**/*.stories.?(ts|tsx|js|jsx)',
importPathMatcher:
'^\\.[\\\\/](?:app\\/component-library\\/components\\/Checkbox(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
},
];

import "@storybook/addon-ondevice-controls/register";
import '@storybook/addon-ondevice-controls/register';

import { decorators, parameters } from "./preview";
import { decorators, parameters } from './preview';

if (decorators) {
if (__DEV__) {
// stops the warning from showing on every HMR
require("react-native").LogBox.ignoreLogs([
"`clearDecorators` is deprecated and will be removed in Storybook 7.0",
require('react-native').LogBox.ignoreLogs([
'`clearDecorators` is deprecated and will be removed in Storybook 7.0',
]);
}
// workaround for global decorators getting infinitely applied on HMR, see https://github.com/storybookjs/react-native/issues/185
Expand All @@ -62,10 +69,11 @@ if (parameters) {

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/Icons/Icon/Icon.stories.tsx": require("../app/component-library/components/Icons/Icon/Icon.stories.tsx"),
"./app/component-library/components/Checkbox/Checkbox.stories.tsx": require("../app/component-library/components/Checkbox/Checkbox.stories.tsx"),
'./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'),
'./app/component-library/components/Icons/Icon/Icon.stories.tsx': require('../app/component-library/components/Icons/Icon/Icon.stories.tsx'),
'./app/component-library/components/Checkbox/Checkbox.stories.tsx': require('../app/component-library/components/Checkbox/Checkbox.stories.tsx'),
};
};

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

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

// 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,
);

return {
color: colorSelector,
onPress: () => console.log("I'm clicked!"),
};
import { default as OverlayComponent } from './Overlay';

const OverlayMeta = {
title: 'Component Library / Overlay',
component: OverlayComponent,
argTypes: {
color: {
control: { type: 'color' },
defaultValue: mockTheme.colors.overlay.default,
},
},
};
export default OverlayMeta;

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

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

export default OverlayStory;
export const Overlay = {
render: (args: any) => (
<OverlayComponent {...args} onPress={() => console.log("I'm clicked!")} />
),
};

0 comments on commit 289d1fe

Please sign in to comment.