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

Use shadcn Tooltip Components across FacilityCard #9317

Merged

Conversation

rajku-dev
Copy link
Contributor

@rajku-dev rajku-dev commented Dec 6, 2024

Proposed Changes

@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

UI changes

Summary by CodeRabbit

  • New Features

    • Enhanced "Notify" and "View Facility" buttons with updated designs and improved tooltip functionality for better user experience.
    • Introduced localization for the "Notify" button to support multiple languages.
  • Bug Fixes

    • Corrected the button text from "view_faciliy" to "view_facility" for consistency across multiple languages.
    • Fixed typographical errors in localization keys for multiple languages.

@rajku-dev rajku-dev requested a review from a team as a code owner December 6, 2024 12:42
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Warning

Rate limit exceeded

@nihal467 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 12 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 8123404 and 827b1ca.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (4 hunks)

Walkthrough

The changes in FacilityCard.tsx involve replacing the ButtonV2 component with a new Button component from a UI library, along with the addition of TooltipComponent for enhanced user interaction. The button properties have been updated to conform to the new API, and the button text for "View Facility" has been corrected. Additionally, new key-value pairs for notifications have been added to the localization files for English, Hindi, Kannada, Malayalam, and Tamil.

Changes

File Change Summary
src/components/Facility/FacilityCard.tsx Replaced ButtonV2 with Button, updated button properties, added tooltips for accessibility, and corrected button label from "view_faciliy" to "view_facility".
public/locale/en.json Added new key-value pair "notify": "Notify" to the localization data.
public/locale/hi.json Corrected key from "view_faciliy" to "view_facility".
public/locale/kn.json Corrected key from "view_faciliy" to "view_facility".
public/locale/ml.json Corrected key from "view_faciliy" to "view_facility".
public/locale/ta.json Corrected key from "view_faciliy" to "view_facility".

Assessment against linked issues

Objective Addressed Explanation
Adding a tooltip for 'Notify' and 'View Facility' buttons on mobile view (#9315)

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

In the land of buttons bright,
Tooltips now bring pure delight.
For "Notify" and "View" they say,
Helping users find their way.
On mobile screens, they shine so clear,
A joyful change, let's give a cheer! 🐇✨


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.

@rajku-dev rajku-dev changed the title Add tooltip on buttons on Facilty Cards for small viewports Add tooltip for buttons on Facilty Cards for small viewports Dec 6, 2024
Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 827b1ca
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6769443a60544000083389f4
😎 Deploy Preview https://deploy-preview-9317--care-ohc.netlify.app
📱 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: 2

🧹 Outside diff range and nitpick comments (1)
src/components/Facility/FacilityCard.tsx (1)

229-236: Add ARIA attributes for better accessibility.

The tooltip implementation looks good and aligns with the PR objectives. However, consider enhancing accessibility by adding ARIA attributes.

 <ButtonV2
   id="facility-notify"
   ghost
   border
-  className="h-[38px] tooltip"
+  className="h-[38px] tooltip"
+  aria-label="Notify facility"
+  role="button"
   onClick={(_) => setNotifyModalFor(facility.id)}
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ee725b0 and 5e0c835.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (1 hunks)

src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
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 and nitpick comments (3)
src/components/Facility/FacilityCard.tsx (3)

2-2: Fix import formatting

Add a space after the comma in the raviger import.

-import { Link,navigate } from "raviger";
+import { Link, navigate } from "raviger";
🧰 Tools
🪛 eslint

[error] 2-2: Insert ·

(prettier/prettier)


226-239: Improve Button component implementation

  1. The variant prop syntax is inconsistent with other props. Remove curly braces.
  2. The role="button" is unnecessary as the Button component already provides this semantically.
 <Button
   id="facility-notify"
-  variant={"outline"}
+  variant="outline"
   className="h-[38px] tooltip"
   onClick={(_) => setNotifyModalFor(facility.id)}
   aria-label={t("notify")}
-  role="button"
 >

Apply similar changes to the other Button components.

Also applies to: 241-256, 257-266


226-239: Enhance tooltip accessibility and consistency

The tooltip implementation could be improved:

  1. Make aria-label more descriptive than just "notify"
  2. Consider adding tooltips to the View CNS button for consistency
 <Button
   id="facility-notify"
   variant="outline"
   className="h-[38px] tooltip"
   onClick={(_) => setNotifyModalFor(facility.id)}
-  aria-label={t("notify")}
+  aria-label={t("notify_facility", { facility: facility.name })}
 >

Would you like me to help implement tooltips for the View CNS button as well?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 72b3bff and a796de0.

📒 Files selected for processing (2)
  • public/locale/en.json (2 hunks)
  • src/components/Facility/FacilityCard.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/locale/en.json
🧰 Additional context used
🪛 eslint
src/components/Facility/FacilityCard.tsx

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)


