Skip to content

Commit

Permalink
refactor and fix disabled color when no color code provided
Browse files Browse the repository at this point in the history
  • Loading branch information
manivoxel51 committed Oct 16, 2024
1 parent d0ba069 commit 7bedaa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 2 additions & 9 deletions app/packages/core/src/plugins/SchemaIO/utils/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7bedaa7

Please sign in to comment.