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

[FIX] Figma User Portal: Organization Left Drawer Violates The Figma Style Guide #3421

Merged

Conversation

hustlernik
Copy link
Contributor

@hustlernik hustlernik commented Jan 25, 2025

What kind of change does this PR introduce?

UI fix according to figma.

Issue Number:

Fixes #3198

Snapshots/Videos:

UserSidebarOrg1.mp4

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

Other information

Have you read the contributing guide?

Yes

Copy link
Contributor

coderabbitai bot commented Jan 25, 2025

Warning

Rate limit exceeded

@hustlernik has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 2df1906 and 6a39793.

📒 Files selected for processing (4)
  • src/components/ProfileCard/ProfileCard.spec.tsx (1 hunks)
  • src/components/ProfileDropdown/ProfileDropdown.tsx (1 hunks)
  • src/components/SignOut/SignOut.tsx (1 hunks)
  • src/style/app.module.css (4 hunks)

Walkthrough

This pull request introduces several enhancements to the user interface components, focusing on consolidating CSS styles, improving user experience, and ensuring consistency with the Figma design guidelines. The changes include the addition of new components like ProfileCard and SignOut, updates to the UserSidebarOrg component, and modifications to the application's CSS styling in the app.module.css file.

Changes

File Change Summary
src/components/ProfileCard/ProfileCard.tsx New component added to render user profile card with dynamic role and name display
src/components/SignOut/SignOut.tsx New component added to provide sign-out functionality with token revocation
src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx Updated to include new ProfileCard and SignOut components, modified styling imports
src/style/app.module.css Added new CSS variables, updated styling for user sidebar and components
docs/docs/auto-docs/ Updated documentation for new and modified components

Assessment against linked issues

Objective Addressed Explanation
Consolidate CSS into src/style/app.module.css
Remove references to HTML color codes
Use descriptive variable names for colors
Conform to Figma style guide

Possibly related issues

Possibly related PRs

Suggested labels

refactor, ui, style-guide

Suggested reviewers

  • palisadoes
  • design-team-lead

Poem

🐰 A rabbit's tale of UI delight,
Styling components with pixel-perfect might,
ProfileCard and SignOut, dancing with grace,
Figma's design, we now embrace!
Code refactored, colors aligned just right! 🎨


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

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

🔭 Outside diff range comments (1)
src/components/ProfileDropdown/ProfileDropdown.tsx (1)

Line range hint 66-71: Remove code coverage ignore for conditional rendering.

The user image conditional rendering should be tested for both cases.

Remove the coverage ignore and add test cases for both scenarios:

-            /*istanbul ignore next*/
             <img
               src={userImage}
               alt={`profile picture`}
               data-testid="display-img"
             />
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Contains code coverage disable statement. Please remove it and add the appropriate tests.

🧹 Nitpick comments (6)
src/components/ProfileCard/ProfileCard.tsx (1)

36-41: Extract magic numbers into named constants.

The maximum name length is hardcoded and could be moved to a constants file for better maintainability.

Consider creating a constants file:

+// src/constants/ui.ts
+export const UI_CONSTANTS = {
+  MAX_NAME_LENGTH: 20,
+  ELLIPSIS_OFFSET: 3,
+} as const;

-const MAX_NAME_LENGTH = 20;
+const { MAX_NAME_LENGTH, ELLIPSIS_OFFSET } = UI_CONSTANTS;
 const fullName = `${firstName} ${lastName}`;
 const displayedName =
   fullName.length > MAX_NAME_LENGTH
-    ? fullName.substring(0, MAX_NAME_LENGTH - 3) + '...'
+    ? fullName.substring(0, MAX_NAME_LENGTH - ELLIPSIS_OFFSET) + '...'
     : fullName;
src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx (1)

164-171: Simplify button variant logic.

The current variant logic can be simplified as it's using empty strings in both cases.

-variant={isActive === true ? '' : ''}

Also, consider using a CSS variable for the icon color to maintain consistency with the design system:

-isActive === true ? '#00000' : 'var(--bs-secondary)'
+isActive === true ? 'var(--primary-text)' : 'var(--bs-secondary)'
src/components/ProfileCard/ProfileCard.spec.tsx (1)

83-124: Consider adding negative test cases.

While the current tests cover the happy path scenarios well, consider adding tests for:

  • Missing user information
  • Invalid image URLs
  • Empty name handling
src/style/app.module.css (1)

4311-4319: Enhance keyboard navigation accessibility.

The focus styles for the profileContainer could be improved for better accessibility.

Consider adding these focus styles:

 .profileContainer {
   &:focus-within {
+    outline: 2px solid var(--bs-primary);
+    outline-offset: 2px;
+    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25);
     @extend .reusable-focus-visible;
   }
 }
🧰 Tools
🪛 GitHub Actions: PR Workflow

[warning] Code style issues found. Run Prettier with --write to fix formatting issues.

docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md (1)

11-14: Improve documentation grammar and consistency.

The documentation has some grammatical inconsistencies:

Apply these changes:

-Renders a sign out button.
+Renders a sign-out button.

-This component helps to logout.
+This component helps users to log out.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~11-~11: When ‘sign-out’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...nts/SignOut/SignOut.tsx#L20) Renders a sign out button. This component helps to logout...

(VERB_NOUN_CONFUSION)


[misspelling] ~13-~13: Did you mean the verb “log out” instead of the noun ‘logout’?
Context: ...gn out button. This component helps to logout. The logout function revokes the refres...

(LOG_IN)

src/components/ProfileDropdown/ProfileDropdown.tsx (1)

62-62: Consider using a more semantic class name for styling.

Instead of using variant="none", consider adding a custom class for styling the dropdown.

