From 7bedaa7751044689b47faeef4a745f02016ba097 Mon Sep 17 00:00:00 2001 From: manivoxel51 Date: Wed, 16 Oct 2024 10:08:00 -0700 Subject: [PATCH] refactor and fix disabled color when no color code provided --- .../src/plugins/SchemaIO/components/ButtonView.tsx | 9 ++------- app/packages/core/src/plugins/SchemaIO/utils/style.ts | 11 ++--------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx b/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx index 3b47b82134..5778fa96ac 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/ButtonView.tsx @@ -107,17 +107,12 @@ function getButtonProps(props: ViewPropsType): ButtonProps { } if (disabled) { - const [bgColor, textColor] = getDisabledColors(color); + const [bgColor, textColor] = getDisabledColors(); baseProps.sx["&.Mui-disabled"] = { backgroundColor: variant === "outlined" ? "inherit" : bgColor, color: textColor, }; - if (variant === "square") { - baseProps.sx["&.Mui-disabled"].backgroundColor = (theme) => - theme.palette.background.field; - } - - if (variant === "outlined") { + if (["square", "outlined"].includes(variant)) { baseProps.sx["&.Mui-disabled"].backgroundColor = (theme) => theme.palette.background.field; } diff --git a/app/packages/core/src/plugins/SchemaIO/utils/style.ts b/app/packages/core/src/plugins/SchemaIO/utils/style.ts index 70195d8f75..cac0727655 100644 --- a/app/packages/core/src/plugins/SchemaIO/utils/style.ts +++ b/app/packages/core/src/plugins/SchemaIO/utils/style.ts @@ -8,15 +8,8 @@ export function getColorByCode(code: ColorType) { } } -export function getDisabledColors(code: ColorType) { - if (code) { - if (["primary", "secondary", ...fiftyOneColorNames].includes(code)) - return [ - "var(--fo-palette-primary-main)", - "var(--fo-palette-text-primary)", - ]; - return [code, "var(--fo-palette-text-primary)"]; - } +export function getDisabledColors() { + return ["var(--fo-palette-primary-main)", "var(--fo-palette-text-primary)"]; } export function getFieldSx(options: FieldsetOptionsType) {