From c7d3c4e3cf01e0b8b7c44418e01d86bf43749bcb Mon Sep 17 00:00:00 2001 From: Enzo Vezzaro Date: Fri, 22 Apr 2022 08:07:57 -0400 Subject: [PATCH] create basic component for initial setup --- .../index.module.css} | 0 .../@shared/atoms/Button/index.stories.tsx | 26 +++++++++++++++++++ .../@shared/atoms/Button/index.test.jsx | 22 ++++++++++++++++ .../atoms/{Button.tsx => Button/index.tsx} | 2 +- src/stories/Header.tsx | 17 ++++++------ src/stories/Page.stories.tsx | 7 ----- src/stories/Page.tsx | 2 +- 7 files changed, 59 insertions(+), 17 deletions(-) rename src/components/@shared/atoms/{Button.module.css => Button/index.module.css} (100%) create mode 100644 src/components/@shared/atoms/Button/index.stories.tsx create mode 100644 src/components/@shared/atoms/Button/index.test.jsx rename src/components/@shared/atoms/{Button.tsx => Button/index.tsx} (96%) diff --git a/src/components/@shared/atoms/Button.module.css b/src/components/@shared/atoms/Button/index.module.css similarity index 100% rename from src/components/@shared/atoms/Button.module.css rename to src/components/@shared/atoms/Button/index.module.css diff --git a/src/components/@shared/atoms/Button/index.stories.tsx b/src/components/@shared/atoms/Button/index.stories.tsx new file mode 100644 index 000000000..428f381a8 --- /dev/null +++ b/src/components/@shared/atoms/Button/index.stories.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import { ComponentStory, ComponentMeta } from '@storybook/react' + +import Button, { ButtonProps } from '@shared/atoms/Button' + +// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export +export default { + title: 'Component/@shared/atoms/Button', + component: Button +} as ComponentMeta + +// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args +const Template: ComponentStory = (args: ButtonProps) => ( + ) : ( <> - + )} diff --git a/src/stories/Page.stories.tsx b/src/stories/Page.stories.tsx index 416b95a29..e6910ac04 100644 --- a/src/stories/Page.stories.tsx +++ b/src/stories/Page.stories.tsx @@ -17,10 +17,3 @@ const Template: ComponentStory = (args) => export const LoggedOut = Template.bind({}) export const LoggedIn = Template.bind({}) - -// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing -LoggedIn.play = async ({ canvasElement }) => { - const canvas = within(canvasElement) - const loginButton = await canvas.getByRole('button', { name: /Log in/i }) - await userEvent.click(loginButton) -} diff --git a/src/stories/Page.tsx b/src/stories/Page.tsx index 292fa91e5..df5abc18c 100644 --- a/src/stories/Page.tsx +++ b/src/stories/Page.tsx @@ -40,7 +40,7 @@ export const Page: React.VFC = () => {
  • Use a higher-level connected component. Storybook helps you compose - such data from the "args" of child component stories + such data from the "args" of child component stories
  • Assemble data in the page component from your services. You can mock