Skip to content

Commit 15c719c

Browse files
committed
refactor: replace tooltip in compare plans
1 parent a76c942 commit 15c719c

File tree

2 files changed

+53
-59
lines changed

2 files changed

+53
-59
lines changed

components/pricing/compare-plans.tsx

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import { PlansRow } from "@/types";
2-
import { CircleCheck, CircleHelp } from "lucide-react";
2+
import { CircleCheck, Info } from "lucide-react";
33

44
import { comparePlans, plansColumns } from "@/config/subscriptions";
55
import {
6-
Tooltip,
7-
TooltipContent,
8-
TooltipPortal,
9-
TooltipProvider,
10-
TooltipTrigger,
11-
} from "@/components/ui/tooltip";
6+
Popover,
7+
PopoverContent,
8+
PopoverTrigger,
9+
} from "@/components/ui/popover";
1210
import { HeaderSection } from "@/components/shared/header-section";
1311
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
1412

1513
export function ComparePlans() {
1614
const renderCell = (value: string | boolean | null) => {
1715
if (value === null) return "—";
1816
if (typeof value === "boolean")
19-
return value ? <CircleCheck className="mx-auto size-6" /> : "—";
17+
return value ? <CircleCheck className="mx-auto size-[22px]" /> : "—";
2018
return value;
2119
};
2220

@@ -28,59 +26,57 @@ export function ComparePlans() {
2826
subtitle="Find the perfect plan tailored for your business needs!"
2927
/>
3028

31-
<TooltipProvider delayDuration={200} skipDelayDuration={0}>
32-
<div className="my-10 overflow-x-scroll max-lg:mx-[-0.8rem] md:overflow-x-visible">
33-
<table className="w-full table-fixed">
34-
<thead>
35-
<tr className="divide-x divide-border border">
36-
<th className="sticky left-0 z-10 w-40 bg-accent p-5 md:w-1/4 lg:top-14"></th>
29+
<div className="my-10 overflow-x-scroll max-lg:mx-[-0.8rem] md:overflow-x-visible">
30+
<table className="w-full table-fixed">
31+
<thead>
32+
<tr className="divide-x divide-border border">
33+
<th className="sticky left-0 z-20 w-40 bg-accent p-5 md:w-1/4 lg:top-14"></th>
34+
{plansColumns.map((col) => (
35+
<th
36+
key={col}
37+
className="sticky z-10 w-40 bg-accent p-5 font-heading text-xl capitalize tracking-wide md:w-auto lg:top-14 lg:text-2xl"
38+
>
39+
{col}
40+
</th>
41+
))}
42+
</tr>
43+
</thead>
44+
<tbody className="divide-x divide-border border">
45+
{comparePlans.map((row: PlansRow, index: number) => (
46+
<tr key={index} className="divide-x divide-border border">
47+
<td
48+
data-tip={row.tooltip ? row.tooltip : ""}
49+
className="sticky left-0 bg-accent md:bg-transparent"
50+
>
51+
<div className="flex items-center justify-between space-x-2 p-4">
52+
<span className="text-[15px] font-medium lg:text-base">
53+
{row.feature}
54+
</span>
55+
{row.tooltip && (
56+
<Popover>
57+
<PopoverTrigger className="rounded p-1 hover:bg-muted">
58+
<Info className="size-[18px] text-muted-foreground" />
59+
</PopoverTrigger>
60+
<PopoverContent className="max-w-80 p-3 text-sm">
61+
{row.tooltip}
62+
</PopoverContent>
63+
</Popover>
64+
)}
65+
</div>
66+
</td>
3767
{plansColumns.map((col) => (
38-
<th
68+
<td
3969
key={col}
40-
className="sticky z-10 w-40 bg-accent p-5 font-heading text-xl capitalize tracking-wide md:w-auto lg:top-14 lg:text-2xl"
70+
className="p-4 text-center text-[15px] text-muted-foreground lg:text-base"
4171
>
42-
{col}
43-
</th>
72+
{renderCell(row[col])}
73+
</td>
4474
))}
4575
</tr>
46-
</thead>
47-
<tbody className="divide-x divide-border border">
48-
{comparePlans.map((row: PlansRow, index: number) => (
49-
<tr key={index} className="divide-x divide-border border">
50-
<td
51-
data-tip={row.tooltip ? row.tooltip : ""}
52-
className="sticky left-0 bg-accent md:bg-transparent"
53-
>
54-
<div className="flex items-center justify-between space-x-2 p-4 font-medium">
55-
<span>{row.feature}</span>
56-
{row.tooltip && (
57-
<Tooltip>
58-
<TooltipTrigger>
59-
<CircleHelp className="size-[18px] text-muted-foreground" />
60-
</TooltipTrigger>
61-
<TooltipPortal>
62-
<TooltipContent className="max-w-80">
63-
<p>{row.tooltip}</p>
64-
</TooltipContent>
65-
</TooltipPortal>
66-
</Tooltip>
67-
)}
68-
</div>
69-
</td>
70-
{plansColumns.map((col) => (
71-
<td
72-
key={col}
73-
className="p-4 text-center text-muted-foreground"
74-
>
75-
{renderCell(row[col])}
76-
</td>
77-
))}
78-
</tr>
79-
))}
80-
</tbody>
81-
</table>
82-
</div>
83-
</TooltipProvider>
76+
))}
77+
</tbody>
78+
</table>
79+
</div>
8480
</MaxWidthWrapper>
8581
);
8682
}

config/subscriptions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const plansColumns = [
7979

8080
export const comparePlans: PlansRow[] = [
8181
{
82-
feature: "Access to Basic Analytics",
82+
feature: "Access to Analytics",
8383
starter: true,
8484
pro: true,
8585
business: true,
@@ -100,7 +100,6 @@ export const comparePlans: PlansRow[] = [
100100
pro: "Email",
101101
business: "Email & Chat",
102102
enterprise: "24/7 Support",
103-
tooltip: "Higher plans provide more extensive support options.",
104103
},
105104
{
106105
feature: "Advanced Reporting",
@@ -125,7 +124,6 @@ export const comparePlans: PlansRow[] = [
125124
pro: "Standard",
126125
business: "Enhanced",
127126
enterprise: "Full",
128-
tooltip: "API access varies by plan level.",
129127
},
130128
{
131129
feature: "Monthly Webinars",

0 commit comments

Comments
 (0)