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 CSS for LeftDrawerOrg #3131

Merged

Conversation

dhruuvarora
Copy link

@dhruuvarora dhruuvarora commented Jan 3, 2025

Pull Request Details
Type of Change:
Refactoring

Issue Reference:
Fixes #2900

Description:
This PR improves the UI/UX of the Talawa-Admin by:

Making the application more accessible to color-blind users.
Streamlining all CSS into a single global file: src/style/app.module.css.
Summary of Changes:
Removed all embedded CSS from the relevant file.
Merged embedded CSS into the global app.module.css file.
Used pre-existing CSS patterns for consistency.

Summary by CodeRabbit

  • Style Changes

    • Replaced local CSS module with global styles
    • Added new reusable CSS classes for text handling, indicators, and layout
    • Enhanced drawer and organization section styling
    • Improved responsiveness and accessibility of UI components
    • Introduced new styles for active/inactive button states with transitions
  • Refactor

    • Simplified button rendering logic
    • Updated component styling management

Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Walkthrough

This pull request focuses on refactoring the CSS for the LeftDrawerOrg component by removing its local CSS module and migrating styles to the global app.module.css. The changes involve updating the component's styling references, simplifying button rendering logic, and consolidating CSS classes. The primary goal is to streamline the application's CSS management and improve overall styling consistency.

Changes

File Change Summary
src/components/LeftDrawerOrg/LeftDrawerOrg.module.css Deleted entirely
src/components/LeftDrawerOrg/LeftDrawerOrg.tsx Updated CSS import from local module to global app.module.css, simplified button rendering logic
src/style/app.module.css Added multiple reusable classes, enhanced layout and styling for left drawer, organization, and profile components

Assessment against linked issues

