-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.tsx
More file actions
101 lines (91 loc) · 2.49 KB
/
index.tsx
File metadata and controls
101 lines (91 loc) · 2.49 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
import Link from "@docusaurus/Link";
import styles from "./styles.module.css";
import { ReactNode } from "react";
export interface Category {
title: string;
icon: string;
href: string;
comingSoon?: boolean;
comingSoonBanner?: string;
}
export interface CategoryCardsTheme {
gradientStart: string;
gradientEnd: string;
iconHoverColorEffect?: "white" | "none";
}
interface CategoryCardsProps {
categories: Category[];
theme?: CategoryCardsTheme;
columns?: number;
}
export default function CategoryCards({
categories,
theme,
columns = 4,
}: CategoryCardsProps): ReactNode {
const handleCardClick = (
e: React.MouseEvent<HTMLAnchorElement>,
href: string,
comingSoon?: boolean
) => {
if (comingSoon) {
e.preventDefault();
return;
}
e.preventDefault();
// Scroll to top
window.scrollTo({ top: 0 });
// Navigate after scroll
setTimeout(() => {
window.location.href = href;
}, 10);
};
// Default theme (Wonderland)
const defaultTheme: CategoryCardsTheme = {
gradientStart: "var(--wonderland-pink)",
gradientEnd: "var(--wonderland-yellow)",
iconHoverColorEffect: "white",
};
const currentTheme = theme || defaultTheme;
return (
<div
className={styles.categoryCards}
style={{
'--columns': columns
} as React.CSSProperties}
>
{categories.map((category) => (
<Link
key={category.title}
to={category.href}
className={`${styles.categoryCard} ${currentTheme.iconHoverColorEffect === "none" ? styles.noIconHoverEffect : ""}`}
onClick={(e: React.MouseEvent<HTMLAnchorElement>) =>
handleCardClick(e, category.href, category.comingSoon)
}
style={
{
"--gradient-start": currentTheme.gradientStart,
"--gradient-end": currentTheme.gradientEnd,
} as React.CSSProperties
}
>
<img
src={category.icon}
alt={category.title}
className={styles.categoryIcon}
/>
<span className={styles.categoryTitle}>{category.title}</span>
{category.comingSoon && category.comingSoonBanner && (
<div className={styles.comingSoonOverlay}>
<img
src={category.comingSoonBanner}
alt="Coming Soon"
className={styles.comingSoonBanner}
/>
</div>
)}
</Link>
))}
</div>
);
}