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

Refactor styles: move SubTags.module.css styles to app.module.css #2538

Open
wants to merge 7 commits into
base: develop-postgres
Choose a base branch
from

Conversation

amitb0ra
Copy link

@amitb0ra amitb0ra commented Dec 1, 2024

What kind of change does this PR introduce?

refactoring

Issue Number:

Fixes #2526

Did you add tests for your changes?

No

Snapshots/Videos:

image

There are some issues like: "Cannot find module '@testing-library/dom' from 'node_modules/@testing-library/react/dist/pure.js'" but that is not relevant here.

If relevant, did you update the documentation?

No

Summary

The goal is to convert the CSS file in this subdirectory and all the components related to this screen to use this new design pattern.

Does this PR introduce a breaking change?

No

Other information

No

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error message display and styling for better visibility.
  • New Features

    • Introduced new styles for improved button and input layouts.
    • Added responsive design adjustments for better usability on mobile devices.
  • Style

    • Updated various CSS classes for improved visual consistency and interactivity.
    • Enhanced scrollbar styles for scrollable areas.
    • Modified button and layout properties for better control and spacing.
    • Improved hover effects and layout stability for links and breadcrumbs.

Copy link

coderabbitai bot commented Dec 1, 2024

Walkthrough

The changes involve the deletion of the SubTags.module.css file, which contained various CSS styles for a user interface component related to sub-tags. These styles have been integrated into the global CSS file src/style/app.module.css, which has been updated with new styles and adjustments to improve layout, responsiveness, and visual consistency across components. The modifications include new media queries, error message styles, and adjustments to existing classes.

Changes

File Change Summary
src/screens/SubTags/SubTags.module.css Deleted the file, which included styles for buttons, input fields, error messages, and layout properties.
src/style/app.module.css Updated with new styles, including .btnsContainer, .errorMessage, and media queries for responsiveness.

Assessment against linked issues

Objective Addressed Explanation
Merge CSS from src/screens/SubTags into a global CSS file (2526)
Delete the CSS file in src/screens/SubTags after merging (2526)
Reference the global CSS file in remaining relevant files (2526) No confirmation that remaining files reference the global CSS file.

Possibly related issues

🐇 In the garden, we hop and play,
With styles so bright, they light our way.
CSS merged, a global delight,
In Talawa's realm, everything feels right!
Let's cheer for changes, both bold and new,
A better UI for me and you! 🌼


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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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.

Copy link

github-actions bot commented Dec 1, 2024

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

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: 1

🧹 Outside diff range and nitpick comments (4)
src/style/app.module.css (4)

Line range hint 75-89: Consolidate duplicate .btnsContainer styles

There are duplicate style definitions for .btnsContainer and its child elements. This can lead to maintenance issues and potential style conflicts.

Consolidate the styles into a single definition:

.btnsContainer {
  display: flex;
  margin: 2.5rem 0;
  align-items: center;
  gap: 10px;
}

.btnsContainer .btnsBlock {
  display: flex;
  width: max-content;
}

