From 6bac3e28a17130448eee7a8810c8009091af7927 Mon Sep 17 00:00:00 2001 From: Narin Ratana Date: Thu, 9 Nov 2023 10:20:21 -0800 Subject: [PATCH] Rename VAButton to Button. Refactor styling to use switch statement. Remove empty files. Commit root yarn.lock --- .../.storybook/native/storybook.requires.js | 52 +++++----- .../Button.stories.tsx} | 14 +-- .../Button.test.tsx} | 6 +- .../VAButton.tsx => Button/Button.tsx} | 97 ++++++++++--------- packages/components/src/index.tsx | 2 +- packages/tokens/src/tokens.json | 0 packages/tokens/src/tokens.tsx | 0 yarn.lock | 9 +- 8 files changed, 95 insertions(+), 85 deletions(-) rename packages/components/src/components/{VAButton/VAButton.stories.tsx => Button/Button.stories.tsx} (73%) rename packages/components/src/components/{VAButton/VAButton.test.tsx => Button/Button.test.tsx} (85%) rename packages/components/src/components/{VAButton/VAButton.tsx => Button/Button.tsx} (55%) delete mode 100644 packages/tokens/src/tokens.json delete mode 100644 packages/tokens/src/tokens.tsx diff --git a/packages/components/.storybook/native/storybook.requires.js b/packages/components/.storybook/native/storybook.requires.js index b2887948..0e1dfff3 100644 --- a/packages/components/.storybook/native/storybook.requires.js +++ b/packages/components/.storybook/native/storybook.requires.js @@ -6,57 +6,57 @@ import { addParameters, addArgsEnhancer, clearDecorators, -} from "@storybook/react-native"; +} from '@storybook/react-native' global.STORIES = [ { - titlePrefix: "", - directory: "./src/components", - files: "**/*.stories.mdx", + titlePrefix: '', + directory: './src/components', + files: '**/*.stories.mdx', importPathMatcher: - "^\\.[\\\\/](?:src\\/components(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$", + '^\\.[\\\\/](?:src\\/components(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.mdx)$', }, { - titlePrefix: "", - directory: "./src/components", - files: "**/*.stories.@(js|jsx|ts|tsx)", + titlePrefix: '', + directory: './src/components', + files: '**/*.stories.@(js|jsx|ts|tsx)', importPathMatcher: - "^\\.[\\\\/](?:src\\/components(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$", + '^\\.[\\\\/](?:src\\/components(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$', }, -]; +] -import "@storybook/addon-ondevice-controls/register"; -import "@storybook/addon-ondevice-actions/register"; +import '@storybook/addon-ondevice-controls/register' +import '@storybook/addon-ondevice-actions/register' -import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"; +import { argsEnhancers } from '@storybook/addon-actions/dist/modern/preset/addArgs' -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 - clearDecorators(); - decorators.forEach((decorator) => addDecorator(decorator)); + clearDecorators() + decorators.forEach((decorator) => addDecorator(decorator)) } if (parameters) { - addParameters(parameters); + addParameters(parameters) } try { - argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer)); + argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer)) } catch {} const getStories = () => { return { - "./src/components/SegmentedControl/SegmentedControl.stories.tsx": require("../../src/components/SegmentedControl/SegmentedControl.stories.tsx"), - "./src/components/VAButton/VAButton.stories.tsx": require("../../src/components/VAButton/VAButton.stories.tsx"), - }; -}; + './src/components/SegmentedControl/SegmentedControl.stories.tsx': require('../../src/components/SegmentedControl/SegmentedControl.stories.tsx'), + './src/components/Button/Button.stories.tsx': require('../../src/components/Button/Button.stories.tsx'), + } +} -configure(getStories, module, false); +configure(getStories, module, false) diff --git a/packages/components/src/components/VAButton/VAButton.stories.tsx b/packages/components/src/components/Button/Button.stories.tsx similarity index 73% rename from packages/components/src/components/VAButton/VAButton.stories.tsx rename to packages/components/src/components/Button/Button.stories.tsx index cf2cfd62..fc78983a 100644 --- a/packages/components/src/components/VAButton/VAButton.stories.tsx +++ b/packages/components/src/components/Button/Button.stories.tsx @@ -1,11 +1,11 @@ +import { Button, ButtonProps, ButtonVariants } from './Button' import { Meta, StoryObj } from '@storybook/react-native' -import { VAButton, VAButtonProps, VAButtonVariants } from './VAButton' import { View } from 'react-native' import React from 'react' -const meta: Meta = { - title: 'VAButton', - component: VAButton, +const meta: Meta = { + title: 'Button', + component: Button, argTypes: { onPress: { action: 'onPress event', @@ -29,7 +29,7 @@ const meta: Meta = { export default meta -type Story = StoryObj +type Story = StoryObj export const Primary: Story = { storyName: 'Primary', @@ -42,7 +42,7 @@ export const Primary: Story = { export const Secondary: Story = { storyName: 'Secondary', args: { - buttonType: VAButtonVariants.Secondary, + buttonType: ButtonVariants.Secondary, label: 'Button text', }, } @@ -50,7 +50,7 @@ export const Secondary: Story = { export const Destructive: Story = { storyName: 'Destructive', args: { - buttonType: VAButtonVariants.Destructive, + buttonType: ButtonVariants.Destructive, label: 'Button text', }, } diff --git a/packages/components/src/components/VAButton/VAButton.test.tsx b/packages/components/src/components/Button/Button.test.tsx similarity index 85% rename from packages/components/src/components/VAButton/VAButton.test.tsx rename to packages/components/src/components/Button/Button.test.tsx index 1b0fba9c..a625c69f 100644 --- a/packages/components/src/components/VAButton/VAButton.test.tsx +++ b/packages/components/src/components/Button/Button.test.tsx @@ -5,16 +5,16 @@ import React from 'react' import 'jest-styled-components' import { ReactTestInstance } from 'react-test-renderer' -import { VAButton } from './VAButton' +import { Button } from './Button' -describe('VAButton', () => { +describe('Button', () => { let component: RenderAPI let testInstance: ReactTestInstance const onPressSpy = jest.fn() const initializeTestInstance = (): void => { - component = render() + component = render(