Skip to content

Commit 98ff71b

Browse files
refactor(webapp): links (#58)
* chore: sass * chore: sass base styles * chore: eof newlines * feat: base link component * chore: base link tweak * feat: external link component don't need its styling yet because the base link is assumed external * feat: internal link component * style: internal link colours * feat: local link component * refactor: register page * refactor: login page * chore: misc lib changes * refactor: header component * refactor: theme switcher * refactor: videolist component * fix: build errors * style: header and footer tweaks * refactor: video page Co-authored-by: OtoMAN <65930041+horahoradev@users.noreply.github.com>
1 parent 93cb6ff commit 98ff71b

22 files changed

+197
-190
lines changed

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
volumes:
88
- ./webapp/src:/webapp/src
99
- ./webapp/public:/webapp/public
10+
- ./webapp/next.config.js:/webapp/next.config.js
1011
ports:
1112
- "3000:3000"
1213
frontapi:

webapp/next.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const nextJSConfig = {
1212
},
1313
sassOptions: {
1414
includePaths: [path.join(__dirname, "src", "styles")],
15-
},
16-
experimental: {
17-
newNextLinkBehavior: true,
18-
},
15+
}
1916
};
2017

2118
module.exports = nextJSConfig;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@use "../styles/variables/sass.scss" as *;
2+
3+
.block {
4+
display: flex;
5+
justify-content: space-around;
6+
width: 100%;
7+
height: 2rem;
8+
background-color: var(--colour1-secondary);
9+
}
10+
11+
.link {
12+
font-size: 1.25rem;
13+
line-height: 2rem;
14+
font-weight: bold;
15+
}

webapp/src/components/footer.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { PrivacyPolicy } from "./privacy-policy";
2-
import { TermsOfService } from "./terms-of-service";
1+
import styles from "./footer.module.scss";
32

4-
interface IFooterProps extends Record<string, unknown> {}
3+
import { LinkInternal } from "#components/links";
54

