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 files in src/screens/OrgContribution (Fixs : #2520) #2674

Conversation

amaan-aly246
Copy link
Contributor

@amaan-aly246 amaan-aly246 commented Dec 16, 2024

What kind of change does this PR introduce?

Refactor

Issue Number:

Fixes #2520

Did you add tests for your changes?

No

Snapshots/Videos:

Screenshot 2024-12-12 234946

If relevant, did you update the documentation?

Not relevant

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

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Introduced new CSS variables and class definitions for improved styling across components.
  • Bug Fixes

    • Removed unused CSS styles to streamline the stylesheet.
  • Documentation

    • Updated comments for improved clarity in GraphQL mutation definitions.
  • Style

    • Removed several CSS files and associated styles, affecting the appearance of text and card components.
    • Updated import paths for CSS in several components to a centralized stylesheet.
  • Refactor

    • Simplified prop access in the ContriStats component for better readability.
    • Renamed the orgContribution component to OrgContribution for consistency with naming conventions.

…onding css file code into global css file (app.module.css)
Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request focuses on refactoring CSS files for the Organization Contribution screen and related components. The changes involve merging CSS styles from multiple component-specific CSS files into the global app.module.css file, removing individual CSS modules, and updating import statements in corresponding TypeScript files to reference the new global stylesheet. The modifications aim to streamline the application's styling and improve maintainability.

Changes

File Change Summary
src/components/ContriStats/ContriStats.module.css Deleted CSS module file
src/components/ContriStats/ContriStats.tsx Updated import to use app.module.css and modified function signature
src/components/OrgContriCards/OrgContriCards.module.css Deleted CSS module file
src/components/OrgContriCards/OrgContriCards.tsx Updated import to use app.module.css
src/screens/OrgContribution/OrgContribution.module.css Deleted CSS module file
src/screens/OrgContribution/OrgContribution.tsx Renamed component to follow capitalization convention and updated import to use app.module.css
src/style/app.module.css Added numerous CSS variables and modified existing styles

Assessment against linked issues

Objective Addressed Explanation
Merge CSS files into global stylesheet
Delete individual CSS files
Reference global CSS file
Improve UI/UX for color-blind users Requires further review of color variables

Possibly related issues

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Suggested reviewers

  • palisadoes

Poem

🐰 CSS files dancing away,
Merging styles in a grand display,
From modules scattered, now unite,
In app.module.css shining bright,
A rabbit's refactor, clean and gay! 🎨


📜 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 30a01ad and 73cd0ae.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/GraphQl/Mutations/ActionItemCategoryMutations.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/GraphQl/Mutations/ActionItemCategoryMutations.ts

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

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 (3)
package.json (2)

Update @apollo/client from beta version ^3.4.0-beta.19 to the latest stable version 3.12.3

Using a beta version in production dependencies poses stability risks. The latest stable version 3.12.3 is recommended for production use.

  • Update the dependency in package.json:
-    "@apollo/client": "^3.4.0-beta.19",
+    "@apollo/client": "^3.12.3",
🔗 Analysis chain

Line range hint 163-163: Caution: Using beta version of @apollo/client in resolutions

Using a beta version (^3.4.0-beta.19) of @apollo/client in production could introduce instability. Consider using the latest stable version instead.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest stable version of @apollo/client
curl -s https://registry.npmjs.org/@apollo/client | jq -r '."dist-tags".latest'

Length of output: 88


Version mismatch between @types/react and React needs to be addressed

The verification confirms that:

  • React 18.3.1 is being used in the project
  • React 18 features like createRoot are actively being used
  • Multiple components use React.FC/FunctionComponent types
  • @types/react is pinned to version 17.0.2

This version mismatch between React 18.3.1 and @types/react 17.0.2 needs to be resolved by updating @types/react to a compatible version (18.x.x) to ensure type definitions match the actual React implementation.

🔗 Analysis chain

Line range hint 164-164: Version mismatch: @types/react vs React

The project uses React 18.3.1 but @types/react is pinned to 17.0.2. This version mismatch could lead to incorrect type definitions and development issues.


Let me gather more information about the React version actually being used in the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for React 18 type usage that might break with React 17 types
rg -l "React\.(FC|FunctionComponent)<" 

# Check if any files use React 18 specific features
ast-grep --pattern 'useTransition|useDeferredValue|useId|useInsertionEffect|useSyncExternalStore'

Length of output: 2707


Script:

#!/bin/bash
# Check React version in package.json
cat package.json | jq '.dependencies.react, .devDependencies.react'

# Check for any React 18 specific imports
rg "createRoot|useTransition|useDeferredValue|useId|useInsertionEffect|useSyncExternalStore" -A 2

Length of output: 542

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

Line range hint 388-394: Duplicate CSS class definitions for .orgUserTagsScrollableDiv

The .orgUserTagsScrollableDiv class is defined twice in the stylesheet (lines 388-394 and lines 419-425). This can lead to confusion and unexpected behavior due to overlapping styles. Please consolidate these definitions into a single definition to maintain clarity and prevent potential conflicts.

Also applies to: 419-425

🧹 Nitpick comments (4)
src/screens/OrgContribution/OrgContribution.tsx (2)

11-15: Update JSDoc to match new component name

The JSDoc comment still references the old component name orgContribution while the component has been renamed to OrgContribution.

 /**
- * The `orgContribution` component displays the contributions to an organization.
+ * The `OrgContribution` component displays the contributions to an organization.
  * It includes a sidebar for filtering contributions by organization name and transaction ID.
  * Additionally, it shows recent contribution statistics and a list of contribution cards.
  */

Line range hint 49-55: Consider removing hardcoded values from components

The ContriStats and OrgContriCards components contain hardcoded values which might be test data. Consider replacing these with actual data from props or a data source.

 <ContriStats
-  key="129"
-  id="21"
-  recentAmount="90"
-  highestAmount="500"
-  totalAmount="6000"
+  key={someUniqueKey}
+  id={contributionId}
+  recentAmount={recentAmount}
+  highestAmount={highestAmount}
+  totalAmount={totalAmount}
 />

 <OrgContriCards
-  key="129"
-  id="21"
-  userName="John Doe"
-  contriDate="20/7/2021"
-  contriAmount="21"
-  contriTransactionId="21WE98YU"
-  userEmail="johndoexyz@gmail.com"
+  key={someUniqueKey}
+  id={contributionId}
+  userName={userName}
+  contriDate={contriDate}
+  contriAmount={contriAmount}
+  contriTransactionId={transactionId}
+  userEmail={userEmail}
 />

Also applies to: 69-77

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

432-440: Remove commented-out code

There is a block of commented-out CSS code between lines 432-440. Keeping unused code can clutter the stylesheet and make maintenance more difficult. If this code is no longer needed, please remove it to keep the codebase clean.


73-109: Ensure consistent naming conventions for CSS classes

The class names in the stylesheet use a mix of camelCase and kebab-case (e.g., .sidebarsticky, .logintitle, .searchtitle, .admindetails). For improved readability and maintainability, consider using a consistent naming convention throughout the stylesheet, such as kebab-case (.sidebar-sticky, .login-title).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9723078 and 30a01ad.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • package.json (1 hunks)
  • src/components/ContriStats/ContriStats.module.css (0 hunks)
  • src/components/ContriStats/ContriStats.tsx (2 hunks)
  • src/components/OrgContriCards/OrgContriCards.module.css (0 hunks)
  • src/components/OrgContriCards/OrgContriCards.tsx (1 hunks)
  • src/screens/OrgContribution/OrgContribution.module.css (0 hunks)
  • src/screens/OrgContribution/OrgContribution.tsx (2 hunks)
  • src/style/app.module.css (11 hunks)
💤 Files with no reviewable changes (3)
  • src/components/ContriStats/ContriStats.module.css
  • src/components/OrgContriCards/OrgContriCards.module.css
  • src/screens/OrgContribution/OrgContribution.module.css
✅ Files skipped from review due to trivial changes (1)
  • src/components/OrgContriCards/OrgContriCards.tsx
🔇 Additional comments (7)
src/screens/OrgContribution/OrgContribution.tsx (2)

Line range hint 16-85: Implementation follows React best practices

The component implementation is well-structured with:

  • Proper TypeScript typing
  • Accessible form controls
  • Internationalization support
  • Clear component structure

8-8: Verify CSS class migration to global stylesheet

The CSS import has been moved to the global stylesheet. Let's ensure all required styles are properly migrated.

✅ Verification successful

Let me fix the regex issue and try again to verify the CSS classes.


CSS classes are properly migrated to global stylesheet

All CSS classes used in OrgContribution.tsx (justifysp, logintitle, mainpageright, searchtitle, sidebar, sidebarsticky) are present in the global stylesheet at src/style/app.module.css. The import path and CSS migration are correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all CSS classes used in this component exist in the global stylesheet

# Get all CSS classes used in this file
echo "CSS classes used in OrgContribution.tsx:"
rg "styles\.[a-zA-Z0-9_-]+" "src/screens/OrgContribution/OrgContribution.tsx" -o | sort -u | sed 's/styles\.//'

# Check if these classes exist in the global stylesheet
echo -e "\nChecking if these classes exist in global stylesheet:"
rg "^\.([a-zA-Z0-9_-]+)\s*{" "src/style/app.module.css" -o | sed 's/^\.//' | sort -u

Length of output: 589


Script:

#!/bin/bash
# Description: Verify that all CSS classes used in this component exist in the global stylesheet

# Get all CSS classes used in this file
echo "CSS classes used in OrgContribution.tsx:"
rg "styles\.[a-zA-Z0-9_-]+" "src/screens/OrgContribution/OrgContribution.tsx" -o | sort -u | sed 's/styles\.//'

# Check if these classes exist in global stylesheet
echo -e "\nChecking if these classes exist in global stylesheet:"
rg "^\.[a-zA-Z0-9_-]+" "src/style/app.module.css" -o | sed 's/^\.//' | sort -u

Length of output: 1077

package.json (2)

159-159: LGTM: Minor version bump for vitest

The update from ^2.1.5 to ^2.1.8 is a patch version change that should be safe.


Line range hint 169-171: Verify Node.js version requirement impact

The addition of "node": ">=20.x" is quite restrictive. Ensure this aligns with your CI/CD environment and development team requirements.

✅ Verification successful

Let me gather more information about the Node.js version requirements.


Node.js 20 requirement is justified and properly aligned

The Node.js 20.x requirement is well-aligned with the project's infrastructure and dependencies:

  • The Dockerfile explicitly uses node:20.10.0 as the base image
  • Several dependencies in package.json are using recent versions that benefit from Node.js 20's features and improvements:
    • React 18.3.x and related ecosystem
    • Vite 5.4.x
    • TypeScript 5.6.x
    • Modern testing libraries and tooling

The codebase shows a modern JavaScript/TypeScript setup that would benefit from Node.js 20's performance improvements and features. No compatibility issues were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if CI configuration specifies Node.js version
fd -t f "^\.?github/workflows/.*\.(ya?ml|json)$" | xargs rg "node-version"

# Check for Node.js version specific features in the codebase
rg "node:" # Search for Node.js protocol imports
ast-grep --pattern 'fetch($$$)' # Search for native fetch usage (Node.js 18+ feature)

Length of output: 12257


Script:

#!/bin/bash
# Check package.json for dependencies that might require Node.js 20
cat package.json | jq '.dependencies, .devDependencies'

# Check for usage of Node.js 20 specific features
rg "import.meta" # Node.js 20 feature
rg "structuredClone" # Node.js 17+ feature
rg "Object\.hasOwn" # Node.js 16.9+ feature

# Check Dockerfile for any other Node.js version references
cat Dockerfile

Length of output: 4618

src/components/ContriStats/ContriStats.tsx (3)

4-4: Updated import to centralized stylesheet

Importing styles from app.module.css centralizes styling and promotes consistency across components.


16-18: Enhanced JSDoc comments for parameters

Providing detailed descriptions for each parameter in the JSDoc comments improves documentation and helps other developers understand the code more easily.


22-26: Destructured props in function declaration

Destructuring props directly in the function parameters simplifies the code and enhances readability.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 16, 2024
@Cioppolo14
Copy link
Contributor

@amaan-aly246 Please fix the failed tests.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 17, 2024
@amaan-aly246
Copy link
Contributor Author

currently working on resolving the 3rd failed test.

@palisadoes
Copy link
Contributor

  1. Please fix the failing tests. Click on the Details links for more information.
  2. Please make sure that CodeRabbit.ai approves your changes

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.91%. Comparing base (debe672) to head (73cd0ae).
Report is 9 commits behind head on develop-postgres.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           develop-postgres    #2674      +/-   ##
====================================================
- Coverage             92.23%   83.91%   -8.33%     
====================================================
  Files                   295      312      +17     
  Lines                  7036     8128    +1092     
  Branches               1516     1778     +262     
====================================================
+ Hits                   6490     6821     +331     
- Misses                  342     1162     +820     
+ Partials                204      145      -59     

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

@amaan-aly246
Copy link
Contributor Author

@palisadoes, I need help solving the failing test. I know a bit of GraphQL but am unable to resolve this error:
[log] in /home/runner/work/talawa-admin/talawa-admin/src/GraphQl/Mutations/FundMutation.ts: [log] - Cannot query field 'createFund' on type 'Mutation'. Did you mean 'createUser'?

I looked at the schema.graphql and FundMutation.ts files but couldn't find any issue in the schema and code is working fine on my end without any errors.
Thanks

@palisadoes palisadoes merged commit 395fbc0 into PalisadoesFoundation:develop-postgres Dec 20, 2024
12 of 14 checks passed
@palisadoes
Copy link
Contributor

The introspection tests will be fixed in a few weeks.
Thanks

@amaan-aly246
Copy link
Contributor Author

@palisadoes I want to contribute more to this org. I have 2-3 question if you (or any maintainer) can answer

  1. Do you guys have any stack/discord channel for development related issue, where I can ask question regarding the same?
  2. Initially, I pulled the main branch of the forked repository (as mentioned in the README file about contributions) and made my changes there. However, when raising a PR, I was told to make changes to the develop-postgres branch. Should I fetch the updated code from develop-postgres and start development from that branch moving forward?
  3. Will this organization be participating in GSoC'25 as a mentoring organization?

Thanks, looking forward to contribute more.

@amaan-aly246 amaan-aly246 deleted the refactor_OrgContribution_css branch December 20, 2024 13:01
@Cioppolo14
Copy link
Contributor

@amaan-aly246 I cannot answer #2, but you can find the link to our slack channel on our main github page for Palisadoes Foundation. We do hope to participate in GSoC 2025 as a mentoring organization.

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.

3 participants