|
1
|
import React from "react" |
|
2
|
import { CheckCircleSolid } from "@medusajs/icons" |
|
3
|
import { HeroPricingFields } from "../../../utils/types" |
|
4
|
import { getPricingButtonUrl } from "../../../utils/pricing" |
|
5
|
import { H3, Button } from "docs-ui" |
|
6
|
import clsx from "clsx" |
|
7
|
import slugify from "slugify" |
|
8
|
import Link from "next/link" |
|
9
|
|
|
10
|
interface HeroPricingProps { |
|
11
|
data: HeroPricingFields |
|
12
|
} |
|
13
|
|
|
14
|
const HeroPricing: React.FC<HeroPricingProps> = ({ data }) => { |
|
15
|
if (!data?.options) { |
|
16
|
return null |
|
17
|
} |
|
18
|
|
|
19
|
return ( |
|
20
|
<div className="relative w-full rounded shadow-elevation-card-rest dark:shadow-elevation-card-rest-dark"> |
|
21
|
{/* Header Row */} |
|
22
|
<div className="flex items-start justify-start"> |
|
23
|
{/* Main content area */} |
|
24
|
<div |
|
25
|
className="w-full grid gap-0" |
|
26
|
style={{ |
|
27
|
gridTemplateColumns: `repeat(${data.options.length}, minmax(0, 1fr))`, |
|
28
|
gridTemplateRows: "auto 1fr auto", |
|
29
|
}} |
|
30
|
> |
|
31
|
{data.options.map((option, index) => ( |
|
32
|
<React.Fragment key={option._key}> |
|
33
|
<div |
|
34
|
className={clsx( |
|
35
|
`p-1`, |
|
36
|
index !== data.options.length - 1 && |
|
37
|
"border-solid border-r border-medusa-border-base", |
|
38
|
index === data.options.length - 1 && |
|
39
|
"bg-medusa-bg-subtle rounded-tr" |
|
40
|
)} |
|
41
|
> |
|
42
|
<div className="flex flex-col w-full"> |
|
43
|
<div className="flex flex-col items-start justify-start w-full"> |
|
44
|
<div className="flex flex-col justify-end w-full"> |
|
45
|
<H3 |
|
46
|
className="!mb-0 txt-xlarge" |
|
47
|
id={slugify(option.title, { |
|
48
|
lower: true, |
|
49
|
})} |
|
50
|
> |
|
51
|
{option.title} |
|
52
|
</H3> |
|
53
|
</div> |
|
54
|
<div className="flex flex-col justify-end w-full"> |
|
55
|
<p className="txt-xlarge text-medusa-fg-subtle"> |
|
56
|
{option.subtitle} |
|
57
|
</p> |
|
58
|
</div> |
|
59
|
</div> |
|
60
|
</div> |
|
61
|
</div> |
|
62
|
</React.Fragment> |
|
63
|
))} |
|
64
|
</div> |
|
65
|
</div> |
|
66
|
|
|
67
|
{/* Features and Buttons Row */} |
|
68
|
<div |
|
69
|
className="w-full grid gap-0 overflow-hidden" |
|
70
|
style={{ |
|
71
|
gridTemplateColumns: `repeat(${data.options.length}, minmax(0, 1fr))`, |
|
72
|
gridTemplateRows: "auto 1fr auto", |
|
73
|
}} |
|
74
|
> |
|
75
|
{/* Description row - all descriptions at same height */} |
|
76
|
{data.options.map((option, index) => ( |
|
77
|
<div |
|
78
|
key={`description-${option._key}`} |
|
79
|
className={clsx( |
|
80
|
`p-1 flex items-start border-b border-medusa-border-base`, |
|
81
|
index !== data.options.length - 1 && |
|
82
|
"border-solid border-r border-medusa-border-base", |
|
83
|
index === data.options.length - 1 && "bg-medusa-bg-subtle" |
|
84
|
)} |
|
85
|
> |
|
86
|
<div className="w-full flex items-start"> |
|
87
|
{option.description && ( |
|
88
|
<p className="text-medusa-fg-base txt-small-plus text-balance"> |
|
89
|
{option.description} |
|
90
|
</p> |
|
91
|
)} |
|
92
|
</div> |
|
93
|
</div> |
|
94
|
))} |
|
95
|
|
|
96
|
{/* Features row - all features sections at same level */} |
|
97
|
{data.options.map((option, index) => ( |
|
98
|
<div |
|
99
|
key={`features-${option._key}`} |
|
100
|
className={clsx( |
|
101
|
`p-1 flex flex-col gap-0.75`, |
|
102
|
index !== data.options.length - 1 && |
|
103
|
"border-solid border-r border-medusa-border-base", |
|
104
|
index === data.options.length - 1 && "bg-medusa-bg-subtle" |
|
105
|
)} |
|
106
|
> |
|
107
|
{option.pre_features && ( |
|
108
|
<div className="flex items-center w-full"> |
|
109
|
<span className="text-medusa-fg-base txt-small-plus"> |
|
110
|
{option.pre_features} |
|
111
|
</span> |
|
112
|
</div> |
|
113
|
)} |
|
114
|
|
|
115
|
{option.features.map((feature, featureIndex) => ( |
|
116
|
<div |
|
117
|
key={featureIndex} |
|
118
|
className="flex gap-0.75 items-center w-full text-medusa-fg-base" |
|
119
|
> |
|
120
|
<div className="flex gap-0.5 items-center"> |
|
121
|
<CheckCircleSolid /> |
|
122
|
</div> |
|
123
|
<span className="txt-medium-plus">{feature}</span> |
|
124
|
</div> |
|
125
|
))} |
|
126
|
</div> |
|
127
|
))} |
|
128
|
|
|
129
|
{/* Buttons row - all buttons at same level */} |
|
130
|
{data.options.map((option, index) => ( |
|
131
|
<div |
|
132
|
key={`buttons-${option._key}`} |
|
133
|
className={clsx( |
|
134
|
`p-1`, |
|
135
|
index !== data.options.length - 1 && |
|
136
|
"border-solid border-r border-medusa-border-base", |
|
137
|
index === data.options.length - 1 && |
|
138
|
"bg-medusa-bg-subtle rounded-br" |
|
139
|
)} |
|
140
|
> |
|
141
|
<div className="w-full flex flex-col gap-0.25"> |
|
142
|
{option.buttons.map((button) => ( |
|
143
|
<Link |
|
144
|
key={button._key} |
|
145
|
href={getPricingButtonUrl(button.link)} |
|
146
|
target="_blank" |
|
147
|
rel="noreferrer" |
|
148
|
> |
|
149
|
<Button |
|
150
|
variant={ |
|
151
|
button.variant === "primary" || button.variant === "dark" |
|
152
|
? "primary" |
|
153
|
: button.variant === "transparent" |
|
154
|
? "transparent" |
|
155
|
: "secondary" |
|
156
|
} |
|
157
|
className={clsx( |
|
158
|
"w-full txt-compact-xsmall-plus", |
|
159
|
button.variant === "transparent" && |
|
160
|
"text-medusa-fg-subtle" |
|
161
|
)} |
|
162
|
> |
|
163
|
{button.link.label} |
|
164
|
</Button> |
|
165
|
</Link> |
|
166
|
))} |
|
167
|
</div> |
|
168
|
</div> |
|
169
|
))} |
|
170
|
</div> |
|
171
|
</div> |
|
172
|
) |
|
173
|
} |
|
174
|
|
|
175
|
export default HeroPricing |