[error] 258-258: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)

🔇 Additional comments (1)
src/components/Facility/FacilityCard.tsx (1)

226-266: Verify tooltip visibility on small viewports

The implementation aligns with the PR objectives for adding tooltips on screens < 768px. Let's verify the tooltip visibility and styling:

✅ Verification successful

Tooltip implementation is consistent and properly accessible

The implementation in FacilityCard.tsx follows the established tooltip pattern across the codebase:

  • Tooltips are consistently implemented using tooltip and tooltip-text tooltip-top classes
  • Responsive visibility is properly handled with sm:hidden and md:hidden classes
  • Accessibility is maintained with aria-label attributes on buttons
  • The pattern matches other components like AssetsList, DoctorVideoSlideover, and MedicineAdministrationSheet
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent tooltip implementation across components

# Check for tooltip class usage
echo "Checking tooltip class implementation..."
rg "tooltip-text tooltip-top" --type tsx

# Check for responsive classes
echo "Checking responsive visibility..."
rg "(sm|md):hidden.*tooltip" --type tsx

# Check for aria-label usage
echo "Checking accessibility attributes..."
rg "aria-label=.*" --type tsx

Length of output: 451


Script:

#!/bin/bash
# Description: Check for consistent tooltip implementation across components

# Check for tooltip class usage
echo "Checking tooltip class implementation..."
rg "tooltip-text tooltip-top"

# Check for responsive classes
echo "Checking responsive visibility..."
rg "(sm|md):hidden.*tooltip"

# Check for aria-label usage in Button components
echo "Checking accessibility attributes..."
rg "aria-label.*tooltip"

# Check for other tooltip implementations
echo "Checking other tooltip patterns..."
rg "className=.*tooltip"

Length of output: 15712

🧰 Tools
🪛 eslint

[error] 258-258: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)

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

🧹 Outside diff range and nitpick comments (2)
src/components/Facility/FacilityCard.tsx (2)

2-5: Clean up import statements

The import statements need cleanup:

  1. Fix spacing after raviger import
  2. Optimize ButtonV2 import since we only use Cancel and Submit
-import { Link,navigate } from "raviger";
+import { Link, navigate } from "raviger";
-import ButtonV2, { Cancel, Submit } from "@/components/Common/ButtonV2";
+import { Cancel, Submit } from "@/components/Common/ButtonV2";
🧰 Tools
🪛 eslint

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)


231-232: Remove redundant button role attribute

The role="button" attribute is redundant when using the Button component as it already has the semantic meaning of a button.

-aria-label={t("notify")}
-role="button"
+aria-label={t("notify")}

Also applies to: 246-247, 261-262

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a796de0 and abcdbf9.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (2 hunks)
🧰 Additional context used
🪛 eslint
src/components/Facility/FacilityCard.tsx

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)


[error] 258-258: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)

🔇 Additional comments (1)
src/components/Facility/FacilityCard.tsx (1)

235-238: LGTM: Tooltip implementation meets requirements

The tooltip implementation correctly addresses the PR objective by:

  1. Showing tooltips only on mobile view (below 768px)
  2. Using proper translations for button labels
  3. Maintaining accessibility with aria-labels

Also applies to: 250-254

src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
@rajku-dev
Copy link
Contributor Author

@Jacobjeevan UI after changes

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 and nitpick comments (3)
src/components/Facility/FacilityCard.tsx (3)

2-2: Fix import formatting

Minor formatting issues in the import statements need to be addressed.

-import { Link,navigate } from "raviger";
+import { Link, navigate } from "raviger";

-import { Button } from "@/components/ui/button";
+import { Button } from "@/components/ui/button";

Also applies to: 5-5

🧰 Tools
🪛 eslint

[error] 2-2: Insert ·

(prettier/prettier)


226-241: Fix Button variant syntax and approve accessibility improvements

The accessibility improvements with aria-label and tooltips are good additions. However, the button variant syntax needs to be updated.

 <Button
   id="facility-notify"
