mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-24 09:45:35 +08:00
fix(rules): reload button style issue
This commit is contained in:
parent
29ebee3bb0
commit
04c8d2524b
@ -1,19 +1,25 @@
|
|||||||
import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
|
import { JSX, ParentComponent, Show, splitProps } from 'solid-js'
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
export const Button: ParentComponent<
|
interface ButtonBaseProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ButtonWithIconProps extends ButtonBaseProps {
|
||||||
|
icon: JSX.Element
|
||||||
|
children?: JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ButtonWithoutIconProps extends ButtonBaseProps {
|
||||||
icon?: JSX.Element
|
icon?: JSX.Element
|
||||||
}
|
children: JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Button: ParentComponent<
|
||||||
|
ButtonWithIconProps | ButtonWithoutIconProps
|
||||||
> = (props) => {
|
> = (props) => {
|
||||||
const [local, others] = splitProps(props, [
|
const [local, others] = splitProps(props, ['class', 'loading', 'icon'])
|
||||||
'class',
|
|
||||||
'loading',
|
|
||||||
'disabled',
|
|
||||||
'icon',
|
|
||||||
])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
@ -22,29 +28,12 @@ export const Button: ParentComponent<
|
|||||||
local.loading ? 'btn-disabled' : local.class,
|
local.loading ? 'btn-disabled' : local.class,
|
||||||
)}
|
)}
|
||||||
{...others}
|
{...others}
|
||||||
onClick={(e) => {
|
|
||||||
if (props.disabled) {
|
|
||||||
e.preventDefault()
|
|
||||||
e.stopPropagation()
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof props.onClick === 'function') {
|
|
||||||
props.onClick(e)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Show when={local.loading}>
|
<Show when={local.loading}>
|
||||||
<div class="loading loading-spinner" />
|
<div class="loading loading-spinner" />
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<span
|
<span class="truncate" classList={{ 'flex-1': !local.icon }}>
|
||||||
class="truncate"
|
|
||||||
classList={{
|
|
||||||
'flex-1': !local.icon,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{props.icon || props.children}
|
{props.icon || props.children}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -59,7 +59,7 @@ export default () => {
|
|||||||
return (
|
return (
|
||||||
<div class="flex h-full flex-col gap-2">
|
<div class="flex h-full flex-col gap-2">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<div class="tabs tabs-boxed gap-2">
|
<div class="tabs-boxed tabs gap-2">
|
||||||
<For each={tabs()}>
|
<For each={tabs()}>
|
||||||
{(tab) => (
|
{(tab) => (
|
||||||
<button
|
<button
|
||||||
@ -81,13 +81,14 @@ export default () => {
|
|||||||
class="btn btn-circle btn-sm"
|
class="btn btn-circle btn-sm"
|
||||||
disabled={allProviderIsUpdating()}
|
disabled={allProviderIsUpdating()}
|
||||||
onClick={(e) => onUpdateAllProviderClick(e)}
|
onClick={(e) => onUpdateAllProviderClick(e)}
|
||||||
>
|
icon={
|
||||||
<IconReload
|
<IconReload
|
||||||
class={twMerge(
|
class={twMerge(
|
||||||
allProviderIsUpdating() && 'animate-spin text-success',
|
allProviderIsUpdating() && 'animate-spin text-success',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Button>
|
}
|
||||||
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -133,14 +134,15 @@ export default () => {
|
|||||||
class="btn-circle btn-sm absolute right-2 top-2 mr-2 h-4"
|
class="btn-circle btn-sm absolute right-2 top-2 mr-2 h-4"
|
||||||
disabled={updatingMap()[ruleProvider.name]}
|
disabled={updatingMap()[ruleProvider.name]}
|
||||||
onClick={(e) => onUpdateProviderClick(e, ruleProvider.name)}
|
onClick={(e) => onUpdateProviderClick(e, ruleProvider.name)}
|
||||||
>
|
icon={
|
||||||
<IconReload
|
<IconReload
|
||||||
class={twMerge(
|
class={twMerge(
|
||||||
updatingMap()[ruleProvider.name] &&
|
updatingMap()[ruleProvider.name] &&
|
||||||
'animate-spin text-success',
|
'animate-spin text-success',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Button>
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
Loading…
Reference in New Issue
Block a user