Skip to content

Commit

Permalink
[Feature/BAR-156] 버튼 컴포넌트 작성 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
miro-ring authored Jan 7, 2024
1 parent 4a2b4c2 commit eeeb205
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
111 changes: 111 additions & 0 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import type { Meta, StoryObj } from '@storybook/react';

import Button from '.';

const meta: Meta<typeof Button> = {
title: 'Components/Button',
component: Button,
parameters: {
componentSubtitle: 'Action이나 Event를 Trigger하는 컴포넌트',
},
};

export default meta;

type Story = StoryObj<typeof Button>;

export const MiddleDefault: Story = {
args: {
children: 'MiddleDefault',
size: 'M',
state: 'default',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'M size, Default state Button',
},
},
},
};

export const MiddleDisabled: Story = {
args: {
children: 'MiddleDisabled',
size: 'M',
state: 'disabled',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'M size, Disabled state Button',
},
},
},
};

export const MiddleEnabled: Story = {
args: {
children: 'MiddleEnabled',
size: 'M',
state: 'enabled',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'M size, Enabled state Button',
},
},
},
};

export const LargeDefault: Story = {
args: {
children: 'LargeDefault',
size: 'L',
state: 'default',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'L size, Default state Button',
},
},
},
};

export const LargeDisabled: Story = {
args: {
children: 'LargeDisabled',
size: 'L',
state: 'disabled',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'L size, Disabled state Button',
},
},
},
};

export const LargeEnabled: Story = {
args: {
children: 'LargeEnabled',
size: 'L',
state: 'enabled',
onClick: () => {},
},
parameters: {
docs: {
description: {
story: 'L size, Enabled state Button',
},
},
},
};
32 changes: 32 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { ComponentPropsWithoutRef, PropsWithChildren } from 'react';
import type { RecipeVariants } from '@vanilla-extract/recipes';
import clsx from 'clsx';

import * as styles from './style.css';

interface ButtonProps
extends RecipeVariants<typeof styles.button>,
PropsWithChildren<ComponentPropsWithoutRef<'button'>> {
onClick: () => void;
}

const Button = ({
children,
className,
size,
state,
onClick,
type = 'button',
}: ButtonProps) => {
return (
<button
className={clsx(styles.button({ state, size }), className)}
type={type}
onClick={onClick}
>
{children}
</button>
);
};

export default Button;
40 changes: 40 additions & 0 deletions src/components/Button/style.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { recipe } from '@vanilla-extract/recipes';

import { sprinkles } from '@/src/styles/sprinkles.css';
import { COLORS } from '@/src/styles/tokens';

export const button = recipe({
variants: {
state: {
default: {
backgroundColor: COLORS['Grey/150'],
color: COLORS['Grey/600'],
},
disabled: {
backgroundColor: COLORS['Blue/Default'],
color: COLORS['Grey/White'],
opacity: '50%',
},
enabled: {
backgroundColor: COLORS['Blue/Default'],
color: COLORS['Grey/White'],
},
},
size: {
M: [
sprinkles({ typography: '15/Title/Medium' }),
{
padding: '15px 24px',
borderRadius: '8px',
},
],
L: [
sprinkles({ typography: '16/Title/Medium' }),
{
padding: '18.5px 40px',
borderRadius: '8px',
},
],
},
},
});

0 comments on commit eeeb205

Please sign in to comment.