2
0

💄 (buttons) Improve multiple choice form UI

This commit is contained in:
Baptiste Arnaud
2023-04-26 15:59:22 +02:00
parent f51d619c79
commit 124f350aa2
33 changed files with 454 additions and 262 deletions

View File

@ -0,0 +1,33 @@
import { children, JSX, Show, splitProps } from 'solid-js'
import { Spinner } from './Spinner'
type Props = {
variant?: 'primary' | 'secondary'
children: JSX.Element
isDisabled?: boolean
isLoading?: boolean
} & JSX.ButtonHTMLAttributes<HTMLButtonElement>
export const Button = (props: Props) => {
const childrenReturn = children(() => props.children)
const [local, buttonProps] = splitProps(props, ['disabled', 'class'])
return (
<button
{...buttonProps}
disabled={props.isDisabled || props.isLoading}
class={
'py-2 px-4 font-semibold focus:outline-none filter hover:brightness-90 active:brightness-75 disabled:opacity-50 disabled:cursor-not-allowed disabled:brightness-100' +
(props.variant === 'secondary'
? ' secondary-button'
: ' typebot-button') +
' ' +
local.class
}
>
<Show when={!props.isLoading} fallback={<Spinner />}>
{childrenReturn()}
</Show>
</button>
)
}