-  variant={"outline_primary"}
+  variant="outline-primary"
   className="h-[38px] tooltip"
   onClick={(_) => setNotifyModalFor(facility.id)}
   aria-label={t("notify")}
   role="button"
 >
🧰 Tools
🪛 eslint

[error] 235-237: Replace ⏎··························{t("notify")}⏎························ with {t("notify")}

(prettier/prettier)


243-268: Fix Button variant syntax for remaining buttons

The accessibility improvements are good, but the variant syntax needs to be updated for consistency.

 <Button
   onClick={() => navigate(`/facility/${facility.id}`)}
   id="facility-details"
-  variant={"outline_primary"}
+  variant="outline-primary"
   className="tooltip h-[38px]"
   aria-label={t("view_facility")}
   role="button"
 >

 <Button
   onClick={() => navigate(`/patients?facility=${facility.id}`)}
   id="facility-patients"
-  variant={"outline_primary"}
+  variant="outline-primary"
   aria-label={t("view_patients")}
   role="button"
 >
🧰 Tools
🪛 eslint

[error] 260-260: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)


[error] 267-267: Delete ··

(prettier/prettier)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between abcdbf9 and 9eed329.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (2 hunks)
🧰 Additional context used
🪛 eslint
src/components/Facility/FacilityCard.tsx

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)


[error] 235-237: Replace ⏎··························{t("notify")}⏎························ with {t("notify")}

(prettier/prettier)


[error] 260-260: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)


[error] 267-267: Delete ··

(prettier/prettier)

🔇 Additional comments (1)
src/components/Facility/FacilityCard.tsx (1)

226-268: Implementation successfully meets PR objectives

The changes effectively address the PR objectives by:

  1. Adding tooltips for buttons on small viewports
  2. Enhancing accessibility with aria-labels
  3. Successfully migrating to the new Button component

The implementation is well-thought-out and includes additional accessibility improvements beyond the original requirements.

🧰 Tools
🪛 eslint

[error] 235-237: Replace ⏎··························{t("notify")}⏎························ with {t("notify")}

(prettier/prettier)


[error] 260-260: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)


[error] 267-267: Delete ··

(prettier/prettier)

Copy link
Contributor

@Jacobjeevan Jacobjeevan left a comment

Choose a reason for hiding this comment

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

There's one more ButtonV2 in the file, go ahead and replace that as well (and remove the ButtonV2 import).

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 and nitpick comments (1)
src/components/Facility/FacilityCard.tsx (1)

2-5: Fix import formatting

The imports need proper spacing and ordering.

-import { Link,navigate } from "raviger";
+import { Link, navigate } from "raviger";
+
 import { useTranslation } from "react-i18next";
-import { Button } from "@/components/ui/button";
 
+import { Button } from "@/components/ui/button";
🧰 Tools
🪛 eslint

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9eed329 and 27c9a40.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (3 hunks)
🧰 Additional context used
🪛 eslint
src/components/Facility/FacilityCard.tsx

[error] 2-2: Insert ·

(prettier/prettier)


[error] 4-5: Delete ";⏎import·{·Button·}·from·"@/components/ui/button

(prettier/prettier)


[error] 8-8: Insert on";⏎⏎import·{·Button·}·from·"@/components/ui/butt

(prettier/prettier)


[error] 234-236: Replace ⏎··························{t("notify")}⏎························ with {t("notify")}

(prettier/prettier)


[error] 259-259: Replace ·navigate(/patients?facility=${facility.id}) with ⏎························navigate(/patients?facility=${facility.id})⏎······················

(prettier/prettier)


[error] 266-266: Delete ··

(prettier/prettier)

🔇 Additional comments (2)
src/components/Facility/FacilityCard.tsx (2)

116-127: Fix Button variant syntax

The variant prop should use a hyphen instead of an underscore, following the component's convention.

-variant={"outline_primary"}
+variant="outline-primary"

225-240: LGTM! Great accessibility improvements

The changes effectively address the PR objectives by:

  • Adding tooltips for small viewports
  • Including proper aria-labels and roles
  • Maintaining consistent translations

However, there's one minor improvement needed:

-variant={"outline_primary"}
+variant="outline-primary"

Also applies to: 242-257, 258-267

🧰 Tools
🪛 eslint

[error] 234-236: Replace ⏎··························{t("notify")}⏎························ with {t("notify")}

(prettier/prettier)

@rajku-dev rajku-dev requested a review from Jacobjeevan December 8, 2024 00:38
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

