File size: 7,608 Bytes
8b105ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
import React, { useState, useRef, useEffect } from "react";
import styled from "styled-components";
// Styled Components
const PricingSection = styled.div`
padding: 4rem 2rem;
text-align: center;
`;
const SectionTitle = styled.h2`
font-size: 2rem;
font-weight: 800;
margin-bottom: 2rem;
background: #3267B9;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
`;
const ToggleWrapper = styled.div`
display: flex;
justify-content: center;
max-width: 14rem;
margin: 0 auto 2rem;
background: #fff;
border-radius: 9999px;
padding: 0.25rem;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
`;
const ToggleButton = styled.button`
flex: 1;
font-size: 0.875rem;
font-weight: 500;
padding: 0.5rem 0;
border: none;
border-radius: 9999px;
background: ${({ active }) =>
active ? "#3267B9" : "transparent"};
color: ${({ active }) => (active ? "#fff" : "#6b7280")};
cursor: pointer;
transition: background-color 0.3s ease, color 0.3s ease;
&:focus {
outline: none;
box-shadow: 0 0 0 2px #c7d2fe;
}
`;
const PricingGrid = styled.div`
display: grid;
gap: 2rem;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
max-width: 1200px;
margin: 0 auto;
`;
const Card = styled.div`
background: #fff;
border: ${({ highlighted }) =>
highlighted ? "2px solid transparent" : "1px solid #e5e7eb"};
border-radius: 1rem;
padding: 1.5rem;
position: relative;
overflow: hidden;
box-shadow: ${({ highlighted }) =>
highlighted
? "0 4px 15px rgba(16, 185, 129, 0.3)"
: "0 2px 5px rgba(0, 0, 0, 0.05)"};
background: ${({ highlighted }) =>
highlighted ? "#3267B9" : "#fff"};
&:hover {
transform: translateY(-5px);
transition: transform 0.3s ease;
}
`;
const PopularBadge = styled.div`
position: absolute;
top: -10px;
right: -10px;
background: #10b981;
color: #fff;
font-size: 0.75rem;
font-weight: 700;
padding: 0.5rem 1rem;
border-radius: 9999px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
`;
const Title = styled.h3`
font-size: 1.5rem;
font-weight: 700;
margin-bottom: 0.5rem;
color: ${({ highlighted }) => (highlighted ? "#fff" : "#1f2937")};
`;
const Price = styled.div`
font-size: 2rem;
font-weight: 800;
margin-bottom: 1rem;
color: ${({ highlighted }) => (highlighted ? "#fff" : "#1f2937")};
span {
font-size: 1rem;
font-weight: 500;
color: ${({ highlighted }) =>
highlighted ? "rgba(255,255,255,0.7)" : "#6b7280"};
}
`;
const Description = styled.p`
font-size: 0.875rem;
margin-bottom: 1.5rem;
color: ${({ highlighted }) => (highlighted ? "#d1fae5" : "#6b7280")};
`;
const Button = styled.a`
display: inline-block;
width: 100%;
text-align: center;
font-size: 0.875rem;
font-weight: 500;
padding: 0.75rem;
border-radius: 0.5rem;
text-decoration: none;
transition: all 0.3s ease;
${({ highlighted }) =>
highlighted
? `
background: #fff;
color: #3f7ad3;
&:hover {
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
`
: `
background: #3267B9;
color: #fff;
&:hover {
background: #3f7ad3;
box-shadow: 0 0 15px rgba(14, 168, 182, 0.5);
}
`}
`;
const FeatureList = styled.ul`
list-style: none;
padding: 0;
margin: 1rem 0 0;
color: ${({ highlighted }) => (highlighted ? "#d1fae5" : "#6b7280")};
`;
const FeatureItem = styled.li`
display: flex;
align-items: center;
font-size: 0.875rem;
margin-bottom: 0.5rem;
svg {
flex-shrink: 0;
margin-right: 0.5rem;
color: ${({ highlighted }) => (highlighted ? "#fff" : "#10b981")};
}
`;
const Pricing = () => {
const [isAnnual, setIsAnnual] = useState(true);
const pricingRef = useRef(null);
// UseEffect hook to handle smooth scrolling on initial load only
useEffect(() => {
// Scroll into view with smooth behavior
if (pricingRef.current) {
pricingRef.current.scroll({ behavior: "smooth" });
}
}, []);
const plans = [
{
title: "Academia",
monthly: "Free",
yearly: "Free",
description: "For research purposes. Institutional E-MailID required.",
features: [
"Limited VCF's",
"Size: <5MB",
"For research use only",
],
},
{
title: "Silver",
monthly: 30,
yearly: 330,
description: "Mostly Ideal for small teams and startups.",
features: [
"Up to 5 VCF's per month",
"Size: <5MB",
"Save $30 /year",
],
},
{
title: "Gold",
monthly: 250,
yearly: 2700,
description: "For growing businesses with higher needs.",
features: [
"Up to 50 VCF's per month",
"Size: <5MB",
"Save $300 /year",
],
},
{
title: "Platinum",
monthly: 1500,
yearly: 15000,
description: "For large organizations with high volume.",
features: [
"Up to 500 VCF's per month",
"Size: <5MB",
"Save $3000 /year",
],
},
];
// Handle Toggle Button Clicks
const handleToggle = (value) => {
setIsAnnual(value);
if (pricingRef.current && typeof pricingRef.current.scroll === 'function') {
pricingRef.current.scroll({ behavior: "smooth" });
}
};
return (
<div className="bg-zinc">
<PricingSection ref={pricingRef}>
<SectionTitle>Our Pricing Plans</SectionTitle>
{/* Toggle */}
<ToggleWrapper>
<ToggleButton active={isAnnual} onClick={() => handleToggle(true)} aria-label="Yearly">
Yearly <span></span>
</ToggleButton>
<ToggleButton active={!isAnnual} onClick={() => handleToggle(false)} aria-label="Monthly">
Monthly
</ToggleButton>
</ToggleWrapper>
{/* Pricing Grid */}
<PricingGrid className="items-center">
{plans.map((plan, index) => (
<Card key={index} highlighted={plan.highlighted} data-testid="pricing-card">
{plan.highlighted && <PopularBadge>Most Popular</PopularBadge>}
<Title highlighted={plan.highlighted}>{plan.title}</Title>
<Price highlighted={plan.highlighted}>
${isAnnual ? plan.yearly : plan.monthly}
<span>{isAnnual ? "/year" : "/mo"}</span>
</Price>
<Description highlighted={plan.highlighted}>{plan.description}</Description>
<Button highlighted={plan.highlighted} href="#0">
{plan.highlighted ? "Get Started" : "Purchase Plan"}
</Button>
<FeatureList highlighted={plan.highlighted}>
{plan.features.map((feature, i) => (
<FeatureItem key={i} highlighted={plan.highlighted}>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="#3f7ad3"
width="16"
height="16"
>
<path
fillRule="evenodd"
d="M16.707 4.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 11.586l7.293-7.293a1 1 0 011.414 0z"
clipRule="evenodd"
/>
</svg>
{feature}
</FeatureItem>
))}
</FeatureList>
</Card>
))}
</PricingGrid>
</PricingSection>
</div>
);
};
export default Pricing; |