2023-01-20 04:40:55 +00:00
|
|
|
import type { JSX } from 'solid-js'
|
|
|
|
import { clsx } from 'clsx'
|
|
|
|
import styles from './Button.module.scss'
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
value: string | JSX.Element
|
|
|
|
size?: 'S' | 'M' | 'L'
|
2023-05-04 04:43:52 +00:00
|
|
|
variant?: 'primary' | 'secondary' | 'bordered' | 'inline' | 'outline'
|
2023-01-20 04:40:55 +00:00
|
|
|
type?: 'submit' | 'button'
|
|
|
|
loading?: boolean
|
|
|
|
disabled?: boolean
|
|
|
|
onClick?: () => void
|
2023-04-26 02:37:29 +00:00
|
|
|
class?: string
|
2023-01-20 04:40:55 +00:00
|
|
|
}
|
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
export const Button = (props: Props) => {
|
2023-01-20 04:40:55 +00:00
|
|
|
return (
|
|
|
|
<button
|
|
|
|
onClick={props.onClick}
|
|
|
|
type={props.type ?? 'button'}
|
|
|
|
disabled={props.loading || props.disabled}
|
2023-04-26 02:37:29 +00:00
|
|
|
class={clsx(
|
|
|
|
styles.button,
|
|
|
|
styles[props.size ?? 'M'],
|
|
|
|
styles[props.variant ?? 'primary'],
|
|
|
|
{
|
|
|
|
[styles.loading]: props.loading
|
|
|
|
},
|
|
|
|
props.class
|
|
|
|
)}
|
2023-01-20 04:40:55 +00:00
|
|
|
>
|
|
|
|
{props.value}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|