From bf3060d0f4b8efb6ebba3044533f142d79457014 Mon Sep 17 00:00:00 2001 From: TaeeunKim Date: Sun, 28 Jul 2024 18:25:48 +0200 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20Spacing=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/Spacing/Spacing.stories.tsx | 81 +++++++++++++++++++ src/components/Common/Spacing/Spacing.tsx | 27 +++++++ src/components/Common/Spacing/spacing.css.ts | 8 ++ src/components/Common/index.ts | 1 + 4 files changed, 117 insertions(+) create mode 100644 src/components/Common/Spacing/Spacing.stories.tsx create mode 100644 src/components/Common/Spacing/Spacing.tsx create mode 100644 src/components/Common/Spacing/spacing.css.ts diff --git a/src/components/Common/Spacing/Spacing.stories.tsx b/src/components/Common/Spacing/Spacing.stories.tsx new file mode 100644 index 00000000..3cf539af --- /dev/null +++ b/src/components/Common/Spacing/Spacing.stories.tsx @@ -0,0 +1,81 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import type { PropsWithChildren } from 'react'; + +import Spacing from './Spacing'; + +import { vars } from '@/styles/theme.css'; + +const meta: Meta = { + title: 'common/Spacing', + component: Spacing, +}; + +export default meta; +type Story = StoryObj; + +const Container = ({ children, vertical }: PropsWithChildren<{ vertical?: boolean }>) => { + return ( +
+ {children} +
+ ); +}; + +const Box = () => { + return ( +
+ ); +}; + +export const Default: Story = { + render: ({ direction = 'vertical', size }) => ( + + + + + + + + + + ), +}; + +export const Vertical: Story = { + render: ({ size }) => ( + + + + + + + + + + ), +}; + +export const Horizontal: Story = { + render: ({ size }) => ( + + + + + + + + + + ), +}; diff --git a/src/components/Common/Spacing/Spacing.tsx b/src/components/Common/Spacing/Spacing.tsx new file mode 100644 index 00000000..d2bc12d0 --- /dev/null +++ b/src/components/Common/Spacing/Spacing.tsx @@ -0,0 +1,27 @@ +import type { ComponentPropsWithoutRef } from 'react'; + +import { spacing, spacingSize } from './spacing.css'; + +import { assignInlineVars } from '@vanilla-extract/dynamic'; + +type SpacingDirections = 'vertical' | 'horizontal'; + +export interface SpacingProps extends ComponentPropsWithoutRef<'div'> { + direction?: SpacingDirections; + size: number; +} + +const Spacing = ({ direction = 'vertical', size, ...props }: SpacingProps) => { + return ( +