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

Enhance Comment Section UI with Redesigned User Icon and Styling #10458

Merged

Conversation

modamaan
Copy link
Contributor

@modamaan modamaan commented Feb 6, 2025

Proposed Changes

updated
Screenshot 2025-02-08 002808

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Added tooltips on avatars to show the creator’s name on hover.
    • Enabled Markdown formatting for comment text.
    • Updated comment ordering to display the most recent first.
  • Style

    • Enhanced layout with improved alignment for a cleaner structure.
    • Updated date presentation for better accessibility and semantic clarity.
    • Refined overall styling of the comment section for a polished look.

@modamaan modamaan requested a review from a team as a code owner February 6, 2025 20:36
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

The changes enhance the comment section by introducing a tooltip on the avatar to display the creator’s name, replacing plain text with Markdown for comment formatting, and improving overall layout using flexbox and semantic HTML with a time element for the creation date. Comments are now displayed in reverse order, and the export signature for the component has been updated.

Changes

File(s) Change Summary
src/components/.../ResourceCommentSection.tsx - Added a tooltip feature in the Comment component (wraps Avatar with TooltipComponent).
- Replaced plain text with Markdown component for comment formatting.
- Modified layout with flexbox for improved alignment and styling.
- Rendered created_date using a semantic time element.
- Comments now display in reverse order.
- Updated export signature for Comment.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as Comment Component
    participant T as TooltipComponent
    U->>C: Hover over Avatar
    C->>T: Trigger tooltip with creator name
    T-->>U: Display tooltip
Loading

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a rabbit hopping through lines of code,
Where tooltips reveal names on the avatar's abode.
Markdown now sings in each comment displayed,
Flexbox alignment in a stylish parade.
Hopping with joy, our UI's a brighter mode! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e640ead and 9054b07.

📒 Files selected for processing (1)
  • src/components/Resource/ResourceCommentSection.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Resource/ResourceCommentSection.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@modamaan modamaan marked this pull request as draft February 6, 2025 20:36
Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 9054b07
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67b3617696351800089e2cb8
😎 Deploy Preview https://deploy-preview-10458.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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 (2)
src/components/Resource/ResourceCommentSection.tsx (2)

146-160: Consider extracting the tooltip implementation into a reusable component.

The tooltip implementation could be extracted into a reusable component to promote DRY principles and improve maintainability.

Here's a suggested implementation:

// components/Common/TooltipAvatar.tsx
interface TooltipAvatarProps {
  name: string;
  className?: string;
}

export const TooltipAvatar = ({ name, className }: TooltipAvatarProps) => (
  <TooltipProvider>
    <Tooltip>
      <TooltipTrigger asChild>
        <div className="flex">
          <Avatar
            name={name}
            className={className}
          />
        </div>
      </TooltipTrigger>
      <TooltipContent>
        <p>{formatName(name)}</p>
      </TooltipContent>
    </Tooltip>
  </TooltipProvider>
);

Then simplify the usage in the Comment component:

-      <TooltipProvider>
-        <Tooltip>
-          <TooltipTrigger asChild>
-            <div className="flex">
-              <Avatar
-                name={`${created_by.first_name} ${created_by.last_name}`}
-                className="w-8 h-8 rounded-full object-cover"
-              />
-            </div>
-          </TooltipTrigger>
-          <TooltipContent>
-            <p>{formatName(created_by)}</p>
-          </TooltipContent>
-        </Tooltip>
-      </TooltipProvider>
+      <TooltipAvatar
+        name={`${created_by.first_name} ${created_by.last_name}`}
+        className="w-8 h-8 rounded-full object-cover"
+      />

140-143: Consider extracting animation classes to a constant.

The animation classes could be moved to a constant to ensure consistency across the application and make updates easier to manage.

// constants/animations.ts
export const FADE_IN_ANIMATION = 'animate-in fade-in-0 slide-in-from-bottom-4';

// Then in the component:
className={cn(
  "flex w-full mb-4",
  FADE_IN_ANIMATION,
  "justify-start"
)}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4e67a5 and 1d6cded.

📒 Files selected for processing (1)
  • src/components/Resource/ResourceCommentSection.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (2)
src/components/Resource/ResourceCommentSection.tsx (2)

11-16: LGTM! Well-organized imports.

