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

Refactored CSS files in src/screens/Requests #3570

Merged

Conversation

aadhil2k4
Copy link
Contributor

@aadhil2k4 aadhil2k4 commented Feb 9, 2025

What kind of change does this PR introduce?

Refactoring

Issue Number:

Fixes #2525

Summary

A part of the Issue was already completed like streamlining CSS to a single file. I updated the Requests table to match the styles of the Table used across the application and added CSS variables wherever required.

Does this PR introduce a breaking change?

No

Checklist

CodeRabbit AI Review

  • I have reviewed and addressed all critical issues flagged by CodeRabbit AI
  • I have implemented or provided justification for each non-critical suggestion
  • I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented

Test Coverage

  • I have written tests for all new changes/features
  • I have verified that test coverage meets or exceeds 95%
  • I have run the test suite locally and all tests pass

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features
    • Revamped the Requests table interface with new Material-UI components for an enhanced, modern display.
  • Style
    • Updated input fields to apply a consistent shadow effect during active and focus states for improved visual consistency.
  • Documentation
    • Updated documentation to reflect the new definition location for the default() function.
  • Tests
    • Increased timeout duration for the Search by Category name test case to enhance the waiting mechanism.

Copy link
Contributor

coderabbitai bot commented Feb 9, 2025

Walkthrough

This pull request updates documentation and UI styling without altering core functionality. The documentation for the default() function now correctly points to its new definition location. In the Requests component, the table implementation has been refactored to use Material-UI components instead of Bootstrap HTML elements, while the mapping of requests remains unchanged. In addition, the global CSS file has been updated to replace hard-coded box-shadow values with a CSS variable for the .input element’s active and focus states.

Changes

File(s) Change Summary
docs/.../Requests/functions/default.md Updated default() function documentation: corrected definition location from line 33 to 41 in Requests.tsx.
src/screens/Requests/Requests.tsx Replaced the Bootstrap table structure with Material-UI components (Table, TableHead, TableBody, TableRow, TableCell, TableContainer); mapping remains unchanged.
src/style/app.module.css Modified .input :active and :focus states by replacing a fixed box-shadow with the variable var(--dorpdownItem-hover-shadow) for consistency.

Assessment against linked issues

