-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] Button 컴포넌트, 스토리북 구현
- Loading branch information
Showing
15 changed files
with
134 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { ComponentPropsWithoutRef } from 'react'; | ||
|
||
export type Props = { | ||
/** | ||
* The variant of the button. | ||
* @default 'primary' | ||
*/ | ||
variant?: 'primary' | 'gray'; | ||
/** | ||
* The height of the button. | ||
* @default 'large' | ||
*/ | ||
size?: 'medium' | 'large'; | ||
/** | ||
* Optional children for the button, typically a string. | ||
*/ | ||
children: React.ReactNode; | ||
} & ComponentPropsWithoutRef<'button'>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
// TODO : hover, disable 됐을 경우 색상 추가 | ||
export const ButtonVariants = cva( | ||
`flex items-center justify-center whitespace-nowrap select-none rounded-xl`, | ||
{ | ||
variants: { | ||
variant: { | ||
primary: 'bg-primary text-white disabled:opacity-50 disabled:cursor-not-allowed', | ||
gray: 'bg-gray-100 text-gray-950 disabled:opacity-50 disabled:cursor-not-allowed', | ||
}, | ||
size: { | ||
large: 'w-full h-14 text-xl font-medium', | ||
medium: 'w-72 h-12 text-lg font-medium', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'primary', | ||
}, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
export const Button = () => { | ||
return <></>; | ||
}; | ||
import { forwardRef } from 'react'; | ||
|
||
import { cn } from '@/lib/core'; | ||
|
||
import { Props } from './Button.types'; | ||
import { ButtonVariants } from './Button.variants'; | ||
|
||
export const Button = forwardRef<HTMLButtonElement, Props>( | ||
({ variant = 'primary', size = 'large', children, ...props }, ref) => { | ||
return ( | ||
<button type="button" className={cn(ButtonVariants({ variant, size }))} ref={ref} {...props}> | ||
{children} | ||
</button> | ||
); | ||
} | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ClassValue, clsx } from 'clsx'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
export const cn = (...inputs: ClassValue[]) => { | ||
return twMerge(clsx(inputs)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters