-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement button atom component/#19 #24
Changes from all commits
be42996
306b87a
a935a7b
9aec13e
0308ea8
35957d3
ff59271
1766af6
0d372c8
4352042
0f5a644
77241e9
e76ded8
8323010
43a32f3
1d6594e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard-dynamic-subset.min.css" | ||
/> | ||
|
||
<style> | ||
* { | ||
font-family: 'Pretendard'; | ||
} | ||
</style> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Button } from './button'; | ||
|
||
const meta = { | ||
title: 'ui/view/atom/Button', | ||
component: Button, | ||
tags: ['autodocs'], | ||
parameters: { | ||
componentSubtitle: 'Button์ ์ฌ์ฉ์๊ฐ ํ ๋ฒ์ ํญ์ผ๋ก ์์ ์ ์ํํ๊ณ ์ ํํ ์ ์๋ ์ปดํฌ๋ํธ์ ๋๋ค.', | ||
docs: { | ||
description: { | ||
component: ` | ||
- variant๊ฐ์ผ๋ก "primary" | "secondary" | "text" | "delete" ์ค ํ๋๋ฅผ ์ ํํ ์ ์์ต๋๋ค.\n | ||
- size๊ฐ์ผ๋ก "lg" | "md" | "sm" | "xs" | "default" ์ค ํ๋๋ฅผ ์ ํํ ์ ์์ต๋๋ค.\n | ||
- label ๊ฐ์ผ๋ก button ํ๊ทธ์ ์กด์ฌํ๋ text๋ฅผ ์๋ฏธํ๊ณ ํ์์ ์ผ๋ก ํ ๋นํด์ผ ํฉ๋๋ค | ||
`, | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
variant: { | ||
description: 'Button์ Variant๋ฅผ ์ค์ ํฉ๋๋ค.', | ||
table: { | ||
type: { summary: 'ButtonVariant' }, | ||
defaultValue: { summary: 'primary' }, | ||
}, | ||
options: ['primary', 'secondary', 'text', 'delete'], | ||
control: { | ||
type: 'radio', | ||
}, | ||
}, | ||
size: { | ||
description: 'Button์ size๋ฅผ ์ค์ ํฉ๋๋ค.', | ||
table: { | ||
type: { summary: 'ButtonSize' }, | ||
defaultValue: { summary: 'md' }, | ||
}, | ||
options: ['lg', 'md', 'sm', 'xs', 'default'], | ||
control: { | ||
type: 'radio', | ||
}, | ||
}, | ||
label: { | ||
description: 'Button์ label์ ์ค์ ํฉ๋๋ค', | ||
table: { | ||
type: { summary: 'ButtonLabel' }, | ||
defaultValue: { summary: '' }, | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
|
||
export const PrimaryButton: StoryObj<typeof Button> = { | ||
args: { | ||
size: 'md', | ||
variant: 'primary', | ||
label: '์๊ฐํํฉ ์์ธํ๋ณด๊ธฐ', | ||
}, | ||
render: (args) => <Button {...args} />, | ||
}; | ||
|
||
export const SecondaryButton: StoryObj<typeof Button> = { | ||
args: { | ||
size: 'xs', | ||
variant: 'secondary', | ||
label: '์ปค์คํ ํ๊ธฐ', | ||
}, | ||
render: (args) => <Button {...args} />, | ||
}; | ||
|
||
export const DeleteButton: StoryObj<typeof Button> = { | ||
args: { | ||
size: 'default', | ||
variant: 'delete', | ||
label: '์ญ์ ', | ||
}, | ||
render: (args) => <Button {...args} />, | ||
}; | ||
Comment on lines
+56
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ฒ์์๋ text๋ฅผ label์ด ์๋ children์ผ๋ก ๋ฐ์๊ธฐ์ ์ง์ ํด์ฃผ๋ ๋ณ ๋ค๋ฅธ ์คํ์ผ์ด ์์๊ณ ์คํ ๋ฆฌ๋ถ์ ๊ตณ์ด ์์ฑํง ํ์๊ฐ ์๋ค๊ณ ์๊ฐํด์ ์์ฑํ์ง ์์์ต๋๋ค! |
||
|
||
export const TextButton: StoryObj<typeof Button> = { | ||
args: { | ||
size: 'default', | ||
variant: 'text', | ||
label: 'ํ์ํํดํ๊ธฐ', | ||
}, | ||
render: (args) => <Button {...args} />, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { cva } from 'class-variance-authority'; | ||
import React from 'react'; | ||
|
||
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | ||
label: string; | ||
variant?: 'primary' | 'secondary' | 'text' | 'delete'; | ||
size?: 'xs' | 'sm' | 'md' | 'lg' | 'default'; | ||
} | ||
|
||
export const ButtonVariants = cva(`flex justify-center items-center`, { | ||
variants: { | ||
variant: { | ||
primary: 'bg-primary rounded-[100px] text-white border-0 hover:bg-primary-hover', | ||
secondary: 'bg-white rounded-[100px] border-solid border-[1px] border-gray hover:bg-white-hover', | ||
text: 'font-medium text-slate-400 text-sm hover:text-slate-600', | ||
delete: 'py-2 px-3.5 bg-[#35353559] rounded-[7px] text-white leading-5 font-medium text-[18px]', | ||
}, | ||
size: { | ||
default: '', | ||
xs: 'px-5 py-3 text-lg font-medium leading-5', | ||
sm: 'px-12 py-3.5 text-sm font-medium leading-3', | ||
md: 'px-6 py-4 text-lg font-medium leading-3', | ||
lg: 'px-32 py-6 text-3xl font-medium leading-9', | ||
}, | ||
}, | ||
}); | ||
|
||
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button( | ||
{ label, variant = 'primary', size = 'default', ...props }, | ||
ref, | ||
) { | ||
return ( | ||
<button className={ButtonVariants({ variant, size })} {...props} ref={ref}> | ||
{label} | ||
</button> | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next์์ font ์ต์ ํ๋ฅผ ์ ๊ณตํด์ฃผ๋ ์ง ๋ชฐ๋์ต๋๋ค
์ถํ ์์ ํ๊ฒ ์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ต ์ฐธ๊ณ ๋งํฌ ์ฒจ๋ถํด๋๊ฒ ์ต๋๋ค
https://nextjs.org/docs/app/building-your-application/optimizing/fonts