File tree Expand file tree Collapse file tree 4 files changed +26
-12
lines changed
src/components/common/button Expand file tree Collapse file tree 4 files changed +26
-12
lines changed Original file line number Diff line number Diff line change 1+ import clsx from 'clsx'
2+
13import { Clickable , ClickableProps } from './Clickable'
24
3- interface ButtonProps
5+ export interface ButtonProps
46 extends ClickableProps ,
57 React . ButtonHTMLAttributes < HTMLButtonElement > { }
68
79export const Button = ( {
810 onClick,
911 type = 'button' ,
1012 disabled = false ,
13+ fullWidth,
1114 ...props
1215} : ButtonProps ) : JSX . Element => (
13- < button onClick = { onClick } type = { type } disabled = { disabled } >
14- < Clickable { ...props } disabled = { disabled } />
16+ < button
17+ onClick = { onClick }
18+ type = { type }
19+ disabled = { disabled }
20+ className = { clsx ( { 'w-full' : fullWidth } ) }
21+ >
22+ < Clickable { ...props } disabled = { disabled } fullWidth = { fullWidth } />
1523 </ button >
1624)
Original file line number Diff line number Diff line change 11import clsx from 'clsx'
2- import { twMerge } from 'tailwind-merge'
32
43export interface ClickableProps {
54 label ?: string
@@ -83,18 +82,18 @@ export const Clickable = ({
8382 : ''
8483 const textColorClass = textColor ? styleByTextColor [ textColor ] : ''
8584
86- const clickableStyle = twMerge (
85+ const clickableStyle = clsx (
8786 baseStyle ,
8887 styleByVariant [ variant ] ,
8988 styleBySize [ size ] ,
9089 textColorClass ,
91- clsx ( {
90+ {
9291 [ borderColorClass ] : variant === 'outlined' ,
9392 [ backgroundColorClass ] : variant !== 'text' ,
9493 [ disabledStyle ] : disabled ,
9594 'w-full' : fullWidth ,
9695 'justify-start' : leftAlign ,
97- } ) ,
96+ } ,
9897 className
9998 )
10099
Original file line number Diff line number Diff line change 11import NextLink from 'next/link'
22
3+ import clsx from 'clsx'
4+
35import { Clickable , ClickableProps } from './Clickable'
46
5- interface LinkProps
7+ export interface LinkProps
68 extends ClickableProps ,
79 React . AnchorHTMLAttributes < HTMLAnchorElement > { }
810
911export const Link = ( {
1012 href = '#' ,
1113 disabled,
14+ onClick = ( ) => { } ,
15+ fullWidth,
1216 ...props
1317} : LinkProps ) : JSX . Element => (
1418 < NextLink
@@ -18,9 +22,12 @@ export const Link = ({
1822 onClick = { e => {
1923 if ( disabled ) {
2024 e . preventDefault ( )
25+ } else {
26+ onClick ( e )
2127 }
2228 } }
29+ className = { clsx ( { 'w-full' : fullWidth } ) }
2330 >
24- < Clickable { ...props } disabled = { disabled } />
31+ < Clickable { ...props } disabled = { disabled } fullWidth = { fullWidth } />
2532 </ NextLink >
2633)
Original file line number Diff line number Diff line change 1- import { Button } from './Button'
2- import { Link } from './Link'
1+ import { Button , type ButtonProps } from './Button'
2+ import { Link , type LinkProps } from './Link'
33
4- export { Button , Link }
4+ export { Button , ButtonProps , Link , LinkProps }
You can’t perform that action at this time.
0 commit comments