.btnsContainer .btnsBlock button {
  margin-left: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btnsContainer .input {
  flex: 1;
  position: relative;
  max-width: 60%;
  justify-content: space-between;
}

.btnsContainer input {
  outline: 1px solid var(--bs-gray-400);
}

.btnsContainer .input button {
  width: 52px;
}

- /* Remove duplicate definitions at lines 616-641 */

Also applies to: 616-641


691-707: Enhance error message accessibility

While the error styles are well-structured, they could benefit from improved accessibility for screen readers.

Add ARIA attributes and role to improve accessibility:

.errorContainer {
  min-height: 100vh;
+ role: alert;
+ aria-live: polite;
}

.errorMessage {
  margin-top: 25%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
+ aria-atomic: true;
}

.errorIcon {
  transform: scale(1.5);
  color: var(--bs-danger);
  margin-bottom: 1rem;
+ aria-hidden: true;
}

709-717: Approve color accessibility improvements

The use of Bootstrap color variables improves accessibility for color-blind users. The contrast between the white text and primary background color meets WCAG guidelines.

Consider adding a hover state for table rows to improve interactivity:

.rowBackground {
  background-color: var(--bs-white);
  max-height: 120px;
+ transition: background-color 0.2s ease;
}

+ .rowBackground:hover {
+   background-color: var(--bs-gray-100);
+ }

767-773: Enhance scrolling behavior

The scrollbar styling is good, but the scrolling experience could be improved.

Add smooth scrolling behavior:

.subTagsScrollableDiv {
  scrollbar-width: auto;
  scrollbar-color: var(--bs-gray-400) var(--bs-white);
  max-height: calc(100vh - 18rem);
  overflow: auto;
+ scroll-behavior: smooth;
+ -webkit-overflow-scrolling: touch;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c2630ae and 85a5e3d.

📒 Files selected for processing (2)
  • src/screens/SubTags/SubTags.module.css (0 hunks)
  • src/style/app.module.css (2 hunks)
💤 Files with no reviewable changes (1)
  • src/screens/SubTags/SubTags.module.css
🔇 Additional comments (1)
src/style/app.module.css (1)

643-689: 🛠️ Refactor suggestion

Consolidate duplicate media queries

Similar to the button container styles, there are duplicate media query definitions that should be consolidated.

Consolidate the media queries into a single location in the file:

@media (max-width: 1020px) {
  .btnsContainer {
    flex-direction: column;
    margin: 1.5rem 0;
  }

  .btnsContainer .btnsBlock {
    margin: 1.5rem 0 0 0;
    justify-content: space-between;
  }

  .btnsContainer .btnsBlock button {
    margin: 0;
  }

  .btnsContainer .btnsBlock div button {
    margin-right: 1.5rem;
  }
}

@media (max-width: 520px) {
  .btnsContainer {
    margin-bottom: 0;
  }

  .btnsContainer .btnsBlock {
    display: block;
    margin-top: 1rem;
    margin-right: 0;
  }

  .btnsContainer .btnsBlock div {
    flex: 1;
  }

  .btnsContainer .btnsBlock div[title='Sort organizations'] {
    margin-right: 0.5rem;
  }

  .btnsContainer .btnsBlock button {
    margin-bottom: 1rem;
    margin-right: 0;
    width: 100%;
  }
}

- /* Remove duplicate media queries from other locations */

Likely invalid or redundant comment.

src/style/app.module.css Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 1, 2024
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: 2

🧹 Outside diff range and nitpick comments (3)
src/style/app.module.css (3)

75-75: Consider accessibility and responsive design improvements.

While the layout structure is improved, there are a few concerns:

  1. Setting outline directly might affect keyboard navigation accessibility.
  2. The fixed max-width of 60% on input might cause issues on certain viewports.

Consider these improvements:

.btnsContainer .input {
  flex: 1;
  position: relative;
-  max-width: 60%;
+  max-width: min(60%, 600px);
  justify-content: space-between;
}

.btnsContainer input {
-  outline: 1px solid var(--bs-gray-400);
+  border: 1px solid var(--bs-gray-400);
+  &:focus-visible {
+    outline: 2px solid var(--bs-primary);
+    outline-offset: 2px;
+  }
}

Also applies to: 618-643


645-691: Improve maintainability of responsive styles.

The media queries handle responsive behavior well, but there are opportunities for improvement:

  1. The breakpoint values should be defined as CSS custom properties for better maintainability.
  2. There's a duplicate media query for max-width: 520px (also appears earlier in the file).

Consider these improvements:

+:root {
+  --breakpoint-tablet: 1020px;
+  --breakpoint-mobile: 520px;
+}

-@media (max-width: 1020px) {
+@media (max-width: var(--breakpoint-tablet)) {
  /* ... */
}

-@media (max-width: 520px) {
+@media (max-width: var(--breakpoint-mobile)) {
  /* ... */
}

Also, consider consolidating the duplicate media queries to avoid maintenance issues.


761-767: Add cross-browser compatibility for scrollbar styles.

The scrollbar styles need webkit prefixes for better browser support.

Add webkit prefixes:

.subTagsScrollableDiv {
  scrollbar-width: auto;
  scrollbar-color: var(--bs-gray-400) var(--bs-white);
+  &::-webkit-scrollbar {
+    width: auto;
+  }
+  &::-webkit-scrollbar-track {
+    background: var(--bs-white);
+  }
+  &::-webkit-scrollbar-thumb {
+    background-color: var(--bs-gray-400);
+  }
  max-height: calc(100vh - 18rem);
  overflow: auto;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 85a5e3d and 4f7b820.

📒 Files selected for processing (1)
  • src/style/app.module.css (3 hunks)
🔇 Additional comments (1)
src/style/app.module.css (1)

721-759: LGTM! Excellent implementation of layout shift prevention.

The navigation styles demonstrate best practices:

  1. Layout shift prevention using pseudo-elements.
  2. Proper focus states for keyboard navigation.
  3. Consistent hover and focus styles.

src/style/app.module.css Outdated Show resolved Hide resolved
src/style/app.module.css Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 1, 2024
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 (1)
src/style/app.module.css (1)

Line range hint 75-648: Remove duplicate btnsContainer styles

The styles for .btnsContainer and its child elements are duplicated in the file. This can lead to maintenance issues and inconsistencies.

Consolidate the styles into a single definition:

- /* First definition at line 75 */
- .btnsContainer {
-   display: flex;
-   margin: 2.5rem 0;
-   align-items: center;
-   gap: 10px;
- }
- /* ... other duplicate styles ... */

/* Keep the complete definition at line 622 */
.btnsContainer {
  display: flex;
  margin: 2.5rem 0;
  align-items: center;
  gap: 10px;
  /* ... rest of the styles ... */
}

Also applies to: 622-696

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4f7b820 and eccf0f7.

📒 Files selected for processing (1)
  • src/style/app.module.css (4 hunks)
🔇 Additional comments (3)
src/style/app.module.css (3)

344-348: Add ARIA attributes for error messages

While adding a non-color indication for errors is good, the error messages should be properly announced to screen readers.

As mentioned in a previous review, add ARIA attributes to improve accessibility:

.errorContainer {
  min-height: 100vh;
+ role: "alert";
+ aria-live: "polite";
}

.errorIcon {
  transform: scale(1.5);
  color: var(--bs-danger);
  margin-bottom: 1rem;
  &::before {
    content: '⚠️';
    margin-right: 0.5rem;
  }
}

706-715: LGTM: Table styles improvements

The changes address previous review comments:

  1. Table header now uses --bs-primary-text-emphasis for better contrast
  2. Added overflow handling for row content

717-755: LGTM: Navigation accessibility improvements

Excellent improvements for accessibility and user experience:

  1. Focus states match hover states for keyboard navigation
  2. Layout shift prevention using pseudo-elements

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

You haven't updated the code files that will use the updated app.module.css

@amitb0ra
Copy link
Author

amitb0ra commented Dec 2, 2024

You haven't updated the code files that will use the updated app.module.css

It was already there in src/screens/SubTags/SubTags.tsx

import styles from '../../style/app.module.css';

@palisadoes
Copy link
Contributor

Thanks. Please fix the failing tests

@amitb0ra
Copy link
Author

amitb0ra commented Dec 3, 2024

Thanks. Please fix the failing tests

the failing tests are due to some modules missing, which is out of scope of this PR. Do you want me to include it?

There are some issues like: "Cannot find module '@testing-library/dom' from 'node_modules/@testing-library/react/dist/pure.js'" so to fix failiing tests i have to install this.

@palisadoes
Copy link
Contributor

Thanks. Please fix the failing tests

the failing tests are due to some modules missing, which is out of scope of this PR. Do you want me to include it?

There are some issues like: "Cannot find module '@testing-library/dom' from 'node_modules/@testing-library/react/dist/pure.js'" so to fix failiing tests i have to install this.

Yes. @AVtheking will provide further guidance

@amitb0ra
Copy link
Author

amitb0ra commented Dec 6, 2024

any updates? @AVtheking @palisadoes

@palisadoes
Copy link
Contributor

Please fix the tests that need to be updated because of your changes

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)
src/style/app.module.css (2)

679-696: Consider using a more flexible width constraint

The fixed max-width of 60% might be too restrictive on certain viewport sizes. Consider using clamp() or min() for better flexibility.

.btnsContainer .input {
  flex: 1;
  position: relative;
-  max-width: 60%;
+  max-width: clamp(300px, 60%, 800px);
  justify-content: space-between;
}

813-819: Consider adding smooth scrolling

For better user experience, consider adding smooth scrolling behavior.

.subTagsScrollableDiv {
  scrollbar-width: auto;
  scrollbar-color: var(--bs-gray-400) var(--bs-white);
  max-height: calc(100vh - 18rem);
  overflow: auto;
+  scroll-behavior: smooth;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eccf0f7 and 1fa30fe.

📒 Files selected for processing (1)
  • src/style/app.module.css (4 hunks)
🔇 Additional comments (4)
src/style/app.module.css (4)

706-752: LGTM! Well-structured responsive design

The media queries effectively handle different viewport sizes with appropriate breakpoints and layout adjustments.


762-771: LGTM! Improved table accessibility and usability

The changes address both color contrast and content overflow issues effectively.


773-811: LGTM! Excellent layout shift prevention

The pseudo-element technique effectively prevents layout shifts during hover/focus states while maintaining accessibility.


349-353: ⚠️ Potential issue

Complete the accessibility improvements

While the non-color indication is good, the error message still needs ARIA attributes for better screen reader support.

.errorContainer {
  min-height: 100vh;
+  role: "alert";
+  aria-live: "polite";
}

.errorMessage {
  margin-top: 25%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
+  aria-atomic: "true";
}

Also applies to: 754-760

@amitb0ra
Copy link
Author

amitb0ra commented Dec 7, 2024

Please fix the tests that need to be updated because of your changes

which failing tests?

@VanshikaSabharwal
Copy link

VanshikaSabharwal commented Dec 9, 2024

@amitb0ra amitb0ra force-pushed the refactor/css-global-subtags-2526 branch from 1fa30fe to f674e32 Compare December 9, 2024 10:37
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: 3

🧹 Outside diff range and nitpick comments (1)
src/style/app.module.css (1)

767-771: Consider dynamic max-height for table rows.

The fixed max-height of 120px might truncate content unexpectedly. Consider using a relative unit or min/max constraints.

Apply this diff to improve the row height handling:

.rowBackground {
  background-color: var(--bs-white);
-  max-height: 120px;
+  max-height: min(120px, 8rem);
  overflow-y: auto;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1fa30fe and f674e32.

📒 Files selected for processing (2)
  • src/screens/SubTags/SubTags.module.css (0 hunks)
  • src/style/app.module.css (4 hunks)
💤 Files with no reviewable changes (1)
  • src/screens/SubTags/SubTags.module.css
🔇 Additional comments (2)
src/style/app.module.css (2)

773-811: Great implementation of layout shift prevention and accessibility!

The use of pseudo-elements to prevent layout shifts during hover/focus states is excellent. The focus states matching hover states ensures good keyboard navigation accessibility.


813-819: LGTM! Well-implemented scrollable container.

The scrollbar customization and use of CSS custom properties is clean and maintainable.

src/style/app.module.css Show resolved Hide resolved
src/style/app.module.css Show resolved Hide resolved
src/style/app.module.css Show resolved Hide resolved
@Cioppolo14
Copy link

@amitb0ra Please fix the failed tests.

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.

4 participants