-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathLayout.tsx
214 lines (200 loc) · 5.91 KB
/
Layout.tsx
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// Imports
import Link from "next/link"; // Routing
import { useRouter } from "next/router"; // Routing
import { default as HTMLHead } from "next/head"; // Meta
import styles from "@styles/components/Layout.module.scss"; // Styles
// Types
import type { ReactElement } from "react";
export default function Layout({
children,
}: {
children: ReactElement | ReactElement[];
}) {
const quicklinks: Record<string, string>[] = [
{
name: "Chapters",
url: "/"
},
{
name: "Marketplaces",
url: "/marketplaces"
},
{
name: "Build w/ Loot",
url: "/build"
},
{
name: "Resources",
url: "/resources",
},
];
const subLinks: Record<string, string>[] = [
{
name: "Loot.exchange",
url: "https://www.loot.exchange/",
},
{
name: "Opensea",
url: "https://opensea.io/collection/lootproject"
},
{
name: "Twitter",
url: "https://twitter.com/lootproject",
},
];
const router = useRouter();
return (
<div>
{/* Meta */}
<Head />
{/* Top header */}
<Header />
<div className="container mx-auto px-4 text-center py-10 sm:pt-40 justify-around flex flex-wrap">
<div className="sm:w-1/2">
<h1>Loot</h1>
<div>
<nav className="my-8">
{subLinks.map(({ name, url }, i) => {
return (<Link key={i} href={url}>
<a className={router.pathname == url ? "bg-gray-800 py-1 px-4 sm:p-4 mx-4 rounded-xl border border-gray-900" : " px-4 sm:p-4 mx-4 py-1 hover:bg-gray-800 rounded-xl "} >{name}</a>
</Link>)
})}
</nav>
</div>
<p className="sm:text-2xl">Loot is randomized adventurer gear generated and stored on chain.
Stats, images, and other functionality are intentionally omitted for others to interpret.
Feel free to use Loot in any way you want.</p>
</div>
<div className=" flex w-full justify-around mt-8 relative overflow-hidden ">
<div className="sticky top-0 bg-gray-800 p-2 rounded-2xl flex sm:text-2xl tracking-wide flex-wrap justify-between">
{quicklinks.map(({ name, url }, i) => {
return (<Link key={i} href={url}>
<a className={(router.pathname == url ? "bg-gray-900" : "hover:bg-gray-900") + " py-1 px-4 sm:p-4 mx-1 rounded-xl transition-all duration-150"} >{name}</a>
</Link>)
})}
</div>
</div>
</div>
{/* Page content */}
<div className={styles.content}>{children}</div>
{/* Bottom footer */}
<Footer />
</div>
);
}
/**
* Meta HTML Head
* @returns {ReactElement} HTML Head component
*/
function Head(): ReactElement {
return (
<HTMLHead>
{/* Primary Meta Tags */}
<title>Loot</title>
<meta name="title" content="Loot" />
<meta
name="description"
content="Loot is randomized adventurer gear generated and stored on chain."
/>
{/* OG + Faceook */}
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.lootproject.com/" />
<meta property="og:title" content="Loot" />
<meta
property="og:description"
content="Loot is randomized adventurer gear generated and stored on chain."
/>
<meta property="og:image" content="https://lootproject.com/meta.png" />
{/* Twitter */}
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="https://www.lootproject.com/" />
<meta property="twitter:title" content="Loot" />
<meta
property="twitter:description"
content="Loot is randomized adventurer gear generated and stored on chain."
/>
<meta property="twitter:image" content="https://lootproject.com/meta.png" />
{/* Font */}
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="true"
/>
{/* eslint-disable-next-line @next/next/no-page-custom-font */}
<link
href="https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;700&family=Inconsolata:wght@300&display=swap"
rel="stylesheet"
/>
</HTMLHead>
);
}
/**
* Header
* @returns {ReactElement} Header
*/
function Header() {
// Collect current path for active links
const { pathname } = useRouter();
// All links
const links = [
{ name: "FAQ", path: "/faq" },
{ name: "Discord", path: "https://discord.gg/23gbrJ6pje" },
{ name: "Loot Talk", path: "https://loot-talk.com/" },
];
return (
<div className={styles.header}>
{/* Main logo */}
<div className={styles.header__logo}>
<Link href="/">
<a>Loot</a>
</Link>
</div>
{/* Navigation */}
<div className={styles.header__links}>
<ul>
{links.map(({ name, path }, i) => {
// For each link, render link
return (
<li key={i}>
<Link href={path}>
<a
className={
pathname === path
? // Active class if pathname matches current path
styles.header__links_active
: undefined
}
>
{name}
</a>
</Link>
</li>
);
})}
</ul>
</div>
</div>
);
}
/**
* Footer component
* @returns {ReactElement} Footer
*/
function Footer(): ReactElement {
return (
<div className={styles.footer}>
<p>
This website is{" "}
<a
href="https://github.com/lootproject/website"
target="_blank"
rel="noopener noreferrer"
>
open-source
</a>
.
</p>
</div>
);
}