-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathMainNavLinks.tsx
More file actions
102 lines (97 loc) · 2.38 KB
/
MainNavLinks.tsx
File metadata and controls
102 lines (97 loc) · 2.38 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
import styles from "./styles.module.scss";
import { Logo } from "../Logo";
import { Icon } from "../Icon";
type MainNavLinksProps = {
links: {
label: string;
url: string;
}[];
editorButtonLabel: string;
donateButtonLabel: string;
mobileMenuLabel: string;
isHomepage: boolean;
hasJumpTo: boolean;
handleToggle: () => void;
isOpen: boolean;
};
export const MainNavLinks = ({
links,
donateButtonLabel,
editorButtonLabel,
mobileMenuLabel,
isHomepage = false,
handleToggle,
isOpen,
hasJumpTo,
}: MainNavLinksProps) => {
if (!links || links?.length <= 0) return null;
const renderLogo = () => (
<div class={styles.logo}>
<a
href="/"
class={`${
isHomepage
? "text-logo-color hover:text-sidebar-type-color"
: "text-sidebar-type-color hover:text-logo-color"
}`}
aria-label={isHomepage ? "Reload current page" : "Go to p5.js homepage"}
>
<Logo />
</a>
<button
class={styles.toggle}
onClick={handleToggle}
aria-expanded={isOpen}
aria-label={mobileMenuLabel || "Toggle navigation menu"}
>
<div class={styles.mobileMenuLabel}>
{isOpen ? (
<Icon kind="close" />
) : (
<>
<span>{mobileMenuLabel}</span>
<Icon kind="hamburger" />
</>
)}
</div>
<span class={styles.desktopMenuLabel}>
<Icon kind={isOpen ? "chevron-up" : "chevron-down"} />
</span>
</button>
</div>
);
return (
<div
class={`${styles.mainlinks} ${isOpen && "open"} ${
!hasJumpTo && "noJumpTo"
}`}
>
{renderLogo()}
<ul>
{links.map((link) => (
<li key={link.label}>
<a href={link.url}>{link.label}</a>
</li>
))}
</ul>
<ul class="flex flex-col gap-[15px]">
<li>
<a className={styles.buttonlink} href="https://editor.p5js.org">
<div class="mr-xxs">
<Icon kind="code-brackets" />
</div>
{editorButtonLabel}
</a>
</li>
<li>
<a className={styles.buttonlink} href="/donate/">
<div class="mr-xxs">
<Icon kind="heart" />
</div>
{donateButtonLabel}
</a>
</li>
</ul>
</div>
);
};