Open History to see the last commit
1import { createMemo } from 'solid-js'
2import clsx from 'clsx'
3import { createStyles } from '../styles/use-styles'
4β
5// types
6import type { JSX } from 'solid-js'
7β
8export type ButtonVariant =
9 | 'primary'
10 | 'secondary'
11 | 'danger'
12 | 'success'
13 | 'info'
14 | 'warning'
15type ButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
16 variant?: ButtonVariant
17 outline?: boolean
18 ghost?: boolean
19 children?: any
20 className?: string
21}
22export function Button(props: ButtonProps) {
23 const styles = createStyles()
24β
25 const classes = createMemo(() => {
26 const variant = props.variant || 'primary'
27 return clsx(
28 styles().button.base,
29 styles().button.variant(variant, props.outline, props.ghost),
30 props.className,
31 )
32 })
33β
34 return (
35 <button {...props} class={classes()}>
36 {props.children}
37 </button>
38 )
39}