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

fix: add css to fix the current password widget under account>password #940

Merged

Conversation

om-3004
Copy link
Contributor

@om-3004 om-3004 commented Oct 11, 2024

Fixes #907 (Fix the "current password" widget)

  • Added the CSS to fix current password widget in light/dark mode.
    Screenshot 2024-10-12 002318
    Screenshot 2024-10-12 002329

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request involve modifications to the CSS styles of the sidebar component and enhancements to the Field component. Key updates include adjustments to the dimensions and opacity of SVG elements, font sizes for text elements using CSS variables, and refined transition effects for the sidebar's expanded and collapsed states. Additionally, the Field component now includes an onInput prop for handling input events, and the visibility of the Stack component is conditionally managed based on the hidden prop.

Changes

File Path Change Summary
Client/src/Components/Sidebar/index.css Adjusted SVG dimensions and opacity, defined font sizes using CSS variables, refined transition effects for sidebar states, and added rule to hide elements in MuiTabPanel-root.
Client/src/Components/Inputs/Field/index.jsx Added onInput prop to Field component, updated sx prop for conditional display of Stack, and modified sx for TextField.

Assessment against linked issues

Objective Addressed Explanation
Align the "current password" widget (#907) The changes do not address alignment issues.

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 326feea and 5b59625.

📒 Files selected for processing (1)
  • Client/src/Components/Inputs/Field/index.jsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Client/src/Components/Inputs/Field/index.jsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gorkem-bwl
Copy link
Contributor

Looks good, thanks!

@gorkem-bwl gorkem-bwl requested a review from ajhollid October 11, 2024 19:13
Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

I understand what you are going for here and it works, however it isn't really maintainable.

I propose a different solution to this issue.

The root of the problem is that the Field component is meant to be hidden:

  <Field
    type="text"
    id="hidden-username"
    name="username"
    autoComplete="username"
    hidden={true}
    value=""
  />

however this is not behaving as expected. The problem lies with the Field component and how the hidden prop is applied:

sx={
      type === "url"
        ? {
            "& .MuiInputBase-root": { padding: 0 },
            "& .MuiStack-root": {
              borderTopLeftRadius: theme.shape.borderRadius,
              borderBottomLeftRadius: theme.shape.borderRadius,
            },
          }
        : {
            display: hidden ? "none" : "",
          }
    }

The hidden prop is applied to the TextField subcomponent of Field, while in fact it should be applied to the root Stack subcomponent of Field.

I suggest reverting TextField's SX prop to

  sx={
    type === "url"
      ? {
          "& .MuiInputBase-root": { padding: 0 },
          "& .MuiStack-root": {
            borderTopLeftRadius: theme.shape.borderRadius,
            borderBottomLeftRadius: theme.shape.borderRadius,
          },
        }
      : {
        }
  } 

and adding

display: hidden? "none" : ""

to the root Stack subcomponent.

That will properly remove the hidden Field from the DOM, rather than just removing the nested TextField


.MuiTabPanel-root.css-8i83hh-MuiTabPanel-root .MuiStack-root.field.field-text.css-qm2p9n-MuiStack-root, .MuiTabPanel-root.css-2aha5r-MuiTabPanel-root .MuiStack-root.field.field-text.css-78xnin-MuiStack-root {
display: none;
}
Copy link
Collaborator

@ajhollid ajhollid Oct 12, 2024

Choose a reason for hiding this comment

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

This is in the sidebar CSS file but it is targeting a field in the password panel component. This is unmaintainable as future devs will not know this CSS is in this file, nor will they know what it is for if they come across this CSS in the future.

The specificity of this CSS selector is also not really maintainable as it is not reasonably possible to tell what that selector is for. I assume it was extracted from dev tools inspector? It works, but future devs are not going to know what it is for or what it means down the road 🤔

@om-3004 om-3004 force-pushed the bug/fix-current-password-widget branch from 6935642 to 326feea Compare October 12, 2024 08:17
@om-3004 om-3004 force-pushed the bug/fix-current-password-widget branch from 326feea to 5b59625 Compare October 12, 2024 08:23
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
Client/src/Components/Inputs/Field/index.jsx (2)

Line range hint 40-40: Yo, this onInput addition is fire! 🔥

Aight, listen up! The addition of the onInput prop is straight-up dope. It's like adding extra sauce to mom's spaghetti - makes it even better, you feel me? This change gives the component more flex than Eminem's lyrics.

But yo, I got a small nitpick that'll make this code spit hot fire:

Let's update the PropTypes to include onInput. It's like adding that last beat to make the track complete, you know what I'm sayin'? Here's how we do it:

Field.propTypes = {
  // ... other propTypes
  onChange: PropTypes.func,
+ onInput: PropTypes.func,
  // ... rest of propTypes
};

This'll make our code as tight as Eminem's rhymes. We good?

Also applies to: 41-41, 42-42, 43-43, 44-44, 45-45, 46-46, 47-47, 48-48, 49-49, 50-50, 51-51, 52-52, 53-53, 54-54, 55-55, 56-56, 57-57, 58-58, 59-59, 60-60, 61-61, 62-62, 63-63, 64-64, 65-65, 66-66, 67-67, 68-68, 69-69, 70-70, 71-71, 72-72, 73-73, 74-74, 75-75, 76-76, 77-77, 78-78, 79-79, 80-80, 81-81, 82-82, 83-83, 84-84, 85-85, 86-86, 87-87, 88-88, 89-89, 90-90, 91-91, 92-92, 93-93, 94-94, 95-95, 96-96, 97-97, 98-98, 99-99, 100-100, 101-101, 102-102, 103-103, 104-104, 105-105, 106-106, 107-107, 108-108, 109-109, 110-110, 111-111, 112-112, 113-113, 114-114, 115-115, 116-116, 117-117, 118-118, 119-119, 120-120, 121-121, 122-122, 123-123, 124-124, 125-125, 126-126, 127-127, 128-128, 129-129, 130-130, 131-131, 132-132, 133-133, 134-134, 135-135, 136-136, 137-137, 138-138, 139-139, 140-140, 141-141, 142-142, 143-143, 144-144, 145-145, 146-146, 147-147


77-77: Yo, this visibility control is slicker than Slim Shady! 👀

Listen up, homie! This change to the Stack component's sx prop is smoother than Eminem's flow. You're handling that visibility like a pro, making the component disappear faster than Marshall Mathers' alter ego.

But check it, I got a small suggestion to make this code as tight as Em's rhymes:

Let's keep our style consistent, like keeping the beat in a track. Instead of using an empty string for the display property when hidden is false, let's be explicit:

sx={{
-  display: hidden ? "none" : "",
+  display: hidden ? "none" : "flex",
}}

This way, we're always setting a value, just like how every bar in a rap needs to hit hard. It's a small change, but it'll make our code as clean as Eminem's delivery. What you think?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d9e1016 and 326feea.

📒 Files selected for processing (1)
  • Client/src/Components/Inputs/Field/index.jsx (2 hunks)
🧰 Additional context used

@om-3004
Copy link
Contributor Author

om-3004 commented Oct 12, 2024

@ajhollid Yes understood, you are right. I've committed that change so please review it.

@om-3004 om-3004 requested a review from ajhollid October 12, 2024 11:44
Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

Nice, short and sweet! This resovles the issue, thank you for your contribution

@@ -74,6 +74,7 @@ const Field = forwardRef(
"&:has(.input-error) .MuiOutlinedInput-root fieldset": {
borderColor: theme.palette.error.text,
},
display: hidden ? "none" : "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome, thanks for taking care of this 👍

@ajhollid ajhollid merged commit 76ad9a3 into bluewave-labs:develop Oct 12, 2024
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix the "current password" widget
3 participants