Skip to content

Commit 9c5d4f9

Browse files
committed
Updated css , position sticky , overflow-x to scroll for body and visisble for main container, tuned header postion w.r.t nav bar , updated media queries for table width and position
Signed-off-by: priyanshu4999 <[email protected]>
1 parent f7ea3fa commit 9c5d4f9

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

src/sections/Pricing/comparison.js

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import details from "./generateDetails";
44
import { Container } from "../../reusecore/Layout";
55
// import FeatureDetails from "./collapsible-details";
66
import FeatureDetails from "../../components/Pricing/PlanCard/collapsible-details";
7+
import { useRef } from "react";
78

89
const ComparisonWrapper = styled.div`
910
margin: 6rem auto;
10-
@media (min-width: 2048px) {
11-
margin: 15rem auto;
12-
}
13-
1411
h2,
1512
h5 {
1613
text-align: center;
@@ -20,10 +17,9 @@ const ComparisonWrapper = styled.div`
2017
box-shadow: 0 0 24px ${(props) => props.theme.whiteOneFiveToBlackOneFive};
2118
margin: 2rem auto;
2219
display: block;
23-
overflow-x: scroll;
24-
overflow-y: hidden;
2520
transition: 0.6s cubic-bezier(0.5, 1);
2621
}
22+
2723
.price-table {
2824
width: 100%;
2925
border-collapse: collapse;
@@ -61,6 +57,18 @@ const ComparisonWrapper = styled.div`
6157
}
6258
.price-table tr:nth-child(even) {
6359
}
60+
.price-table-header-sticky {
61+
overflow-x: scroll;
62+
position: sticky;
63+
top: 0%;
64+
scrollbar-width: thin;
65+
scrollbar-color: ${(props) => props.theme.whiteZeroThreeToBlackZeroThree}
66+
${(props) => props.theme.whiteZeroThreeToBlackZeroThree};
67+
}
68+
.price-table-body-scroll {
69+
overflow-x: scroll;
70+
scrollbar-width: none;
71+
}
6472
6573
.price-table tr:hover {
6674
background-color: ${(props) => props.theme.secondaryLightColor};
@@ -81,7 +89,6 @@ const ComparisonWrapper = styled.div`
8189
.price-table col:nth-child(5) {
8290
width: 9rem;
8391
}
84-
8592
/* Highlighted column */
8693
8794
.price-table tr td:nth-child(3) {
@@ -120,7 +127,7 @@ const ComparisonWrapper = styled.div`
120127
background-color: rgba(0, 179, 159, 0.1);
121128
text-transform: uppercase;
122129
font-size: 12px;
123-
padding: 12px 48px;
130+
padding: 12px 32px;
124131
font-weight: 700;
125132
}
126133
.price-table .price-blank {
@@ -200,17 +207,35 @@ const ComparisonWrapper = styled.div`
200207
.feature-link:hover {
201208
text-decoration: underline;
202209
}
210+
@media (min-width: 1100px) {
211+
.price-table-header-sticky {
212+
top: 2%;
213+
214+
@media (min-width: 2048px) {
215+
margin: 15rem auto;
216+
}
217+
}
218+
}
203219
`;
204220

205221
const Comparison = () => {
222+
const headerScrollRef = useRef(null);
223+
const bodyScrollRef = useRef(null);
224+
const handleCommonScroll = () => {
225+
bodyScrollRef.current.scrollLeft = headerScrollRef.current.scrollLeft;
226+
};
206227
return (
207228
<ComparisonWrapper>
208229
<h2>Compare All Features</h2>
209230
<h5 id={"feature-comparison"}>Choose a plan that’s right for you</h5>
210231
<Container>
211232
<div className="main">
212-
<div className="price-table-header-sticky">
213-
<table>
233+
<div
234+
className="price-table-header-sticky"
235+
ref={headerScrollRef}
236+
onScroll={handleCommonScroll}
237+
>
238+
<table className="price-table">
214239
<colgroup>
215240
<col />
216241
<col />
@@ -236,7 +261,7 @@ const Comparison = () => {
236261
</tbody>
237262
</table>
238263
</div>
239-
<div className="price-table-body-scroll">
264+
<div className="price-table-body-scroll" ref={bodyScrollRef}>
240265
<table className="price-table">
241266
<colgroup>
242267
<col />

0 commit comments

Comments
 (0)