Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot fix/theme disabled #1161

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Client/src/Components/Inputs/Checkbox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Checkbox = ({
onChange,
isDisabled,
}) => {
/* TODO move sizes to theme */
const sizes = { small: "14px", medium: "16px", large: "18px" };
Comment on lines +40 to 41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Yo! These sizes should drop into the theme system, dawg!

Moving the size definitions to the theme would make the component more maintainable and consistent with the design system. This would allow for:

  • Centralized size management
  • Better consistency across components
  • Easier theme customization

Consider moving these sizes to the theme like this:

- /* TODO move sizes to theme */
- const sizes = { small: "14px", medium: "16px", large: "18px" };
+ const sizes = theme.components.Checkbox.sizes;

Committable suggestion skipped: line range outside the PR's diff.

const theme = useTheme();

Expand Down Expand Up @@ -78,6 +79,10 @@ const Checkbox = ({
fontSize: 13,
color: theme.palette.text.tertiary,
},
".MuiFormControlLabel-label.Mui-disabled": {
color: theme.palette.text.tertiary,
opacity: 0.25,
},
Comment on lines +82 to +85
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Yo, the opacity check spits straight facts!

Looking at the codebase, the 0.25 opacity for disabled checkbox labels is significantly lower than other disabled states:

  • Most UI elements use 0.6-0.8 opacity for secondary content
  • Other disabled states use 0.5 (like in CheckEmail.jsx)
  • The closest low opacity is 0.3 in StatusBox.jsx, but that's for background elements

Let's keep it real - 0.25 opacity is too low for text elements. This could make the form hard to use for folks with visual impairments.

Consider:

  1. Bumping up the opacity to 0.5 to match other disabled states
  2. Using MUI's built-in disabled text styles instead of custom opacity
🔗 Analysis chain

Mom's spaghetti moment: Let's check that accessibility!

The opacity value of 0.25 for disabled labels might make the text too faint. We should verify that this meets WCAG contrast requirements.

Let's check if this opacity value is consistent with other disabled states:

Consider:

  1. Increasing the opacity value (e.g., 0.5)
  2. Using the theme's disabled text color instead of manually setting opacity
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other opacity values used for disabled states
rg -g '*.{jsx,js,css}' 'opacity:'

Length of output: 4111

}}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions Client/src/Components/Inputs/Field/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Field = forwardRef(
borderColor: theme.palette.border.dark,
},
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
borderColor: theme.palette.error.contrastText,
borderColor: theme.palette.error.main,
},
display: hidden ? "none" : "",
}}
Expand All @@ -83,7 +83,7 @@ const Field = forwardRef(
<Typography
component="span"
ml={theme.spacing(1)}
color={theme.palette.error.contrastText}
color={theme.palette.error.main}
>
*
</Typography>
Expand Down Expand Up @@ -189,7 +189,7 @@ const Field = forwardRef(
<Typography
component="span"
className="input-error"
color={theme.palette.error.contrastText}
color={theme.palette.error.main}
mt={theme.spacing(2)}
sx={{
opacity: 0.8,
Expand Down