Skip to content

Commit 1f42ad2

Browse files
committed
[Dashboard] migrate SelectOption to shadcn (#7194)
Migrated the `SelectOption` component in the dashboard batch upload flow to use shadcn/ui primitives and Tailwind classes. - Replaced Chakra `Tooltip`, `Flex`, and `Radio` usage with `ToolTipLabel` and Tailwind markup - Switched to shadcn/ui `Card` - Removed dependency on Chakra typography components - Updated component props to extend HTML attributes Fixes migration step towards removing Chakra. <!-- start pr-codex --> --- ## PR-Codex overview This PR updates the `SelectOption` component to improve its structure and styling. It replaces the `Tooltip` from `@chakra-ui/react` with a custom `ToolTipLabel`, modifies the layout and styling, and enhances the handling of props. ### Detailed summary - Changed `SelectOptionProps` to extend `React.HTMLAttributes<HTMLDivElement>`. - Replaced `Tooltip` with `ToolTipLabel`. - Updated the card styling and structure. - Modified the layout for `Radio` to a custom implementation. - Adjusted class names for better styling consistency. - Changed the rendering of `name` and `description` to use HTML elements directly. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the selection option component with custom UI elements and Tailwind CSS styling, removing dependencies on Chakra UI and previous component libraries. - Improved accessibility and styling for tooltips, cards, and selection indicators. - Maintained original functionality and interactions with a refreshed look and feel. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0299034 commit 1f42ad2

File tree

1 file changed

+38
-60
lines changed

1 file changed

+38
-60
lines changed
Lines changed: 38 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { Card } from "@/components/ui/card";
2+
import { ToolTipLabel } from "@/components/ui/tooltip";
13
import { cn } from "@/lib/utils";
2-
import { Flex, Radio, Tooltip } from "@chakra-ui/react";
34
import { InfoIcon } from "lucide-react";
45
import type { JSX, MouseEventHandler } from "react";
5-
import { Card, Heading, Text } from "tw-components";
66

7-
interface SelectOptionProps {
7+
interface SelectOptionProps extends React.HTMLAttributes<HTMLDivElement> {
88
name: string;
99
description?: string;
1010
isActive?: boolean;
@@ -24,84 +24,62 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
2424
disabledText,
2525
infoText,
2626
className,
27-
...stackProps
27+
...divProps
2828
}) => {
2929
return (
30-
<Tooltip
30+
<ToolTipLabel
3131
label={
32-
disabled && (
33-
<Card bgColor="backgroundHighlight">
34-
<Text>{disabledText}</Text>
32+
disabled ? (
33+
<Card className="bg-muted p-3">
34+
<p className="text-sm">{disabledText}</p>
3535
</Card>
36-
)
36+
) : undefined
3737
}
38-
bg="transparent"
39-
boxShadow="none"
40-
p={0}
41-
shouldWrapChildren
4238
>
4339
<Card
4440
className={cn(
45-
"flex flex-col gap-2 rounded-md p-5",
41+
"flex flex-col gap-2 rounded-md p-5 md:w-[350px]",
4642
disabled
47-
? "pointer-events-none cursor-not-allowed"
43+
? "pointer-events-none cursor-not-allowed bg-muted"
4844
: "cursor-pointer",
45+
isActive && "border-primary",
4946
className,
5047
)}
51-
width={{ base: "inherit", md: "350px" }}
52-
borderColor={isActive ? "primary.500" : undefined}
53-
bgColor={disabled ? "backgroundHighlight" : undefined}
54-
{...stackProps}
5548
onClick={onClick}
49+
{...divProps}
5650
>
57-
<Flex flexDirection="row" justifyContent="space-between">
58-
<div className="flex flex-row items-start gap-0">
59-
<Radio
60-
cursor="pointer"
61-
size="lg"
62-
colorScheme="primary"
63-
mt={0.5}
64-
mr={2.5}
65-
isChecked={isActive}
66-
isDisabled={disabled}
67-
/>
51+
<div className="flex flex-row justify-between">
52+
<div className="flex flex-row items-start">
53+
<div className="mt-0.5 mr-2.5 flex h-4 w-4 items-center justify-center rounded-full border border-inverted text-inverted">
54+
{isActive && <div className="h-2 w-2 rounded-full bg-inverted" />}
55+
</div>
6856
<div className="ml-4 flex flex-col gap-2 self-start">
69-
<Heading
70-
size="subtitle.sm"
71-
fontWeight="700"
72-
mb={0}
73-
color={disabled ? "gray.600" : "inherit"}
57+
<h4
58+
className={cn(
59+
"font-semibold text-sm",
60+
disabled && "text-gray-600",
61+
)}
7462
>
7563
{name}
76-
</Heading>
77-
{description && (
78-
<Text size="body.sm" mt="4px">
79-
{description}
80-
</Text>
81-
)}
64+
</h4>
65+
{description && <p className="mt-1 text-sm">{description}</p>}
8266
</div>
8367
</div>
8468
{infoText && (
85-
<div className="flex flex-row">
86-
<Tooltip
87-
bg="transparent"
88-
boxShadow="none"
89-
p={0}
90-
shouldWrapChildren
91-
label={
92-
<Card bgColor="backgroundHighlight">
93-
<Text>{infoText}</Text>
94-
</Card>
95-
}
96-
>
97-
<Flex alignItems="center">
98-
<InfoIcon className="size-4" />
99-
</Flex>
100-
</Tooltip>
101-
</div>
69+
<ToolTipLabel
70+
label={
71+
<Card className="bg-muted p-3">
72+
<p className="text-sm">{infoText}</p>
73+
</Card>
74+
}
75+
>
76+
<div className="flex items-center">
77+
<InfoIcon className="size-4" />
78+
</div>
79+
</ToolTipLabel>
10280
)}
103-
</Flex>
81+
</div>
10482
</Card>
105-
</Tooltip>
83+
</ToolTipLabel>
10684
);
10785
};

0 commit comments

Comments
 (0)