Skip to content

Commit

Permalink
Merge pull request #4934 from voxel51/bug/disabled-button
Browse files Browse the repository at this point in the history
Fixes disabled color on buttonView when no colorCode is passed & refactor
  • Loading branch information
manivoxel51 authored Oct 16, 2024
2 parents d0ba069 + 7bedaa7 commit 16ea2a5
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 16ea2a5

Please sign in to comment.