Objective Addressed Explanation
Refactor CSS in LeftDrawerOrg.tsx [#2900]
Move embedded CSS to app.module.css [#2900]
Remove local CSS module [#2900]

Possibly related issues

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Suggested reviewers

  • varshith257
  • palisadoes
  • AVtheking

Poem

🐰 Hopping through CSS with glee,
Styles now global, oh so free!
Modules merged, complexity shed,
A cleaner path where code has led.
Rabbit's refactor, neat and bright! 🎨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 Jan 3, 2025

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
Contributor

@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

🧹 Nitpick comments (5)
src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (1)

128-131: Shimmer state distinguished well.
The placeholder class shimmer is a neat approach for the loading state. Ensure you have an accessible equivalent for screen-readers (e.g., aria-busy).

src/style/app.module.css (4)

3711-3721: Duplicate .reusable-focus-visible.
Consider reorganizing the repeated definitions to avoid collisions in the final compiled CSS.


3754-3759: .inactiveDrawer transitions.
Smooth sliding effect with transform: translateX(-100%). The code snippet for [data-hidden='true'] is empty. Possibly a placeholder.


3760-3766: .activeDrawer transitions.
Ensures the drawer slides in cleanly. The [data-hidden='false'] is also a placeholder but nice for future expansions.


3807-3809: .profileText
Margin-left for spacing. Confirm it doesn’t break the layout in RTL mode, or rely on logical properties.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2215c0a and a0ac35f.

📒 Files selected for processing (3)
  • src/components/LeftDrawerOrg/LeftDrawerOrg.module.css (0 hunks)
  • src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (6 hunks)
  • src/style/app.module.css (1 hunks)
💤 Files with no reviewable changes (1)
  • src/components/LeftDrawerOrg/LeftDrawerOrg.module.css
🔇 Additional comments (33)
src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (9)

14-14: Global styling import recognized.
Importing from app.module.css instead of a locally scoped CSS file is consistent with the PR objective of consolidating CSS.


34-34: Function signature clarity.
The parameter list and usage are clear. The docstring above it is consistent and helpful for future reference.


49-49: Comment readability.
Though short, the comment effectively clarifies the intent behind indexing logic.


51-51: Safety check not performed.
You return an empty string if segments.length is less than 3. If there's a possibility of an even shorter path or an unexpected format, consider logging or gracefully handling the scenario.


72-72: UseMemo usage is appropriate.
This is a good usage of useMemo to avoid repeatedly executing the parsing logic.


78-78: Cleanup handling.
Nice use of a boolean flag within the effect to avoid setting state after unmount.


135-135: Red danger background usage.
Using styles.bgDanger references the new utility class. This is consistent with the approach to unify all CSS.


179-182: Active vs. inactive state logic.
Smooth usage of isActive to manage variant and class name. This aligns with the standardized approach of .activeButton and .inactiveButton.


188-188: Dynamic icon color.
Conditionally applying the color via 'var(--bs-black)' or 'var(--bs-secondary)' is correct. Make sure these variables align well with your dark-mode or theme overrides.

src/style/app.module.css (24)

3631-3637: Introduce .reusable-text-ellipsis.
A concise utility for truncating text, ensuring improved readability for limited-width containers.


3638-3647: Introduce .reusable-indicator.
Positions a colored indicator bar on the left side of the element. Good for highlighting states or statuses.


3648-3660: Introduce .reusable-arrow-indicator.
Applying '▶' with positioning for directional feedback is a clean, minimal solution.


3661-3665: Introduce .reusable-focus-visible.
Enhances keyboard accessibility by providing a visible outline on focus.


3666-3672: Reduced motion preference check.
Good job disabling transitions and animations when prefers-reduced-motion is enabled. This is inclusive and accessible.


3673-3679: RTL support (repeat).
Positioning transformations are reversed for RTL. This ensures correct alignment for right-to-left interfaces.


3680-3686: Duplicate .reusable-text-ellipsis.
This block appears to be repeated lines. Ensure it won’t create merge conflicts or duplication in your final CSS.


3697-3710: Duplicate .reusable-arrow-indicator.
Again, repeated lines. Confirm if they differ in ways that might cause unintended side effects.


3722-3728: Duplicate RTL support.
Check if you intend to define this twice or if it’s a merge artifact.


3729-3741: Enhanced .leftDrawer styles.
Height set to 100vh with overflow-y scroll ensures a stable layout. The transitions and will-change property help with rendering performance.


3742-3753: .hideElemByDefault & data-hidden approach.
The data attributes are a flexible way to toggle visibility. Just ensure the conditions are well-synchronized in the React code.


3767-3778: .organizationContainer and .profileContainer.
Proper spacing and alignment. Use of focus-visible approach is a plus for accessibility.


3779-3782: Chained SCSS or placeholder usage.
@extend .reusable-focus-visible; implies SCSS usage or Sass placeholder. Make sure your build pipeline supports it.


3783-3786: .bg-danger short usage.
Reuses the existing --delete-button-color. Straightforward naming that indicates its intention.


3787-3794: .text-start & .text-white.
Helpful utility classes. They mirror Bootstrap's pattern. Keep them from clashing with the .bootstrap classes.


3796-3805: .imageContainer img
Applying consistent sizing and alt text styling. This can help maintain a uniform avatar size throughout the UI.


3811-3815: .primaryText
Extending .reusable-text-ellipsis ensures the text truncates gracefully. Looks consistent and prevents overflow.


3817-3821: .secondaryText
Mirrors .primaryText with slightly smaller font. Sufficient for showing subtitles or less important info. Good approach.


3823-3829: .titleHeader
Clear usage for headings with bigger font-size. The line-height and margin variables keep it well spaced.


3831-3844: .activeButton & .inactiveButton
Having them share transitions but differ in background color is good. The usage of pseudo-elements via @extend for indicators is neat.


3846-3857: Hover effect on .activeButton
.activeButton:hover .arrow-indicator shows fancy scaling. Make sure .arrow-indicator is properly referenced in HTML or SCSS.


3859-3863: .inactiveButton hover
Provides a color fill on hover. It's consistent with the .activeButton approach and respects design.


3864-3871: .iconWrapper dynamic tooltip
A slick approach for accessible tooltips. Confirm that screen readers handle these well, or consider ARIA roles for extended accessibility.


3873-3905: Mass additions from 3873 onward
This block primarily adds or modifies utility classes, ensuring consistent styling across large components (e.g., toggles, popups). Overall this standardizes the UI with minimal repeated rules.

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

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.51%. Comparing base (2215c0a) to head (8b2a701).
Report is 3 commits behind head on develop-postgres.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           develop-postgres    #3131       +/-   ##
=====================================================
+ Coverage             21.89%   89.51%   +67.62%     
=====================================================
  Files                   301      322       +21     
  Lines                  7686     8454      +768     
  Branches               1679     1902      +223     
=====================================================
+ Hits                   1683     7568     +5885     
+ Misses                 5897      655     -5242     
- Partials                106      231      +125     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@palisadoes
Copy link
Contributor

Please change the title of the PR to be correctly searchable

@palisadoes
Copy link
Contributor

Fix the failing test

Copy link
Contributor

@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

🧹 Nitpick comments (6)
src/style/app.module.css (6)

Line range hint 1-101: Improve CSS variable naming consistency.

Consider standardizing the naming convention for color variables. Currently, there are inconsistencies:

  • Some use "grey" while others use "gray"
  • Some use descriptive names while others use functional names

Examples to standardize:

- --grey-light: #eaebef;
- --gray-blue: #1e293b;
+ --gray-100: #eaebef;
+ --gray-700: #1e293b;

3631-3642: Optimize drawer performance and touch handling.

The drawer implementation shows good use of will-change and transform, but consider these additional optimizations:

 .leftDrawer {
   height: 100vh;
   overflow-y: auto;
   transition: transform 0.3s ease;
   will-change: transform;
   position: fixed;
   padding-bottom: 1rem;
   overscroll-behavior: contain;
   -webkit-overflow-scrolling: touch;
+  /* Prevent layout shifts during animation */
+  backface-visibility: hidden;
+  /* Improve touch handling */
+  touch-action: pan-y pinch-zoom;
+  /* Use GPU acceleration */
+  transform: translateZ(0);
 }

3686-3696: Improve utility class modularity and specificity.

The utility classes could be more modular and follow a consistent pattern:

- .bg-danger {
-   background-color: var(--delete-button-color);
- }
- .text-start {
-   text-align: start;
- }
- .text-white {
-   color: var(--bs-white);
- }
+ /* Use a more systematic approach */
+ .u-bg-danger {
+   background-color: var(--delete-button-color) !important;
+ }
+ .u-text-start {
+   text-align: start !important;
+ }
+ .u-text-white {
+   color: var(--bs-white) !important;
+ }

3775-3806: Enhance accessibility features.

The icon wrapper implementation has good ARIA support, but consider these accessibility improvements:

 .iconWrapper {
   &[aria-label]:not([aria-label='']) {
     &::after {
       content: attr(aria-label);
       background: var(--bs-dark);
       color: var(--bs-white);
+      /* Ensure sufficient color contrast */
+      background: var(--bs-gray-900);
+      /* Improve visibility */
+      box-shadow: 0 2px 4px rgba(0,0,0,0.2);
+      /* Add screen reader only text */
+      @media screen and (forced-colors: active) {
+        outline: 2px solid currentColor;
+      }
     }
   }
 }

3733-3773: Optimize animation performance.

The button animations could be optimized to prevent layout thrashing:

 .activeButton,
 .inactiveButton {
   position: relative;
-  transition: all 0.2s ease;
+  /* Only animate opacity and transform to avoid layout recalculation */
+  transition: opacity 0.2s ease, transform 0.2s ease;
+  /* Promote to GPU layer */
+  transform: translateZ(0);
+  /* Hint browser about changes */
+  will-change: opacity, transform;
 
   &:active {
     transform: scale(0.98);
   }
 }

3644-3654: Standardize responsive breakpoints.

Consider using CSS custom properties for breakpoints to maintain consistency:

+:root {
+  --breakpoint-sm: 576px;
+  --breakpoint-md: 768px;
+  --breakpoint-lg: 992px;
+  --breakpoint-xl: 1200px;
+}

 .hideElemByDefault {
   display: none;
 }

-[data-hidden='true'] {
+@media (max-width: var(--breakpoint-md)) {
+  [data-hidden='true'] {
   visibility: hidden;
+  }
 }

-[data-hidden='false'] {
+@media (max-width: var(--breakpoint-md)) {
+  [data-hidden='false'] {
   visibility: visible;
+  }
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0ac35f and 8b2a701.

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

@dhruuvarora dhruuvarora changed the title Dev refactor Refactor CSS for LeftDrawerOrg Jan 3, 2025
This was referenced Jan 19, 2025
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.

2 participants