-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
fixed #3318 Figma: Refactor CSS files in src/components/OrganizationCard #3406
fixed #3318 Figma: Refactor CSS files in src/components/OrganizationCard #3406
Conversation
Warning Rate limit exceeded@gurramkarthiknetha has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 15 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request focuses on refactoring the CSS for the OrganizationCard component by removing its local CSS module and integrating its styles into the global Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3406 +/- ##
=====================================================
+ Coverage 7.90% 89.72% +81.82%
=====================================================
Files 312 334 +22
Lines 8163 8626 +463
Branches 1837 1919 +82
=====================================================
+ Hits 645 7740 +7095
+ Misses 7451 624 -6827
- Partials 67 262 +195
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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 (1)
src/style/app.module.css (1)
Line range hint
6138-6165
: Add keyboard navigation support for interactive elements.Ensure interactive elements are keyboard accessible by adding proper focus styles.
.cardsEventListCard { /* ... existing styles ... */ + outline: none; } +.cardsEventListCard:focus-visible { + outline: 2px solid var(--subtle-blue-grey); + outline-offset: 2px; +} .cardsEventListCard a { color: var(--primary-bg-color); font-weight: 600; + text-decoration: none; + transition: text-decoration 0.2s ease; } -.cardsEventListCard a:hover { +.cardsEventListCard a:hover, +.cardsEventListCard a:focus-visible { color: var(--black-color); + text-decoration: underline; }
🧹 Nitpick comments (5)
src/components/OrganizationCard/OrganizationCard.tsx (3)
Line range hint
77-82
: Consider adding error boundary for better error handling.The component has error handling for local storage access, but it could benefit from a higher-level error boundary to catch rendering errors.
+import { ErrorBoundary } from 'react-error-boundary'; + +function ErrorFallback({ error }) { + return ( + <div role="alert"> + <p>Something went wrong:</p> + <pre>{error.message}</pre> + </div> + ); +} function OrganizationCard({...}) { return ( + <ErrorBoundary FallbackComponent={ErrorFallback}> <div className={styles.orgCard}> {/* ... existing content ... */} </div> + </ErrorBoundary> ); }
Line range hint
156-167
: Add loading state for async operations.The component performs async operations (join, withdraw) but doesn't show loading states, which could lead to a poor user experience.
function OrganizationCard({...}) { + const [isLoading, setIsLoading] = useState(false); async function joinOrganization(): Promise<void> { try { + setIsLoading(true); if (userRegistrationRequired) { await sendMembershipRequest({...}); } else { await joinPublicOrganization({...}); } refetch(); } catch (error) { // ... error handling ... } finally { + setIsLoading(false); } } return ( <div className={styles.orgCard}> {/* ... other content ... */} <Button onClick={joinOrganization} disabled={isLoading} > + {isLoading ? 'Loading...' : t('joinNow')} </Button> </div> ); }
Line range hint
187-206
: Add retry mechanism for membership withdrawal.The membership withdrawal function could benefit from a retry mechanism in case of temporary network issues.
+const MAX_RETRIES = 3; +const RETRY_DELAY = 1000; +async function retry<T>( + fn: () => Promise<T>, + retries: number = MAX_RETRIES, + delay: number = RETRY_DELAY +): Promise<T> { + try { + return await fn(); + } catch (error) { + if (retries > 0) { + await new Promise(resolve => setTimeout(resolve, delay)); + return retry(fn, retries - 1, delay); + } + throw error; + } +} async function withdrawMembershipRequest(): Promise<void> { if (!userId) { toast.error(t('UserIdNotFound') as string); return; } try { - await cancelMembershipRequest({...}); + await retry(() => cancelMembershipRequest({...})); toast.success(t('MembershipRequestWithdrawn') as string); } catch (error) { // ... error handling ... } }src/style/app.module.css (2)
Line range hint
77-92
: Improve color variable naming for better maintainability.Consider using semantic color names that reflect their purpose rather than their visual appearance.
- --primary-bg-color: #ffffff; - --off-white-color: #ffffff97; - --black-color: #000000; - --black-shadow-color: #00000029; - --white-shadow-color: #ffffff33; - --warning-text-color: #febc59; + --surface-primary: #ffffff; + --surface-primary-alpha: #ffffff97; + --text-primary: #000000; + --shadow-dark: #00000029; + --shadow-light: #ffffff33; + --text-warning: #febc59;
7325-7371
: LGTM! New OrganizationCard classes follow BEM methodology.The new CSS classes for OrganizationCard are well-structured and follow BEM naming conventions.
However, consider adding hover and focus states for better accessibility:
.alignimg { border-radius: 50%; background-blend-mode: darken; background-color: var(--primary-bg-color); height: 65px; width: 65px; + transition: transform 0.2s ease; } + +.alignimg:hover, +.alignimg:focus-visible { + transform: scale(1.05); +} .box { color: var(--warning-text-color); + transition: opacity 0.2s ease; } -.box :hover { +.box:hover, +.box:focus-visible { color: var(--warning-text-color); + opacity: 0.8; }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/OrganizationCard/OrganizationCard.module.css
(0 hunks)src/components/OrganizationCard/OrganizationCard.tsx
(1 hunks)src/style/app.module.css
(44 hunks)
💤 Files with no reviewable changes (1)
- src/components/OrganizationCard/OrganizationCard.module.css
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test Application
🔇 Additional comments (2)
src/components/OrganizationCard/OrganizationCard.tsx (2)
2-2
: LGTM! CSS module import updated correctly.The import statement has been updated to use the global CSS module as per the refactoring requirements.
Line range hint
1266-1266
: Verify CSS class usage after refactoring.The component uses several CSS classes that reference
--primary-bg-color
. Please ensure all these classes are properly styled in the global CSS module.Also applies to: 1278-1278, 1310-1310, 1316-1316, 1376-1376, 1388-1388, 1473-1473, 1482-1482
✅ Verification successful
CSS classes and primary-bg-color variable are properly implemented
The CSS classes are correctly styled in the global CSS module (app.module.css). The
--primary-bg-color
variable is properly defined in the root scope as#ffffff
and is consistently used across multiple component styles, including organization card related classes.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any CSS classes in the component that might be missing in the global CSS rg -A 1 'className=\{.*\}' src/components/OrganizationCard/OrganizationCard.tsx | \ grep -o '{styles\.[^}]*}' | \ sed 's/{styles\.\([^}]*\)}/\1/' | \ while read -r class; do echo "Checking class: $class" rg "\\.$class\\s*{" src/style/app.module.css doneLength of output: 2568
Script:
#!/bin/bash # First, find the component's CSS module echo "=== Checking for component's CSS module ===" fd -e css -e scss "OrganizationCard" src/ echo -e "\n=== Checking CSS classes and primary-bg-color usage ===" # Search in potential CSS files with fixed regex for ext in css scss; do echo -e "\nSearching in *.$ext files:" rg --type $ext -l "\.orgCard|\.innerContainer|\.orgImgContainer|\.content|\.orgName|\.orgdesc|\.address|\.orgadmin|\.joinedBtn|\.withdrawBtn|\.joinBtn" src/ done echo -e "\n=== Checking primary-bg-color usage ===" rg --type css --type scss "--primary-bg-color" src/Length of output: 1642
Script:
#!/bin/bash echo "=== OrganizationCard.module.css content ===" cat src/components/OrganizationCard/OrganizationCard.module.css echo -e "\n=== Checking primary-bg-color usage ===" rg "var\(--primary-bg-color\)" src/components/OrganizationCard/OrganizationCard.module.css echo -e "\n=== Checking class definitions ===" rg "^\.(orgCard|innerContainer|orgImgContainer|content|orgName|orgdesc|address|orgadmin|joinedBtn|withdrawBtn|joinBtn)" src/components/OrganizationCard/OrganizationCard.module.cssLength of output: 617
Script:
#!/bin/bash echo "=== Checking app.module.css content ===" cat src/style/app.module.css echo -e "\n=== Searching for primary-bg-color in all CSS files ===" rg "var\(--primary-bg-color\)" "src/**/*.css" echo -e "\n=== Checking where primary-bg-color is defined ===" rg "^\s*--primary-bg-color:" "src/**/*.css"Length of output: 66088
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs to be deleted
- src/components/OrganizationCard/OrganizationCard.module.css
please fix the conflicting file |
i fixed it now |
There was a problem hiding this 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
🧹 Nitpick comments (1)
src/style/app.module.css (1)
Line range hint
1-7461
: Improve CSS organization for better maintainability.Consider reorganizing the CSS file for better maintainability:
Group related styles:
/* 1. CSS Variables */ :root { ... } /* 2. Global Styles */ .fonts { ... } /* 3. Layout Components */ .container { ... } /* 4. UI Components */ .button { ... } /* 5. Component-Specific Styles */ /* OrganizationCard */ .organizationCard { ... } /* 6. Media Queries */ @media (max-width: ...) { ... }Consider splitting into multiple files:
variables.css
: CSS variablesglobal.css
: Global stylescomponents/
: Component-specific styleslayout.css
: Layout stylesmedia.css
: Media queriesAdd section comments for better navigation
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/style/app.module.css
(44 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test Application
🔇 Additional comments (1)
src/style/app.module.css (1)
44-44
: LGTM! Improved semantic variable naming.The renaming of CSS variables from color-based names to semantic names (e.g.,
--grey-border
→--border-color
) improves code maintainability and accessibility by:
- Making the purpose of each variable clearer
- Decoupling visual appearance from function
- Making it easier to maintain consistent theming
Also applies to: 77-77, 82-82, 92-92
Please make coderabbit ai approve your PR |
There was a problem hiding this 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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/style/app.module.css
(44 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (2)
src/style/app.module.css (2)
44-44
: Review CSS variable naming and color accessibility.The color variable naming has been improved for better clarity:
--grey-border
→--border-color
--white-color
→--primary-bg-color
--light-orange
→--warning-text-color
--black
→--primary-text-color
However, there is still an accessibility issue:
The warning text color (
--warning-text-color: #febc59
) fails WCAG AA contrast requirements when used on white background (1.96:1 ratio, should be at least 4.5:1). Consider using a darker shade to meet accessibility standards.Also applies to: 78-78, 83-83, 93-93
7440-7486
: LGTM! Well-structured component styles.The organization card styles have been properly refactored with:
- Component-scoped class names (e.g.,
organizationCard_avatar
,organizationCard_header
)- Clear naming that indicates purpose
- Proper use of CSS variables for colors and spacing
@palisadoes now the coderabbitai approved could you please review this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See coment
There was a problem hiding this 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 (2)
src/style/app.module.css (2)
7440-7486
: Improved class naming using BEM convention.The component styles now follow BEM naming convention (e.g.,
organizationCard_avatar
,organizationCard_header
) which improves maintainability and reduces the risk of naming conflicts.However, the font sizes for h4 and h5 are too small for readability:
.second_box > h4 { - font-size: 10px; + font-size: 14px; /* Minimum size for readable text */ font-weight: bold; text-decoration: none; color: var(--primary-text-color); } .second_box > h5 { text-decoration: none; - font-size: 10px; + font-size: 12px; /* Minimum size for readable text */ font-weight: 100; color: var(--background-primary); }
7452-7454
: Use CSS variable for hover state color.The hover state uses a hardcoded color value. For consistency and maintainability, this should use a CSS variable:
+:root { + --warning-text-hover: #b85c00; +} .box :hover { - color: #b85c00; /* Example of a darker, accessible orange */ + color: var(--warning-text-hover); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/style/app.module.css
(50 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test Application
🔇 Additional comments (1)
src/style/app.module.css (1)
Line range hint
44-93
: Improved semantic variable naming for better maintainability.The variable renaming from color-based names to semantic names (e.g.,
--grey-border
→--border-color
) improves maintainability and supports future dark mode implementation.However, the warning text color still has accessibility issues:
- --warning-text-color: #febc59; + --warning-text-color: #b85c00; /* Darker orange that meets WCAG AA contrast requirements */
There was a problem hiding this 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
♻️ Duplicate comments (1)
src/style/app.module.css (1)
83-83
:⚠️ Potential issueFix warning text color for accessibility.
The warning text color #febc59 fails WCAG AA contrast requirements (1.96:1 ratio). Use a darker shade to meet accessibility standards.
- --warning-text-color: #febc59; + --warning-text-color: #b85c00; /* Meets WCAG AA with 4.5:1 contrast ratio */
🧹 Nitpick comments (1)
src/style/app.module.css (1)
93-93
: Use hex code for consistency in color values.Replace the string value "black" with the hex code #000000 for consistency with other color definitions.
- --primary-text-color: black; + --primary-text-color: #000000;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/style/app.module.css
(50 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test Application
🔇 Additional comments (1)
src/style/app.module.css (1)
7440-7486
: LGTM! Well-structured BEM naming convention.The organization card styles follow BEM naming convention, making the code more maintainable and reducing the likelihood of naming conflicts.
Make coderabbit.ai approve your changes |
18cd1f0
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
UI/UX improvement, refactoring of CSS for better accessibility and maintainability.
Issue Number:
Fixes #3318
Snapshots/Videos:
If relevant, did you update the documentation?
N/A - This PR does not introduce new functionality requiring updates to Talawa-Docs.
Summary
This PR addresses the issue by:
src/style/app.module.css
.Does this PR introduce a breaking change?
No, this PR does not introduce breaking changes. It only refactors styles and updates UI components for consistency and accessibility.
Checklist
UI/UX Improvements
src/style/app.module.css
.src/style/app.module.css
.--search-button-bg
instead of--light-blue
).CodeRabbit AI Review
Test Coverage
Additional Information
src/style/app.module.css
, removing redundancy and improving maintainability.Have you read the contributing guide?
Yes
Summary by CodeRabbit
Summary by CodeRabbit