The new imports for tooltips and formatting utilities align well with the UI enhancement objectives.

Also applies to: 27-27


167-174: Great use of semantic HTML and accessibility!

The <time> element with proper dateTime and title attributes improves accessibility and provides better user experience.

@modamaan modamaan marked this pull request as ready for review February 7, 2025 19:04
Copy link
Contributor Author

@modamaan modamaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self reviewed
comment order updated, latest comment should be first

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 (1)
src/components/Resource/ResourceCommentSection.tsx (1)

148-162: Enhance tooltip accessibility.

While the tooltip implementation looks good, consider adding an aria-label to improve accessibility.

-          <TooltipTrigger asChild>
+          <TooltipTrigger asChild aria-label={`View ${formatName(created_by)}'s full name`}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d6cded and ad38525.

📒 Files selected for processing (1)
  • src/components/Resource/ResourceCommentSection.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Resource/ResourceCommentSection.tsx (3)

11-16: LGTM! Well-structured imports for UI enhancements.

The new imports for Tooltip components and formatting utilities align well with the UI enhancement objectives.

Also applies to: 27-27


100-107: LGTM! Improved comment ordering.

The reverse ordering ensures newest comments appear first, improving user experience. The implementation maintains proper React list rendering practices with unique keys.


172-178: LGTM! Excellent timestamp implementation.

Great use of the semantic time element with both relative and absolute timestamps. The implementation follows accessibility best practices by providing machine-readable datetime attribute and human-friendly display.

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 (1)
src/components/Resource/ResourceCommentSection.tsx (1)

101-108: Optimize comment ordering performance.

Creating a new reversed array on every render using slice().reverse() is inefficient. Consider reversing the order at the data source or storing the reversed array.

- {resourceComments?.results
-   ?.slice()
-   .reverse()
-   .map((comment) => (
+ {[...(resourceComments?.results || [])]
+   .reverse()
+   .map((comment) => (

Alternatively, consider adding a query parameter to fetch comments in reverse order from the API.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad38525 and 044a345.

📒 Files selected for processing (1)
  • src/components/Resource/ResourceCommentSection.tsx (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: Lint Code Base
src/components/Resource/ResourceCommentSection.tsx

[error] 1-1: Unresolved import: react-markdown.

🪛 GitHub Actions: Cypress Tests
src/components/Resource/ResourceCommentSection.tsx

[error] 1-1: Rollup failed to resolve import 'react-markdown'. This is most likely unintended because it can break your application at runtime. If you do want to externalize this module, explicitly add it to build.rollupOptions.external.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (3)
src/components/Resource/ResourceCommentSection.tsx (3)

171-173: LGTM! ReactMarkdown implementation.

Great job implementing ReactMarkdown for comment rendering, which addresses the previous review feedback.


149-163: LGTM! Enhanced user experience with tooltip.

The tooltip implementation on the avatar provides better user experience by showing the full name on hover.


175-181: LGTM! Improved date display with semantic HTML.

Good use of the semantic time element with both machine-readable dateTime and human-readable relative time.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 044a345 and ce9618b.

📒 Files selected for processing (1)
  • package.json (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: Lint Code Base
package.json

[error] 1-1: npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.

🪛 GitHub Actions: Cypress Tests
package.json

[error] 1-1: npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
package.json (1)

214-215: Formatting: Trailing Newline Added.
The addition of a newline at the end of the file conforms to best practices for file formatting.

@modamaan
Copy link
Contributor Author

modamaan commented Feb 9, 2025

@rithviknishad should I push package.json and lock file

@rithviknishad
Copy link
Member

we don't need any new packages. we already have a markdown component

@rithviknishad
Copy link
Member

https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/markdown.tsx

@modamaan
Copy link
Contributor Author

modamaan commented Feb 9, 2025

@rithviknishad i removed the package.json and lock.json file, now it shows cypress issue. can you help me resolve it?

@modamaan
Copy link
Contributor Author

Screenshot 2025-02-12 002853

@nihal467
Copy link
Member

LGTM

@rithviknishad rithviknishad merged commit 723c366 into ohcnetwork:develop Feb 18, 2025
15 checks passed
Copy link

@modamaan Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign Comment Section User Icon and Style for Improved UI
4 participants