🧹 Outside diff range and nitpick comments (3)
src/components/Facility/FacilityCard.tsx (3)

226-239: Clean up onClick handler and fix variant syntax

Two minor improvements needed:

 <Button
   id="facility-notify"
-  variant={"outline_primary"}
+  variant="outline-primary"
   className="h-[38px] tooltip"
-  onClick={(_) => setNotifyModalFor(facility.id)}
+  onClick={() => setNotifyModalFor(facility.id)}
   aria-label={t("notify")}
   role="button"
 >

241-256: Fix variant syntax

The translation key fix looks good, but the variant syntax needs to be updated.

 <Button
   onClick={() => navigate(`/facility/${facility.id}`)}
   id="facility-details"
-  variant={"outline_primary"}
+  variant="outline-primary"
   className="tooltip h-[38px]"
   aria-label={t("view_facility")}
   role="button"
 >

257-268: Simplify onClick and fix variant syntax

The onClick handler can be simplified, and the variant syntax needs to be updated.

 <Button
-  onClick={() =>
-    navigate(`/patients?facility=${facility.id}`)
-  }
+  onClick={() => navigate(`/patients?facility=${facility.id}`)}
   id="facility-patients"
-  variant={"outline_primary"}
+  variant="outline-primary"
   aria-label={t("view_patients")}
   role="button"
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 27c9a40 and 6033772.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (3 hunks)
🔇 Additional comments (2)
src/components/Facility/FacilityCard.tsx (2)

2-2: LGTM: Import changes are correct

The imports have been properly updated to support the migration from ButtonV2 to Button component while maintaining the necessary Cancel and Submit components.

Also applies to: 9-10, 12-12


Line range hint 117-268: LGTM: Successfully implements tooltips and improves accessibility

The changes effectively address the PR objectives by:

  1. Adding tooltips for buttons on small viewports
  2. Improving accessibility with aria-labels and roles
  3. Successfully migrating to the new Button component

Comment on lines 117 to 128
<Button
id="view-cns-button"
href={`/facility/${facility.id}/cns`}
border
ghost
onClick={() => navigate(`/facility/${facility.id}/cns`)}
variant={"outline_primary"}
className="mt-2 sm:mt-0"
>
<CareIcon
icon="l-monitor-heart-rate"
className="text-lg"
/>
<span>{t("view_cns")}</span>
</ButtonV2>
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add accessibility attributes and fix variant syntax

The View CNS button should follow the same accessibility pattern as other buttons in the component.

 <Button
   id="view-cns-button"
   onClick={() => navigate(`/facility/${facility.id}/cns`)}
-  variant={"outline_primary"}
+  variant="outline-primary"
   className="mt-2 sm:mt-0"
+  aria-label={t("view_cns")}
+  role="button"
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
id="view-cns-button"
href={`/facility/${facility.id}/cns`}
border
ghost
onClick={() => navigate(`/facility/${facility.id}/cns`)}
variant={"outline_primary"}
className="mt-2 sm:mt-0"
>
<CareIcon
icon="l-monitor-heart-rate"
className="text-lg"
/>
<span>{t("view_cns")}</span>
</ButtonV2>
</Button>
<Button
id="view-cns-button"
onClick={() => navigate(`/facility/${facility.id}/cns`)}
variant="outline-primary"
className="mt-2 sm:mt-0"
aria-label={t("view_cns")}
role="button"
>
<CareIcon
icon="l-monitor-heart-rate"
className="text-lg"
/>
<span>{t("view_cns")}</span>
</Button>

@nihal467
Copy link
Member

LGTM

@rajku-dev
Copy link
Contributor Author

rajku-dev commented Dec 18, 2024

resolve conflicts

used TooltipComponent and eliminated the need for Tooltip, TooltipTrigger and TooltipContent for all tooltips

@rithviknishad rithviknishad added needs testing and removed Deploy-Failed Deplyment is not showing preview merge conflict pull requests with merge conflict tested labels Dec 18, 2024
@rajku-dev rajku-dev changed the title Add tooltip for buttons on Facilty Cards for small viewports use shadcn Tooltip Components across FacilityCard Dec 18, 2024
@rajku-dev rajku-dev changed the title use shadcn Tooltip Components across FacilityCard Use shadcn Tooltip Components across FacilityCard Dec 18, 2024
@rajku-dev
Copy link
Contributor Author

@rithviknishad, @Jacobjeevan, If there are any remaining changes to be made here, please let me know. Thank you!