-    <Dropdown as={ButtonGroup} variant="none">
+    <Dropdown as={ButtonGroup} className={styles.profileDropdown}>
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Contains code coverage disable statement. Please remove it and add the appropriate tests.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee5e754 and 2df1906.

📒 Files selected for processing (12)
  • docs/docs/auto-docs/components/ProfileCard/ProfileCard/functions/default.md (1 hunks)
  • docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md (1 hunks)
  • docs/docs/auto-docs/components/UserPortal/UserSidebarOrg/UserSidebarOrg/functions/default.md (1 hunks)
  • docs/docs/auto-docs/components/UserPortal/UserSidebarOrg/UserSidebarOrg/interfaces/InterfaceUserSidebarOrgProps.md (1 hunks)
  • src/components/ProfileCard/ProfileCard.spec.tsx (1 hunks)
  • src/components/ProfileCard/ProfileCard.tsx (1 hunks)
  • src/components/ProfileDropdown/ProfileDropdown.tsx (2 hunks)
  • src/components/SignOut/SignOut.spec.tsx (1 hunks)
  • src/components/SignOut/SignOut.tsx (1 hunks)
  • src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.module.css (0 hunks)
  • src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx (4 hunks)
  • src/style/app.module.css (4 hunks)
💤 Files with no reviewable changes (1)
  • src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.module.css
✅ Files skipped from review due to trivial changes (3)
  • docs/docs/auto-docs/components/UserPortal/UserSidebarOrg/UserSidebarOrg/functions/default.md
  • docs/docs/auto-docs/components/ProfileCard/ProfileCard/functions/default.md
  • docs/docs/auto-docs/components/UserPortal/UserSidebarOrg/UserSidebarOrg/interfaces/InterfaceUserSidebarOrgProps.md
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
src/components/ProfileDropdown/ProfileDropdown.tsx

[error] Contains code coverage disable statement. Please remove it and add the appropriate tests.

src/style/app.module.css

[warning] Code style issues found. Run Prettier with --write to fix formatting issues.

🪛 LanguageTool
docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md

[uncategorized] ~11-~11: When ‘sign-out’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...nts/SignOut/SignOut.tsx#L20) Renders a sign out button. This component helps to logout...

(VERB_NOUN_CONFUSION)


[misspelling] ~13-~13: Did you mean the verb “log out” instead of the noun ‘logout’?
Context: ...gn out button. This component helps to logout. The logout function revokes the refres...

(LOG_IN)

🔇 Additional comments (6)
src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx (3)

156-156: LGTM! Header styling aligns with Figma guidelines.

The new header implementation with titleHeader class improves visual hierarchy.


189-192: LGTM! Footer addition enhances user experience.

The addition of ProfileCard and SignOut components in the footer improves navigation and accessibility.


14-17: Consider implications of moving styles to global CSS module.

Moving styles from a component-specific module to a global module might affect component isolation and maintainability. Consider keeping component-specific styles local unless these styles are truly shared across multiple components.

Let's verify the usage of these styles across components:

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

7644-7716: LGTM! Well-structured responsive design.

The media queries are well organized with appropriate breakpoints for different screen sizes. The styles properly handle layout adjustments for various device sizes.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[warning] Code style issues found. Run Prettier with --write to fix formatting issues.

src/components/SignOut/SignOut.spec.tsx (1)

1-127: Well-structured test implementation with comprehensive coverage!

The test suite effectively covers both success and error scenarios for the SignOut component with:

  • Proper mocking of dependencies (useSession, react-router-dom, localStorage)
  • Clear test cases for successful logout and error handling
  • Thorough verification of side effects (localStorage clearing, navigation, session end)
src/components/ProfileDropdown/ProfileDropdown.tsx (1)

Line range hint 1-127: Add the following test cases to achieve full coverage.

To resolve the pipeline failure, implement these test scenarios in your spec file:

  1. Error handling test:

    test('logs error when console.error is called', () => {
      const error = new Error('Test error');
      const consoleSpy = jest.spyOn(console, 'error');
      // Trigger error condition
      expect(consoleSpy).toHaveBeenCalledWith('Error revoking refresh token:', error);
    });
  2. Name truncation test:

    test('truncates long names correctly', () => {
      // Setup component with long name
      const longName = 'Very Long Name That Should Be Truncated';
      // Render and verify truncation
      expect(screen.getByTestId('display-name')).toHaveTextContent('Very Long Name Tha...');
    });
  3. User image rendering test:

    test('renders user image when available', () => {
      // Setup component with userImage
      const userImage = 'test-image-url';
      // Render and verify image
      expect(screen.getByTestId('display-img')).toHaveAttribute('src', userImage);
    });
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Contains code coverage disable statement. Please remove it and add the appropriate tests.

src/components/SignOut/SignOut.tsx Outdated Show resolved Hide resolved
src/components/SignOut/SignOut.tsx Show resolved Hide resolved
src/components/ProfileCard/ProfileCard.tsx Show resolved Hide resolved
src/components/ProfileCard/ProfileCard.spec.tsx Outdated Show resolved Hide resolved
src/components/ProfileCard/ProfileCard.spec.tsx Outdated Show resolved Hide resolved
src/style/app.module.css Show resolved Hide resolved
src/components/ProfileDropdown/ProfileDropdown.tsx Outdated Show resolved Hide resolved
src/components/ProfileDropdown/ProfileDropdown.tsx Outdated Show resolved Hide resolved
hustlernik and others added 7 commits January 25, 2025 19:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@palisadoes palisadoes merged commit 00fe16b into PalisadoesFoundation:develop-postgres Jan 25, 2025
16 of 17 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