Objective Addressed Explanation
Refactor CSS files in src/screens/Requests (#2525): Merge CSS into a global file and remove local CSS. Local CSS files remain unchanged; only a global CSS variable was updated.

Possibly related issues

Suggested reviewers

  • palisadoes

Poem

Oh, I’m a rabbit in a code-filled glen,
Hopping through changes now and then.
Tables transformed with Material-UI gleam,
And CSS variables sparkle like a dream.
With whiskered joy and a carrot cheer,
I celebrate updates with a happy bunny leer!
🥕🐇


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9e2a450 and 14548a0.

📒 Files selected for processing (1)
  • src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (1)
src/screens/UserPortal/Volunteer/Actions/Actions.spec.tsx (1)

217-223: Consider investigating the need for such a long timeout.

While adding a longer timeout can help stabilize flaky tests, a 10-second wait suggests potential performance issues with the search operation or data fetching.

Consider:

  1. Investigating why the search operation takes longer than the default timeout
  2. Adding logging or performance monitoring to track search operation latency
  3. Checking if there are any unnecessary delays in the search implementation
  4. Verifying if this is an isolated case or if other similar operations are also slow

Would you like me to help investigate the root cause by analyzing the search implementation?


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 Feb 9, 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: 0

🔭 Outside diff range comments (6)
src/screens/Requests/Requests.tsx (1)

3-3: Remove unused Bootstrap Table import.

The Table import from 'react-bootstrap' is no longer used after migrating to Material-UI components.

-import { Table } from 'react-bootstrap';
src/style/app.module.css (5)

242-242: Fix typo in CSS variable name.

The variable name --dorpdownItem-hover-shadow has a typo - "dorp" should be "drop".

Apply this fix:

-  --dorpdownItem-hover-shadow: 2.5px 2.5px 2.5px rgba(0, 0, 0, 0.3);
+  --dropdownItem-hover-shadow: 2.5px 2.5px 2.5px rgba(0, 0, 0, 0.3);

1096-1100: Remove non-standard CSS property usage.

The &::before syntax is not valid CSS - it's a preprocessor feature. This will not work in regular CSS.

Apply this fix:

-.errorIcon {
-  /* Add error icon for non-color indication */
-  &::before {
-    content: '⚠️';
-    margin-right: 0.5rem;
-  }
-}
+.errorIcon::before {
+  content: '⚠️';
+  margin-right: 0.5rem;
+}

4063-4077: Remove non-standard global CSS module syntax.

The :global() syntax is not valid CSS - it's specific to CSS modules. This will not work in regular CSS.

Apply this fix:

-.selectOrgText {
-  :global(.MuiOutlinedInput-root.Mui-focused) fieldset {
-    border-color: var(--primary-color);
-  }
-
-  :global(.MuiInputLabel-root.Mui-focused) {
-    color: var(--primary-color);
-  }
-
-  :global(.MuiAutocomplete-option:hover) {
-    background-color: var(--primary-color);
-    color: var(--text-color-light);
-  }
-}
+/* Material-UI overrides */
+.MuiOutlinedInput-root.Mui-focused fieldset {
+  border-color: var(--primary-color);
+}
+
+.MuiInputLabel-root.Mui-focused {
+  color: var(--primary-color);
+}
+
+.MuiAutocomplete-option:hover {
+  background-color: var(--primary-color);
+  color: var(--text-color-light);
+}

2184-2204: Consolidate duplicate keyframe animations.

There are multiple duplicate keyframe animations for load8, zoomIn, fadeIn, etc. This violates DRY principle.

Consolidate the animations into a single definition for each unique animation:

-@-webkit-keyframes load8 { ... }
-@keyframes load8 { ... }
-@-webkit-keyframes load8 { ... }
-@keyframes load8 { ... }
+@keyframes load8 {
+  0% {
+    transform: rotate(0deg);
+  }
+  100% {
+    transform: rotate(360deg);
+  }
+}

-@-webkit-keyframes zoomIn { ... }
-@keyframes zoomIn { ... }
-@-webkit-keyframes zoomIn { ... }
-@keyframes zoomIn { ... }
+@keyframes zoomIn {
+  0% {
+    opacity: 0;
+    transform: scale(0.5);
+  }
+  100% {
+    opacity: 1;
+    transform: scale(1);
+  }
+}

// Similarly consolidate other duplicate animations

Also applies to: 2195-2204, 3543-3564, 4493-4516, 4518-4542, 4633-4651, 4686-4696, 8757-8853


525-532: Consolidate duplicate media queries.

There are many duplicate media queries scattered throughout the file. This makes maintenance difficult and increases file size.

Consolidate all media queries at the end of the file and group them by breakpoint:

/* Base styles */
...

/* Media Queries */
@media (max-width: 1440px) {
  /* Consolidate all 1440px breakpoint styles */
}

@media (max-width: 1120px) {
  /* Consolidate all 1120px breakpoint styles */
}

@media (max-width: 820px) {
  /* Consolidate all 820px breakpoint styles */
}

@media (max-width: 520px) {
  /* Consolidate all 520px breakpoint styles */
}

/* And so on for other breakpoints */

Also applies to: 818-821, 1818-1829, 1990-2010, 2106-2133, 2151-2182, 2257-2260, 3406-3420, 3831-3886, 4256-4284, 4425-4480, 4662-4696, 4818-4853, 5060-5106, 5257-5303, 5405-5415, 5662-5686, 5818-5886, 6626-6634, 7255-7302, 7918-7940, 8262-8303, 8727-8755, 8962-9014

🧹 Nitpick comments (4)
src/screens/Requests/Requests.tsx (1)

36-40: Enhance component documentation.

Consider adding more details to the documentation:

  • Mention the Material-UI table integration
  • Describe the table structure and columns
  • Explain the search and filter functionality
 /**
  * The `Requests` component fetches and displays a paginated list of membership requests
  * for an organization, with functionality for searching, filtering, and infinite scrolling.
+ * 
+ * The component uses Material-UI's Table components for consistent styling and accessibility.
+ * It displays member information in columns: serial number, name, email, and action buttons.
+ * The search functionality filters requests by member's first name.
  *
  */
src/style/app.module.css (3)

652-657: Consolidate duplicate box-shadow styles.

The .input:active and .input:focus have identical box-shadow styles. This violates DRY principle.

Consolidate the styles using a common selector:

-.input:active {
-  box-shadow: var(--dorpdownItem-hover-shadow) !important;
-  background-color: var(--create-button-bg-color);
-  border-color: var(--input-shadow) !important;
-  color: var(--input-text-color);
-}
-
-.input:focus {
-  box-shadow: var(--dorpdownItem-hover-shadow) !important;
-  border-color: var(--input-shadow) !important;
-}
+.input:is(:active, :focus) {
+  box-shadow: var(--dropdownItem-hover-shadow) !important;
+  border-color: var(--input-shadow) !important;
+}
+
+.input:active {
+  background-color: var(--create-button-bg-color);
+  color: var(--input-text-color);
+}

Also applies to: 659-662


2290-2299: Remove duplicate pseudo-element styles.

The &::after blocks for .subTagsLink and .tagsBreadCrumbs are identical. This violates DRY principle.

Consolidate the styles using a common selector:

-.subTagsLink {
-  /* Prevent layout shift */
-  &::after {
-    display: block;
-    content: attr(data-text);
-    font-weight: 600;
-    height: 0;
-    overflow: hidden;
-    visibility: hidden;
-  }
-}
-
-.tagsBreadCrumbs {
-  /* Prevent layout shift */
-  &::after {
-    display: block;
-    content: attr(data-text);
-    font-weight: 600;
-    height: 0;
-    overflow: hidden;
-    visibility: hidden;
-  }
-}
+.subTagsLink::after,
+.tagsBreadCrumbs::after {
+  display: block;
+  content: attr(data-text);
+  font-weight: 600;
+  height: 0;
+  overflow: hidden;
+  visibility: hidden;
+}

Also applies to: 2304-2313


1-9014: Consider splitting into multiple files.

The CSS file is very large (9000+ lines) which makes it hard to maintain. Consider splitting it into multiple files based on functionality:

  • variables.css (CSS variables)
  • animations.css (keyframe animations)
  • base.css (base styles)
  • components/ (component-specific styles)
  • layouts/ (layout styles)
  • media-queries.css (consolidated media queries)
🧰 Tools
🪛 Biome (1.9.4)

[error] 2231-2231: Unexpected shorthand property padding after padding-bottom

(lint/suspicious/noShorthandPropertyOverrides)


[error] 5949-5949: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4408384 and 9e2a450.

📒 Files selected for processing (3)
  • docs/docs/auto-docs/screens/Requests/Requests/functions/default.md (1 hunks)
  • src/screens/Requests/Requests.tsx (2 hunks)
  • src/style/app.module.css (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/docs/auto-docs/screens/Requests/Requests/functions/default.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Check Python Code Style
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (3)
src/screens/Requests/Requests.tsx (1)

280-320: Well-implemented Material-UI table migration!

The table implementation:

  • Uses proper Material-UI components and patterns
  • Maintains accessibility with ARIA labels and roles
  • Preserves existing functionality
  • Follows consistent styling with Paper component
src/style/app.module.css (2)

1-36: Excellent CSS documentation and methodology.

The CSS documentation and methodology is well-structured and provides clear guidelines for:

  • Reducing CSS duplication through global classes
  • Naming conventions with clear examples
  • List of global classes with their purposes

This helps maintain consistency and simplifies maintenance.


38-378: Well-organized CSS variables with semantic naming.

The CSS variables are well-organized into logical groups:

  • Neutral colors
  • Blue shades
  • Red shades
  • Yellow/Orange shades
  • Miscellaneous colors
  • Font sizes
  • Borders and radius
  • Loader sizes
  • Image sizes
  • Modal dimensions

This makes the codebase more maintainable and consistent.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 9, 2025
@palisadoes
Copy link
Contributor

Please fix the failing test

Copy link

codecov bot commented Feb 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.87%. Comparing base (7afd9e4) to head (72cb359).
Report is 1 commits behind head on develop-postgres.

Additional details and impacted files
@@                Coverage Diff                @@
##           develop-postgres    #3570   +/-   ##
=================================================
  Coverage             85.87%   85.87%           
=================================================
  Files                   342      342           
  Lines                  8882     8882           
  Branches               1911     1911           
=================================================
  Hits                   7627     7627           
  Misses                  913      913           
  Partials                342      342           

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

@palisadoes palisadoes merged commit 0116e8b into PalisadoesFoundation:develop-postgres Feb 10, 2025
19 checks passed
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