Skip to content

Commit 3f46964

Browse files
author
Piyush Tripathi
committed
fix: correct layout shift on Meet Five and Handbook cards
Signed-off-by: Piyush Tripathi <piyushtripathi9424@gmail.com>
1 parent 2b8377f commit 3f46964

2 files changed

Lines changed: 44 additions & 23 deletions

File tree

‎src/components/AdventuresVol/index.js‎

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
11
import React from "react";
2+
import { Link } from "gatsby";
23
import { HiOutlineChevronRight } from "@react-icons/all-files/hi/HiOutlineChevronRight";
34
import { AdventuresVolWrapper } from "./adventures-vol.style";
45

56
const AdventuresVol = ({ title, description, to, image }) => {
7+
const isExternalOrStatic =
8+
to &&
9+
(to.startsWith("http://") ||
10+
to.startsWith("https://") ||
11+
to.endsWith(".pdf") ||
12+
to.startsWith("mailto:"));
13+
14+
const cardContent = (
15+
<div className="handbook__card">
16+
<h1 className="handbook__card--head">{title}</h1>
17+
<div className="handbook__card--line"></div>
18+
<img src={image} alt={title} />
19+
<p className="handbook__card--para">{description}</p>
20+
{to && (
21+
<div className="handbook__card--lm__container">
22+
<span className="handbook__card--lm">
23+
Read More <HiOutlineChevronRight />
24+
</span>
25+
</div>
26+
)}
27+
</div>
28+
);
29+
630
return (
731
<AdventuresVolWrapper>
8-
<a href={to} className="handbook__card--main">
9-
<div className="handbook__card">
10-
<h1 className="handbook__card--head">{title}</h1>
11-
<div className="handbook__card--line"></div>
12-
<img src={image} />
13-
<p className="handbook__card--para">
14-
{description}
15-
</p>
16-
{to && (
17-
<div className="handbook__card--lm__container">
18-
<a href={to} className="handbook__card--lm">
19-
Read More <HiOutlineChevronRight />
20-
</a>
21-
</div>
22-
)}
23-
</div>
24-
</a>
32+
{!to ? (
33+
<div className="handbook__card--main">{cardContent}</div>
34+
) : isExternalOrStatic ? (
35+
<a
36+
href={to}
37+
className="handbook__card--main"
38+
target={isExternalOrStatic ? "_blank" : undefined}
39+
rel={isExternalOrStatic ? "noreferrer" : undefined}
40+
>
41+
{cardContent}
42+
</a>
43+
) : (
44+
<Link to={to} className="handbook__card--main">
45+
{cardContent}
46+
</Link>
47+
)}
2548
</AdventuresVolWrapper>
2649
);
2750
};

‎src/components/HandbookCard/index.js‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ import { HandbookCardWrapper } from "./HandbookCard.style";
66
const HandbookCard = ({ title, description, to }) => {
77
return (
88
<HandbookCardWrapper>
9-
<Link to={to} class="handbook__card--main">
9+
<Link to={to} className="handbook__card--main">
1010
<div className="handbook__card">
1111
<h1 className="handbook__card--head">{title}</h1>
1212
<div className="handbook__card--line"></div>
13-
<p className="handbook__card--para">
14-
{description}
15-
</p>
13+
<p className="handbook__card--para">{description}</p>
1614
{to && (
1715
<div className="handbook__card--lm__container">
18-
<a href={to} className="handbook__card--lm">
16+
<span className="handbook__card--lm">
1917
Read More <HiOutlineChevronRight />
20-
</a>
18+
</span>
2119
</div>
2220
)}
2321
</div>

0 commit comments

Comments
 (0)