-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathbutton.tsx
More file actions
42 lines (39 loc) · 909 Bytes
/
button.tsx
File metadata and controls
42 lines (39 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { splitProps } from 'solid-js'
import clsx from 'clsx'
import { useStyles } from '../styles/use-styles'
import type { JSX } from 'solid-js'
export type ButtonVariant =
| 'primary'
| 'secondary'
| 'danger'
| 'success'
| 'info'
| 'warning'
type ButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
variant?: ButtonVariant
outline?: boolean
ghost?: boolean
children?: any
className?: string
}
export function Button(props: ButtonProps) {
const styles = useStyles()
const [local, rest] = splitProps(props, [
'variant',
'outline',
'ghost',
'children',
'className',
])
const variant = local.variant || 'primary'
const classes = clsx(
styles().button.base,
styles().button.variant(variant, local.outline, local.ghost),
local.className,
)
return (
<button {...rest} class={classes}>
{local.children}
</button>
)
}