mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-27 22:54:03 +08:00
eca9a160cc
* feat: add modal component * feat: add modal component * fix: proxies page arrow button problem * fix: button radius problem * feat: add modal component * feat: add modal component --------- Signed-off-by: Alpha <61853980+AlphaGHX@users.noreply.github.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
interface ButtonBaseProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
loading?: boolean
|
|
disabled?: boolean
|
|
}
|
|
|
|
interface ButtonWithIconProps extends ButtonBaseProps {
|
|
icon: JSX.Element
|
|
children?: JSX.Element
|
|
}
|
|
|
|
interface ButtonWithoutIconProps extends ButtonBaseProps {
|
|
icon?: JSX.Element
|
|
children: JSX.Element
|
|
}
|
|
|
|
export const Button: ParentComponent<
|
|
ButtonWithIconProps | ButtonWithoutIconProps
|
|
> = (props) => {
|
|
const [local, others] = splitProps(props, ['class', 'loading', 'icon'])
|
|
|
|
return (
|
|
<button
|
|
class={twMerge(
|
|
'btn flex items-center',
|
|
local.loading ? 'btn-disabled' : local.class,
|
|
)}
|
|
{...others}
|
|
>
|
|
<Show when={local.loading}>
|
|
<div class="loading loading-spinner" />
|
|
</Show>
|
|
|
|
<span
|
|
class="truncate rounded-none"
|
|
classList={{
|
|
'flex-1': !local.icon,
|
|
}}
|
|
>
|
|
{props.icon || props.children}
|
|
</span>
|
|
</button>
|
|
)
|
|
}
|