-
Notifications
You must be signed in to change notification settings - Fork 649
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: apply button variants for consistent styling #10589
refactor: apply button variants for consistent styling #10589
Conversation
WalkthroughThis pull request modifies two components by changing the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (2)
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
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Patient/LinkDepartmentsSheet.tsx
(2 hunks)src/components/Questionnaire/QuestionnaireForm.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
@@ -4,7 +4,7 @@ import { Building, Loader2, Trash2 } from "lucide-react"; | |||
import { useState } from "react"; | |||
import { toast } from "sonner"; | |||
|
|||
import { Button } from "@/components/ui/button"; | |||
import { Button, buttonVariants } from "@/components/ui/button"; |
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.
Fix incorrect usage of buttonVariants
.
The current implementation has several issues:
buttonVariants
is meant for button elements, not icons- Applying it to the icon within a button that already has a variant creates conflicting styles
Apply this diff to fix the styling:
-<Button
- variant="ghost"
- size="icon"
- onClick={() => removeOrganization(org.id)}
- disabled={isRemoving}
->
- {isRemoving ? (
- <Loader2 className="h-4 w-4 animate-spin" />
- ) : (
- <Trash2
- className={buttonVariants({ variant: "destructive" })}
- />
- )}
-</Button>
+<Button
+ variant="destructive"
+ size="icon"
+ onClick={() => removeOrganization(org.id)}
+ disabled={isRemoving}
+>
+ {isRemoving ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
+ ) : (
+ <Trash2 className="h-4 w-4" />
+ )}
+</Button>
Also applies to: 227-229
@@ -9,7 +9,7 @@ import { cn } from "@/lib/utils"; | |||
import CareIcon from "@/CAREUI/icons/CareIcon"; | |||
|
|||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; | |||
import { Button } from "@/components/ui/button"; | |||
import { Button, buttonVariants } from "@/components/ui/button"; |
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.
Fix conflicting button variants.
The button has conflicting style variants:
variant="ghost"
propbuttonVariants({ variant: "destructive" })
in className
Apply this diff to fix the styling:
<Button
type="button"
- variant="ghost"
+ variant="destructive"
size="sm"
onClick={() => {
setQuestionnaireForms((prev) =>
prev.filter(
(f) => f.questionnaire.id !== form.questionnaire.id,
),
);
}}
disabled={isPending}
- className={buttonVariants({ variant: "destructive" })}
>
<CareIcon icon="l-times-circle" />
<span>Remove</span>
</Button>
Also applies to: 392-409
This was purposefully kept not destructive as this button is not the primary focus on these pages. This feels there is extra emphasis on the page. |
Proposed Changes
Implementing changes based on the comments in the closed PR (#10574)
Screenshot of the changes: (Clear indication of the "Remove" button)
@ohcnetwork/care-fe-code-reviewers
Summary by CodeRabbit