Skip to content

Commit 5a2cd82

Browse files
authored
Merge pull request #6111 from SAHU-01/master
[UI]: Adding a yearly or monthly toggle
2 parents 24e1841 + 05aa94d commit 5a2cd82

File tree

3 files changed

+88
-16
lines changed

3 files changed

+88
-16
lines changed

src/components/PlanCard/index.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Col, Row, Container } from "../../reusecore/Layout";
44
import PlanCardWrapper from "./planCard.style";
55
import FeatureDetails from "./collapsible-details";
66

7-
const PlanCard = ({ planData }) => {
7+
const PlanCard = ({ planData , isYearly }) => {
88
if (!planData || !Array.isArray(planData) || planData.length === 0) {
99
return <div>No plan data available</div>;
1010
}
@@ -29,23 +29,42 @@ const PlanCard = ({ planData }) => {
2929
<h5 className="byline">{x.byline}</h5>
3030

3131
<div className="price-container">
32-
{x.monthlyprice !== undefined ? (
33-
<div className="price">
34-
<span className="price-amount"><sup>$</sup>
35-
{x.monthlyprice === 0
36-
? "0"
37-
: x.monthlyprice.toFixed(0)}
38-
</span>
39-
<span className="currency">USD</span>
40-
<span className="price-per">per user/month</span>
41-
</div>
32+
{isYearly ? (
33+
x.yearlyprice !== undefined ? (
34+
<div className="price">
35+
<span className="price-amount"><sup>$</sup>
36+
{x.yearlyprice === 0
37+
? "0"
38+
: x.yearlyprice.toFixed(0)}
39+
</span>
40+
<span className="currency">USD</span>
41+
<span className="price-per">per user/year</span>
42+
</div>
43+
) : (
44+
<div className="pricing_coming_soon">
45+
{x.pricing_coming_soon}
46+
</div>
47+
)
4248
) : (
43-
<div className="pricing_coming_soon">
44-
{x.pricing_coming_soon}
45-
</div>
49+
x.monthlyprice !== undefined ? (
50+
<div className="price">
51+
<span className="price-amount"><sup>$</sup>
52+
{x.monthlyprice === 0
53+
? "0"
54+
: x.monthlyprice.toFixed(0)}
55+
</span>
56+
<span className="currency">USD</span>
57+
<span className="price-per">per user/month</span>
58+
</div>
59+
) : (
60+
<div className="pricing_coming_soon">
61+
{x.pricing_coming_soon}
62+
</div>
63+
)
4664
)}
4765
</div>
4866

67+
4968
<Button
5069
disabled={x.tier === "Team Operator"}
5170
$primary

src/sections/Pricing/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import PricingWrapper from "./pricing.style";
33
import Comparison from "./comparison";
44
import FAQ from "../General/Faq";
@@ -8,21 +8,43 @@ import PlanCard from "../../components/PlanCard";
88

99
const Pricing = () => {
1010
// const [monthly, setMonthly] = useState(false);
11+
const [isYearly, setIsYearly] = useState(false);
12+
13+
const handleToggle = () => {
14+
setIsYearly((prev) => !prev);
15+
};
1116

1217
return (
1318
<PricingWrapper>
1419

1520
<div className="headers">
1621
<h1 className="header-heading">Plans For Every Team Size</h1>
1722

23+
<div className="toggle-container">
24+
<div className="toggle">
25+
<span
26+
className={!isYearly ? "active" : ""}
27+
onClick={() => handleToggle(false)} // Call handleToggle
28+
>
29+
Monthly
30+
</span>
31+
<span
32+
className={isYearly ? "active" : ""}
33+
onClick={() => handleToggle(true)} // Call handleToggle
34+
>
35+
Yearly
36+
</span>
37+
</div>
38+
</div>
39+
1840
{/* <svg className="header-svg" aria-hidden="true" role="presentation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
1941
<polygon fill="white" points="0,100 100,0 100,100"/>
2042
<polygon fill="rgba(0,179,159,0.2)" points="50,50 100,0 100,100"/>
2143
</svg> */}
2244
</div>
2345

2446
<div className="wrapper">
25-
<PlanCard planData={options}/>
47+
<PlanCard planData={options} isYearly={isYearly}/>
2648
</div>
2749
<Comparison />
2850
<Reviews />

src/sections/Pricing/pricing.style.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@ const PricingWrapper = styled.section`
3636
}
3737
}
3838
39+
.toggle-container {
40+
display: flex;
41+
justify-content: end;
42+
align-items: center;
43+
margin: 20px 0;
44+
font-size: 16px;
45+
gap: 10px;
46+
width: 85%;
47+
}
48+
49+
.toggle{
50+
border: 2px solid white;
51+
padding:10px;
52+
border-radius: 15px;
53+
}
54+
55+
.toggle-container span {
56+
cursor: pointer;
57+
padding: 8px 16px;
58+
color:white;
59+
border-radius: 12px;
60+
transition: background-color 0.3s, color 0.3s;
61+
}
62+
63+
.toggle-container .active {
64+
background-color: #00d3a9;
65+
color: white;
66+
border-color: #007bff;
67+
}
68+
69+
3970
.subscription-duration {
4071
margin-top: 2rem;
4172
margin-bottom: 4rem;

0 commit comments

Comments
 (0)