Skip to content
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

Merged
merged 16 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard-dynamic-subset.min.css"
/>

<style>
* {
font-family: 'Pretendard';
}
</style>
1 change: 1 addition & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Preview } from '@storybook/react';
import '../app/globals.css';

const preview: Preview = {
parameters: {
Expand Down
14 changes: 9 additions & 5 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}

*,
a {
font-family: 'Pretendard';
}

a:-webkit-any-link {
text-decoration: none;
}
11 changes: 7 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';

const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
Expand All @@ -16,7 +13,13 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<head>
<link
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css"
rel="stylesheet"
/>
</head>
<body>{children}</body>
Comment on lines +16 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]

  • next์—์„œ font ์ตœ์ ํ™”๋ฅผ ์œ„ํ•œ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์•„๋Š”๋ฐ ํ•ด๋‹น ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?
  • ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ์ž„์‹œ์šฉ๋„๋ผ๋ฉด ๊ดœ์ฐฎ์œผ๋‚˜ ์•„๋‹ˆ๋ผ๋ฉด ์ˆ˜์ •์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next์—์„œ font ์ตœ์ ํ™”๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ์ง€ ๋ชฐ๋ž์Šต๋‹ˆ๋‹ค
์ถ”ํ›„ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค

Copy link
Collaborator

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

</html>
);
}
90 changes: 90 additions & 0 deletions app/ui/view/atom/button/button.stories.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]
์Šคํ† ๋ฆฌ๋ถ ํ™•์ธํ–ˆ๋Š”๋ฐ ์ƒ๊ฐ๋ณด๋‹ค ํ›จ์”ฌ ๋ฉ‹์žˆ๋„ค์š”!! ๋„ˆ๋ฌด ์ข‹์Šต๋‹ˆ๋‹ค. ํ™•์ธ ํ›„ ์งˆ๋ฌธ๊ณผ ์˜๊ฒฌ์„ ๋‚จ๊น๋‹ˆ๋‹ค.

  • ๋ฌธ์„œํ™”๋ฅผ ์œ„ํ•ด meta์˜ description๊ณผ argtype์„ ์ƒ์„ธํ•˜๊ฒŒ ์ž‘์„ฑํ•ด์ฃผ์‹  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์ด ๊ณผ์ •์—์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋‘ ๋ฒˆ ๊ฐœ๋ฐœํ•œ๋‹ค๋Š” ๋Š๋‚Œ์ด ๋“ค์—ˆ๊ฑฐ๋‚˜, ์‹œ๊ฐ„์ด ๋„ˆ๋ฌด ์˜ค๋ž˜ ๊ฑธ๋ฆฌ์ง€ ์•Š์•˜๋‚˜์š”?
  • ๋งŒ์•ฝ ๋ถˆํŽธํ•จ์„ ๋Š๊ผˆ๋‹ค๋ฉด, ๋ฌธ์„œํ™”๋Š” ๊ฐœ๋ฐœ ๋‹จ๊ณ„๊ฐ€ ์•ˆ์ •ํ™”๋˜์—ˆ์„ ๋•Œ ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ์€ ์–ด๋–จ๊นŒ์š”? ์ดˆ๋ฐ˜์—๋Š” atom ์ปดํฌ๋„ŒํŠธ๋ผ๋„ ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ๋งŽ์„ ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜๋ฏ€๋กœ, ๋ฌธ์„œํ™”๋ฅผ ๋™์‹œ์— ์ง„ํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด ์ž‘์—… ๋ถ€๋‹ด์ด ๋„ˆ๋ฌด ์ปค์งˆ ๊ฒƒ ๊ฐ™์•„ ๊ฑฑ์ •์ด ๋ฉ๋‹ˆ๋‹ค.
  • ์ •๋ฆฌํ•˜๋ฉด ์Šคํ† ๋ฆฌ๋ถ์€ ๊ฐœ๋ฐœ(์‹œ๊ฐํ™” ๋„๊ตฌ)๊ณผ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ  docs์œ„ํ•œ ์„ธํŒ…์€ ๊ฐœ๋ฐœ์ด ์•ˆ์ •๋˜์—ˆ์„ ๋•Œ ํ•˜๋Š”๊ฒŒ ์–ด๋–จ๊นŒ์š”?

