From 762aed50b748adfa0dcaa1b9aa83ef595a77c407 Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Wed, 18 Jun 2025 21:08:56 -0400 Subject: [PATCH] Updated button styling on config header (#673) * fix: updated button in config * Update src/pages/Config/index.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/components/PageLayout.tsx | 3 +-- src/pages/Config/index.tsx | 48 +++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/components/PageLayout.tsx b/src/components/PageLayout.tsx index 534ab71a..7a8c1eee 100644 --- a/src/components/PageLayout.tsx +++ b/src/components/PageLayout.tsx @@ -80,8 +80,7 @@ export const PageLayout = ({ disabled={action.disabled || action.isLoading} className={cn( "flex items-center space-x-2 py-2 px-3 rounded-md", - "text-foreground transition-colors hover:text-accent", - "hover:bg-slate-200 disabled:hover:bg-white", + "text-foreground transition-colors duration-200", "disabled:opacity-50 disabled:cursor-not-allowed", action.className, )} diff --git a/src/pages/Config/index.tsx b/src/pages/Config/index.tsx index 98725b0f..c1171739 100644 --- a/src/pages/Config/index.tsx +++ b/src/pages/Config/index.tsx @@ -144,19 +144,23 @@ const ConfigPage = () => { [activeConfigSection, workingConfig, workingModuleConfig], ); - const buttonOpacity = useMemo( - () => (formMethods?.formState.isDirty && - Object.keys(formMethods?.formState.dirtyFields ?? {}).length > 0 || - workingConfig.length > 0 || workingModuleConfig.length > 0 - ? "opacity-100" - : "opacity-0"), - [ - formMethods?.formState.isDirty, - formMethods?.formState.dirtyFields, - workingConfig, - workingModuleConfig, - ], - ); + const buttonOpacity = useMemo(() => { + const isFormDirty = formMethods?.formState.isDirty ?? false; + const hasDirtyFields = + (Object.keys(formMethods?.formState.dirtyFields ?? {}).length ?? 0) > 0; + const hasWorkingConfig = workingConfig.length > 0; + const hasWorkingModuleConfig = workingModuleConfig.length > 0; + + const shouldShowButton = (isFormDirty && hasDirtyFields) || + hasWorkingConfig || hasWorkingModuleConfig; + + return shouldShowButton ? "opacity-100" : "opacity-0"; + }, [ + formMethods?.formState.isDirty, + formMethods?.formState.dirtyFields, + workingConfig, + workingModuleConfig, + ]); const isValid = useMemo(() => { return Object.keys(formMethods?.formState.errors ?? {}).length === 0; @@ -168,7 +172,8 @@ const ConfigPage = () => { label: t("common:formValidation.unsavedChanges"), onClick: () => {}, className: cn([ - "bg-blue-500 hover:bg-blue-500 text-white hover:text-white", + "bg-blue-500 text-slate-900 hover:bg-initial", + "transition-colors duration-200", buttonOpacity, "transition-opacity", ]), @@ -178,7 +183,11 @@ const ConfigPage = () => { icon: RefreshCwIcon, label: t("common:button.reset"), onClick: handleReset, - className: cn([buttonOpacity, "transition-opacity"]), + className: cn([ + buttonOpacity, + "transition-opacity hover:bg-slate-200 disabled:hover:bg-white", + "hover:dark:bg-slate-300 hover:dark:text-black cursor-pointer", + ]), }, { key: "save", @@ -187,7 +196,14 @@ const ConfigPage = () => { disabled: isSaving || !isValid || (workingConfig.length === 0 && workingModuleConfig.length === 0), - iconClasses: !isValid ? "text-red-400 cursor-not-allowed" : "", + iconClasses: !isValid + ? "text-red-400 cursor-not-allowed" + : "cursor-pointer", + className: cn([ + "transition-opacity hover:bg-slate-200 disabled:hover:bg-white", + "hover:dark:bg-slate-300 hover:dark:text-black", + disabled ? "cursor-not-allowed" : "cursor-pointer", + ]), onClick: handleSave, label: t("common:button.save"), },