6-
export function Footer(props: IFooterProps) {
7-
const { userData, dataless } = props;
5+
interface IFooterProps extends Record<string, unknown> {}
86

7+
export function Footer({ userData, dataless }: IFooterProps) {
98
return (
10-
<nav className="h-8 w-full bg-white dark:bg-gray-900 shadow">
11-
<div className="flex justify-around p-auto">
12-
<PrivacyPolicy />
13-
<TermsOfService />
14-
</div>
15-
</nav>
9+
<footer className={styles.block}>
10+
<LinkInternal className={styles.link} href="/privacy-policy">Privacy Policy</LinkInternal>
11+
<LinkInternal className={styles.link} href="/terms-of-service">Terms of Service</LinkInternal>
12+
</footer>
1613
);
1714
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@use "../styles/variables/sass.scss" as *;
2+
3+
.block {
4+
display: flex;
5+
justify-content: center;
6+
height: 4rem;
7+
background-color: var(--colour1-secondary);
8+
}
9+
10+
.logo {
11+
font-size: 1.5rem;
12+
line-height: 2rem;
13+
font-weight: bold;
14+
}

webapp/src/components/header.tsx

Lines changed: 32 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useRouter } from "next/router";
2-
import Link from "next/link";
32
import { useCallback, useState } from "react";
43
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
54
import {
@@ -15,29 +14,30 @@ import { Button, Dropdown, Input, Menu } from "antd";
1514

1615
import { ThemeSwitcher } from "./theme-switcher";
1716
import { LinkInternal } from "./links/internal";
17+
import styles from "./header.module.scss"
1818

1919
import { UserRank } from "#api/types";
2020
import { onParentBlur } from "#lib/dom";
21-
import { Icon } from "#components/icons";
2221

2322
interface IHeaderProps extends Record<string, unknown> {}
2423
export function Header({ userData, dataless }: IHeaderProps) {
2524
return (
26-
<nav className="h-16 bg-white dark:bg-gray-800 shadow flex justify-center">
27-
<div className="max-w-screen-lg w-screen flex justify-start items-center gap-x-4 mx-4">
25+
<header className={styles.block}>
26+
<nav className="max-w-screen-lg w-screen flex justify-start items-center gap-x-4 mx-4">
2827
<div className="flex justify-start flex-grow-0">
29-
<Link className="text-2xl font-black text-blue-500" href="/">
28+
{/* @TODO: site logo component */}
29+
<LinkInternal className={styles.logo} href="/">
3030
Horahora
31-
</Link>
31+
</LinkInternal>
3232
</div>
3333
<Search />
3434
{!dataless && (
3535
<div className="flex-grow-0 ml-auto">
3636
<UserNav userData={userData} />
3737
</div>
3838
)}
39-
</div>
40-
</nav>
39+
</nav>
40+
</header>
4141
);
4242
}
4343

@@ -163,46 +163,32 @@ function LoggedInUserNav(props: ILoggedInUserNav) {
163163

164164
let menu = (
165165
<Menu className="bg-white dark:bg-black">
166-
<Menu.Item key="upload" icon={<Icon icon={faUpload} />}>
167-
<LinkInternal href="/account/upload">Upload</LinkInternal>
166+
<Menu.Item key="upload">
167+
<LinkInternal iconID={faUpload} href="/account/upload">
168+
Upload
169+
</LinkInternal>
168170
</Menu.Item>
169-
<Menu.Item key="profile" icon={<Icon icon={faUser} />}>
170-
<Link
171-
className="text-black dark:text-white dark:hover:text-black"
171+
<Menu.Item key="profile">
172+
<LinkInternal
173+
iconID={faUser}
172174
// @ts-expect-error figure `userData` shape
173175
href={`/users/${userData.userID}`}
174176
>
175177
Profile page
176-
</Link>
178+
</LinkInternal>
177179
</Menu.Item>
178180
<Menu.Divider />
179181

180182
<Menu.Item
181183
key="password-reset"
182-
icon={
183-
<FontAwesomeIcon
184-
className="max-h-4 text-black dark:text-white"
185-
icon={faKey}
186-
/>
187-
}
188184
>
189-
<Link className="text-black dark:text-white" href="/password-reset">
190-
Reset Password
191-
</Link>
185+
<LinkInternal iconID={faKey} href="/password-reset">Reset Password</LinkInternal>
192186
</Menu.Item>
193187
<Menu.Divider />
194188
<Menu.Item
195189
key="logout"
196-
icon={
197-
<FontAwesomeIcon
198-
className="max-h-4 text-red-600"
199-
icon={faSignOutAlt}
200-
/>
201-
}
202190
>
203-
<Link className="text-black dark:text-white" href="/logout">
204-
Logout
205-
</Link>
191+
<LinkInternal iconID={faSignOutAlt} href="/logout">Logout</LinkInternal>
206192
</Menu.Item>
207193
</Menu>
208194
);
@@ -229,43 +215,29 @@ function LoggedInAdminNav(props: ILoggedInAdminNav) {
229215
<Menu className="bg-white dark:bg-black">
230216
<Menu.Item
231217
key="profile"
232-
icon={
233-
<FontAwesomeIcon
234-
className="max-h-4 text-black dark:text-white"
235-
icon={faUser}
236-
/>
237-
}
238218
>
239-
<Link
240-
className="text-black dark:text-white dark:hover:text-black"
219+
<LinkInternal
220+
iconID={faUser}
241221
// @ts-expect-error figure `userData` shape
242222
href={`/users/${userData.userID}`}
243223
>
244224
Profile page
245-
</Link>
225+
</LinkInternal>
246226
</Menu.Item>
247227
<Menu.Divider />
248228

249-
<Menu.Item key="upload" className="flex flex-row gap-2" icon={<Icon icon={faUpload} />}>
250-
<LinkInternal href="/account/upload">Upload</LinkInternal>
229+
<Menu.Item
230+
key="upload"
231+
className="flex flex-row gap-2"
232+
>
233+
<LinkInternal iconID={faUpload} href="/account/upload">Upload</LinkInternal>
251234
</Menu.Item>
252235
<Menu.Divider />
253236

254237
<Menu.Item
255238
key="archive-requests"
256-
icon={
257-
<FontAwesomeIcon
258-
className="max-h-4 text-black dark:text-white"
259-
icon={faArchive}
260-
/>
261-
}
262239
>
263-
<Link
264-
className="text-black dark:text-white dark:hover:text-black"
265-
href="/archive-requests"
266-
>
267-
Archive Requests
268-
</Link>
240+
<LinkInternal iconID={faArchive} href="/archive-requests">Archive Requests</LinkInternal>
269241
</Menu.Item>
270242
<Menu.Divider />
271243

@@ -275,54 +247,21 @@ function LoggedInAdminNav(props: ILoggedInAdminNav) {
275247

276248
<Menu.Item
277249
key="password-reset"
278-
icon={
279-
<FontAwesomeIcon
280-
className="max-h-4 text-black dark:text-white"
281-
icon={faKey}
282-
/>
283-
}
284250
>
285-
<Link
286-
className="text-black dark:text-white dark:hover:text-black"
287-
href="/password-reset"
288-
>
289-
Password Reset
290-
</Link>
251+
<LinkInternal iconID={faKey} href="/password-reset">Password Reset</LinkInternal>
291252
</Menu.Item>
292253

293254
<Menu.Divider />
294255
<Menu.Item
295256
key="audits"
296-
icon={
297-
<FontAwesomeIcon
298-
className="max-h-4 text-black dark:text-white"
299-
icon={faArchive}
300-
/>
301-
}
302257
>
303-
<Link
304-
className="text-black dark:text-white dark:hover:text-black"
305-
href="/audits"
306-
>
307-
Audit Logs
308-
</Link>
258+
<LinkInternal iconID={faArchive} href="/audits">Audit Logs</LinkInternal>
309259
</Menu.Item>
310260
<Menu.Divider />
311261
<Menu.Item
312262
key="logout"
313-
icon={
314-
<FontAwesomeIcon
315-
className="max-h-4 text-red-600"
316-
icon={faSignOutAlt}
317-
/>
318-
}
319263
>
320-
<Link
321-
className="text-black dark:text-white dark:hover:text-black"
322-
href="/logout"
323-
>
324-
Logout
325-
</Link>
264+
<LinkInternal iconID={faSignOutAlt} href="/logout">Logout</LinkInternal>
326265
</Menu.Item>
327266
</Menu>
328267
);
@@ -346,12 +285,8 @@ function LoggedInAdminNav(props: ILoggedInAdminNav) {
346285
function LoggedOutUserNav() {
347286
return (
348287
<>
349-
<Link href="/login">
350-
<Button>Login</Button>
351-
</Link>
352-
<Link className="ml-2" href="/register">
353-
<Button type="primary">Register</Button>
354-
</Link>
288+
<LinkInternal href="/login">Login</LinkInternal>
289+
<LinkInternal href="/register">Register</LinkInternal>
355290
</>
356291
);
357292
}

webapp/src/components/links/html.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "../../styles/variables/sass.scss" as *;
2+
13
.block {
24
--local-colour1-primary: var(--anchour-colour1-primary);
35
--local-colour1-secondary: var(--anchour-colour1-secondary);

webapp/src/components/links/internal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
type HTMLAttributeAnchorTarget,
55
type ReactNode,
66
} from "react";
7-
import clsx from "clsx";
7+
88

99
import styles from "./internal.module.scss";
1010
import { AnchourHTML } from "./html";
@@ -35,7 +35,7 @@ export function Component({
3535
return (
3636
<Link {...blockProps} passHref>
3737
<AnchourHTML
38-
className={linkClass}
38+
className={className}
3939
target={target}
4040
iconID={iconID}
4141
onClick={onClick}

webapp/src/components/privacy-policy.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

webapp/src/components/terms-of-service.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)