mirror of
https://github.com/ershisan99/live-bundlers.git
synced 2025-12-17 05:09:27 +00:00
initial commit
This commit is contained in:
23
src/components/button/button.tsx
Normal file
23
src/components/button/button.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentPropsWithoutRef, ElementType } from 'react'
|
||||
|
||||
import { clsx } from 'clsx'
|
||||
|
||||
import s from './button.module.scss'
|
||||
|
||||
export const buttonVariant = ['icon', 'link', 'primary', 'secondary', 'tertiary'] as const
|
||||
|
||||
export type ButtonVariant = (typeof buttonVariant)[number]
|
||||
|
||||
export type ButtonProps<T extends ElementType = 'button'> = {
|
||||
as?: T
|
||||
fullWidth?: boolean
|
||||
variant?: ButtonVariant
|
||||
} & ComponentPropsWithoutRef<T>
|
||||
|
||||
export const Button = <T extends ElementType = 'button'>(props: ButtonProps<T>) => {
|
||||
const { as: Component = 'button', className, fullWidth, variant = 'primary', ...rest } = props
|
||||
|
||||
const classNames = clsx(s.button, s[variant], fullWidth && s.fullWidth, className)
|
||||
|
||||
return <Component className={classNames} {...rest} />
|
||||
}
|
||||
Reference in New Issue
Block a user