From dac99ebd8708c6c0739f488120b1adb5c62d970c Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Tue, 7 Jan 2025 15:38:58 +0000 Subject: [PATCH 1/2] Update stories on Storybook Signed-off-by: Charles de Dreuille --- .../canon/src/components/Box/Box.stories.tsx | 43 +++++-- .../src/components/Button/Button.stories.tsx | 67 ++++++++-- .../canon/src/components/Button/Button.tsx | 5 +- packages/canon/src/components/Button/types.ts | 1 + .../components/Checkbox/Checkbox.stories.tsx | 31 ++++- .../Container/Container.stories.tsx | 28 +++-- .../src/components/Grid/Grid.stories.tsx | 18 ++- .../components/Heading/Heading.stories.tsx | 32 +++-- .../canon/src/components/Heading/Heading.tsx | 1 + .../src/components/Icon/Icon.stories.tsx | 6 +- packages/canon/src/components/Icon/icons.ts | 10 +- packages/canon/src/components/Icon/index.tsx | 1 + packages/canon/src/components/Icon/types.ts | 3 + .../src/components/Inline/Inline.stories.tsx | 59 +++------ .../src/components/Stack/Stack.stories.tsx | 119 ++++++++++-------- ...Example1.stories.tsx => Table.stories.tsx} | 42 ++++--- .../Table/stories/Table.stories.tsx | 32 ----- .../Table/stories/TableBody.stories.tsx | 40 ------ .../Table/stories/TableCaption.stories.tsx | 30 ----- .../Table/stories/TableCell.stories.tsx | 30 ----- .../Table/stories/TableFooter.stories.tsx | 30 ----- .../Table/stories/TableHead.stories.tsx | 30 ----- .../Table/stories/TableHeader.stories.tsx | 40 ------ .../Table/stories/TableRow.stories.tsx | 42 ------- .../src/components/Text/Text.stories.tsx | 80 +++++++++--- packages/canon/src/components/Text/Text.tsx | 5 +- packages/canon/src/components/Text/types.ts | 4 +- 27 files changed, 378 insertions(+), 451 deletions(-) rename packages/canon/src/components/Table/{stories/Example1.stories.tsx => Table.stories.tsx} (86%) delete mode 100644 packages/canon/src/components/Table/stories/Table.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableBody.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableCaption.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableCell.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableFooter.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableHead.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableHeader.stories.tsx delete mode 100644 packages/canon/src/components/Table/stories/TableRow.stories.tsx diff --git a/packages/canon/src/components/Box/Box.stories.tsx b/packages/canon/src/components/Box/Box.stories.tsx index bd4e597fa0..d11f9fbab7 100644 --- a/packages/canon/src/components/Box/Box.stories.tsx +++ b/packages/canon/src/components/Box/Box.stories.tsx @@ -40,22 +40,28 @@ const meta = { export default meta; type Story = StoryObj; -export const Basic: Story = { +export const Default: Story = { args: { style: { - background: '#1f47ff', - color: 'white', - padding: '4px 8px', + width: '64px', + height: '64px', + background: '#eaf2fd', borderRadius: '4px', + border: '1px solid #2563eb', + color: '#2563eb', + backgroundImage: + 'url("data:image/svg+xml,%3Csvg%20width%3D%226%22%20height%3D%226%22%20viewBox%3D%220%200%206%206%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cg%20fill%3D%22%232563eb%22%20fill-opacity%3D%220.3%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M5%200h1L0%206V5zM6%205v1H5z%22/%3E%3C/g%3E%3C/svg%3E")', }, - children: 'Basic Box', }, }; export const Display: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, + width: 'auto', + height: 'auto', + padding: '8px', }, }, render: args => ( @@ -84,7 +90,10 @@ export const Display: Story = { export const FlexDirection: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, + width: 'auto', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -110,8 +119,10 @@ export const FlexDirection: Story = { export const JustifyContent: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -153,9 +164,10 @@ export const JustifyContent: Story = { export const AlignItems: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', height: '100px', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -289,8 +301,10 @@ export const Margin: Story = { export const FlexWrap: Story = { args: { style: { - ...Basic.args?.style, + ...Default.args?.style, width: '200px', + height: 'auto', + padding: '8px', }, display: 'flex', gap: 'xs', @@ -328,11 +342,14 @@ export const FlexWrap: Story = { export const BorderRadius: Story = { args: { style: { - background: '#1f47ff', - color: 'white', - padding: '4px 8px', width: '64px', height: '64px', + background: '#eaf2fd', + border: '1px solid #2563eb', + color: '#2563eb', + backgroundImage: + 'url("data:image/svg+xml,%3Csvg%20width%3D%226%22%20height%3D%226%22%20viewBox%3D%220%200%206%206%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cg%20fill%3D%22%232563eb%22%20fill-opacity%3D%220.3%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M5%200h1L0%206V5zM6%205v1H5z%22/%3E%3C/g%3E%3C/svg%3E")', + padding: '4px 8px', }, display: 'flex', alignItems: 'center', diff --git a/packages/canon/src/components/Button/Button.stories.tsx b/packages/canon/src/components/Button/Button.stories.tsx index c921efa6f2..728098970c 100644 --- a/packages/canon/src/components/Button/Button.stories.tsx +++ b/packages/canon/src/components/Button/Button.stories.tsx @@ -19,13 +19,12 @@ import type { Meta, StoryObj } from '@storybook/react'; import { Button } from './Button'; import { Inline } from '../Inline'; import { Stack } from '../Stack'; +import { Text } from '../Text'; +import { ButtonProps } from './types'; const meta = { title: 'Components/Button', component: Button, - parameters: { - layout: 'centered', - }, argTypes: { size: { control: 'select', @@ -40,12 +39,6 @@ const meta = { export default meta; type Story = StoryObj; -export const Primary: Story = { - args: { - children: 'Primary button', - }, -}; - export const Variants: Story = { args: { children: 'Button', @@ -59,9 +52,15 @@ export const Variants: Story = { }, render: () => ( - - - + + + ), }; @@ -125,3 +124,47 @@ export const Responsive: Story = { }, }, }; + +const variants: string[] = ['primary', 'secondary', 'tertiary']; + +export const Playground: Story = { + args: { + children: 'Button', + }, + render: () => ( + + {variants.map(variant => ( + + {variant} + {['small', 'medium'].map(size => ( + + + + + + ))} + + ))} + + ), +}; diff --git a/packages/canon/src/components/Button/Button.tsx b/packages/canon/src/components/Button/Button.tsx index e4166e5c79..081d09a1d5 100644 --- a/packages/canon/src/components/Button/Button.tsx +++ b/packages/canon/src/components/Button/Button.tsx @@ -29,6 +29,8 @@ export const Button = forwardRef( iconStart, iconEnd, children, + style, + ...rest } = props; const { getResponsiveValue } = useCanon(); @@ -39,7 +41,7 @@ export const Button = forwardRef( return (