-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.tsx
More file actions
123 lines (113 loc) · 3.16 KB
/
index.tsx
File metadata and controls
123 lines (113 loc) · 3.16 KB
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
import styles from "./styles.module.css";
import React, { ReactNode } from "react";
type WonderlandBgTypeHandbook = {
bgType: "wonderland";
color: string;
};
type OtherBgTypeHandbook = {
bgType: "other";
bgImage: string;
};
type HandbookBackground = WonderlandBgTypeHandbook | OtherBgTypeHandbook;
export interface Handbook {
title: string;
image: string;
href: string;
background: HandbookBackground;
}
export interface HandbookSectionProps {
handbooks: Handbook[];
title: string;
description: string;
className?: string;
}
interface HandbookCardProps {
handbook: Handbook;
isDefault?: boolean;
}
function HandbookCard({ handbook, isDefault = false }: HandbookCardProps) {
if (isDefault) {
return (
<div className={styles.handbooksCardDefault}>
<img
src="/common/img/default-handbook.svg"
alt=""
className={styles.handbooksCardIcon}
/>
</div>
);
}
let cardStyle: React.CSSProperties = {};
if (handbook.background.bgType === "wonderland") {
cardStyle.backgroundImage = "url(/common/img/background-handbook-card.jpg)";
} else if (handbook.background.bgType === "other") {
cardStyle.backgroundImage = `url(${handbook.background.bgImage})`;
}
return (
<a
href={handbook.href}
style={cardStyle}
target="_blank"
className={styles.handbooksCard}
>
{handbook.background.bgType === "wonderland" && (
<div
className={styles.colorOverlay}
style={{ backgroundColor: handbook.background.color }}
></div>
)}
<img
src={handbook.image}
alt=""
className={`${styles.handbooksCardIcon} ${
handbook.title.toLowerCase().includes("aztec")
? styles.handbooksCardIconAztec
: ""
}`}
/>
</a>
);
}
export default function HandbookSection({
handbooks,
title,
description,
className,
}: HandbookSectionProps): ReactNode {
return (
<section
className={`${styles.handbooksSection} ${className ? styles[className] || "" : ""}`}
>
<img
src="/common/img/star-icon.svg"
alt=""
className={styles.starMobile}
/>
<div className={styles.handbooksSeparator}>
<span className={`${styles.line} ${styles.mainLine}`}></span>
<p>{title}</p>
<span className={`${styles.line} ${styles.mainLine}`}></span>
</div>
<p className={styles.handbooksDescription}>{description}</p>
<div className={styles.handbooksCards}>
{handbooks.length === 1 ? (
<>
{/* First handbook card */}
<HandbookCard handbook={handbooks[0]} />
{/* Default handbook card (not a link) */}
<HandbookCard handbook={handbooks[0]} isDefault />
</>
) : (
handbooks.map((handbook) => (
<HandbookCard key={handbook.title} handbook={handbook} />
))
)}
</div>
<div className={styles.handbooksSeparator}>
<span className={styles.line}></span>
<img src="/common/img/star-icon.svg" alt="" />
<span className={styles.line}></span>
</div>
</section>
);
}