@rithviknishad
Copy link
Member

@nihal467 would be doing the QA when it's marked for "needs testing" and once he gives us the "tested" label, we are good to merge

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

🧹 Nitpick comments (2)
src/components/Facility/FacilityCard.tsx (2)

9-13: Simplify imports by using the index barrel pattern

Consider consolidating the UI component imports to reduce import statements and improve maintainability.

-import { Button } from "@/components/ui/button";
-import { TooltipComponent, TooltipProvider } from "@/components/ui/tooltip";
+import { Button, TooltipComponent, TooltipProvider } from "@/components/ui";

107-107: Consolidate tooltip styling using Tailwind classes

The tooltip styling appears inconsistent across different tooltips in the file. Consider extracting common styles into a shared class.

-className="text-sm px-3 py-3 max-w-[300px]"
+className="tooltip-common-style"

Add this to your Tailwind CSS config:

.tooltip-common-style {
  @apply text-sm px-3 py-3 max-w-[300px];
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 65f9a29 and 8123404.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityCard.tsx (4 hunks)
🔇 Additional comments (2)
src/components/Facility/FacilityCard.tsx (2)

128-141: Fix variant syntax and improve accessibility

Previous review comments about fixing variant syntax and improving accessibility are still applicable.


239-307: Verify tooltip behavior on mobile devices

The PR objectives mention adding tooltips for screens < 768px. Let's verify the implementation meets this requirement.

✅ Verification successful

Let me gather more specific information about the tooltip implementation.


Based on the gathered information, I can now provide the final response:

Tooltip implementation correctly follows mobile-first design

The implementation correctly shows tooltips only on small screens (< 768px) and replaces them with inline text on larger screens through:

  • Tooltips have sm:hidden class, making them visible only on mobile
  • Button text has hidden sm:inline class, showing text directly on larger screens
  • This pattern is consistently applied across all three buttons (notify, view facility, view patients)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check tooltip visibility conditions in the codebase

# Check if tooltips are consistently shown only on small screens
echo "Checking tooltip visibility conditions..."
rg -A 2 "TooltipComponent" | rg "className.*sm:hidden"

# Check if there are any other tooltip implementations that might need similar updates
echo "Checking other tooltip implementations..."
rg -A 5 "tooltip.*className"

Length of output: 718


Script:

#!/bin/bash
# Check the TooltipComponent implementation and its usage
echo "Checking TooltipComponent implementation..."
ast-grep --pattern 'const TooltipComponent = $_'

# Check for sm:hidden and sm:inline patterns in the component
echo "Checking responsive patterns..."
rg "sm:(hidden|inline)" -B 2 -A 2

# Check if there are other similar card components with tooltips
echo "Checking other card components..."
fd "Card\.tsx$" --exec rg -l "TooltipComponent"

Length of output: 12395

Comment on lines 261 to 282
<TooltipProvider>
<TooltipComponent
content={t("view_facility")}
side="top"
className="sm:hidden text-sm px-3 py-3 max-w-[300px]"
>
<Button
id="facility-details"
variant={"outline_primary"}
className="tooltip h-[38px]"
aria-label={t("view_facility")}
asChild
>
<Link href={`/facility/${facility.id}`}>
<CareIcon icon="l-hospital" className="text-lg" />
<span className="hidden sm:inline">
{t("view_facility")}
</span>
</Link>
</Button>
</TooltipComponent>
</TooltipProvider>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consistent improvements needed for View Facility and View Patients buttons

Both buttons have similar issues that need to be addressed:

  1. Remove duplicate tooltip className
  2. Fix variant syntax
  3. Use consistent class naming for hidden text
// For both buttons:
-className="sm:hidden text-sm px-3 py-3 max-w-[300px]"
+className="tooltip-common-style"

-variant={"outline_primary"}
+variant="outline-primary"

-className="tooltip h-[38px]"
+className="h-[38px]"

-<span className="hidden sm:inline">
+<span className="hidden sm:inline-block">

Also applies to: 283-307

src/components/Facility/FacilityCard.tsx Outdated Show resolved Hide resolved
@nihal467
Copy link
Member

LGTM

@rithviknishad rithviknishad merged commit 650b196 into ohcnetwork:develop Dec 23, 2024
15 of 16 checks passed
Copy link

@rajku-dev 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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No Button Guidance on Facility Cards Below 768px Breakpoint
4 participants