From 04c8d2524b6d6b0fb1b2f36b98a0ffe2a20fbf8c Mon Sep 17 00:00:00 2001 From: kunish Date: Sat, 23 Sep 2023 14:30:16 +0800 Subject: [PATCH] fix(rules): reload button style issue --- src/components/Button.tsx | 47 +++++++++++++++------------------------ src/pages/Rules.tsx | 34 +++++++++++++++------------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 58732c7..7053f18 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,19 +1,25 @@ import { JSX, ParentComponent, Show, splitProps } from 'solid-js' import { twMerge } from 'tailwind-merge' +interface ButtonBaseProps extends JSX.ButtonHTMLAttributes { + 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< - JSX.ButtonHTMLAttributes & { - loading?: boolean - disabled?: boolean - icon?: JSX.Element - } + ButtonWithIconProps | ButtonWithoutIconProps > = (props) => { - const [local, others] = splitProps(props, [ - 'class', - 'loading', - 'disabled', - 'icon', - ]) + const [local, others] = splitProps(props, ['class', 'loading', 'icon']) return ( diff --git a/src/pages/Rules.tsx b/src/pages/Rules.tsx index 8be1c85..ffc64a7 100644 --- a/src/pages/Rules.tsx +++ b/src/pages/Rules.tsx @@ -59,7 +59,7 @@ export default () => { return (
-
+
{(tab) => ( + icon={ + + } + />
@@ -133,14 +134,15 @@ export default () => { class="btn-circle btn-sm absolute right-2 top-2 mr-2 h-4" disabled={updatingMap()[ruleProvider.name]} onClick={(e) => onUpdateProviderClick(e, ruleProvider.name)} - > - - + icon={ + + } + />
)}