Copy link
Member Author

@gahyuun gahyuun Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • button component๋ฅผ ๊ฐœ๋ฐœํ•˜๋ฉด์„œ ๋Š๋ผ์ง„ ๋ชปํ–ˆ์ง€๋งŒ ๊ฒฐ๊ตญ ์–ธ์  ๊ฐ€ storybook ์ž‘์„ฑ์ด ๋ถ€๋‹ด์ด ๋  ๊ฒƒ ๊ฐ™๊ธดํ•ฉ๋‹ˆ๋‹ค
  • ๊ทธ๋ž˜์„œ ์ €๋„ ๊ฐœ๋ฐœ์ด ์•ˆ์ •๋˜๊ธฐ ์ „๊นŒ์ง€๋Š” ์Šคํ† ๋ฆฌ๋ถ์„ ์‹œ๊ฐ์  ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฑฐ ์ข‹์Šต๋‹ˆ๋‹ค
  • ๋‹ค๋งŒ description์€ ๊ตณ์ด ๊ฐœ๋ฐœ์„ ํ•˜๋ฉด์„œ ์ž‘์„ฑํ•  ํ•„์š”๋Š” ์—†์ง€๋งŒ , argType์€ ๊ฐœ๋ฐœํ•  ๋•Œ ์ž‘์„ฑ์„ ํ•ด์•ผ control ํ•˜๋ฉด์„œ props ๊ฐ’์— ๋”ฐ๋ฅธ ๋ Œ๋”๋ง ๋ณ€ํ™”๋ฅผ ํ™•์ธํ•˜๋ฉฐ ์‹œ๊ฐ์  ํ…Œ์ŠคํŠธ๋ฅผ ํ•  ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”?!

Copy link
Collaborator

@seonghunYang seonghunYang Feb 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • argtype์ด ์žˆ์–ด์•ผ conrol ์• ๋“œ์˜จ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•œ ๊ฑด๊ฐ€์š”? ๊ทธ๋Ÿฐ๊ฑฐ๋ผ๋ฉด ํ•„์š”ํ•  ๋“ฏ ํ•˜๋„ค์š”
  • ๊ด€๋ จ ๋ถ€๋ถ„์€ ์ œ๊ฐ€ ์Šคํ† ๋ฆฌ๋ถ์„ ์ข€ ๋” ์—ฐ๊ตฌํ•ด๋ณด๊ณ  ์ถ”ํ›„ ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ๊ฐ€์žฅ ์ž˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„์ง€ ์˜๊ฒฌ ๊ณต์œ ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]

  • text ํƒ€์ž…์ด ๋น ์ง„ ๊ฒƒ ๊ฐ™์€๋ฐ ์ด์œ ๊ฐ€ ์žˆ์—ˆ๋‚˜์š”?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฒ˜์Œ์—๋Š” text๋ฅผ label์ด ์•„๋‹Œ children์œผ๋กœ ๋ฐ›์•˜๊ธฐ์— ์ง€์ •ํ•ด์ฃผ๋Š” ๋ณ„ ๋‹ค๋ฅธ ์Šคํƒ€์ผ์ด ์—†์—ˆ๊ณ  ์Šคํ† ๋ฆฌ๋ถ์— ๊ตณ์ด ์ž‘์„ฑํ•ง ํ•„์š”๊ฐ€ ์—†๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ์ž‘์„ฑํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค!
ํ•˜์ง€๋งŒ text๋ฅผ label prop์œผ๋กœ ๋ฐ›๋Š” ๊ฑธ๋กœ ๋ณ€๊ฒฝํ•ด์„œ,,,, ์ถ”๊ฐ€์ ์œผ๋กœ ์ž‘์„ฑํ•ด์„œ ์ปค๋ฐ‹ํ–ˆ์Šต๋‹ˆ๋‹ค!
e76ded8


export const TextButton: StoryObj<typeof Button> = {
args: {
size: 'default',
variant: 'text',
label: 'ํšŒ์›ํƒˆํ‡ดํ•˜๊ธฐ',
},
render: (args) => <Button {...args} />,
};
37 changes: 37 additions & 0 deletions app/ui/view/atom/button/button.tsx
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>
);
});
Loading
Loading