aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components
diff options
context:
space:
mode:
authorWolfboy248 <georgejvindkarlsen@gmail.com>2025-08-25 11:13:20 +0200
committerWolfboy248 <georgejvindkarlsen@gmail.com>2025-08-25 11:13:20 +0200
commitccd08bc0f03cb59b351c19d78ac0f937a5270368 (patch)
treead6283f389e0bb84a8c1609e8aa26a4383f31279 /frontend/src/components
parentRemoved unnecessary imports (diff)
downloadlphub-ccd08bc0f03cb59b351c19d78ac0f937a5270368.tar.gz
lphub-ccd08bc0f03cb59b351c19d78ac0f937a5270368.tar.bz2
lphub-ccd08bc0f03cb59b351c19d78ac0f937a5270368.zip
Moved breadcrum navigation into its own component
Diffstat (limited to '')
-rw-r--r--frontend/src/components/BreadcrumbNav/BreadcrumbNav.module.css36
-rw-r--r--frontend/src/components/BreadcrumbNav/BreadcrumbNav.tsx72
2 files changed, 108 insertions, 0 deletions
diff --git a/frontend/src/components/BreadcrumbNav/BreadcrumbNav.module.css b/frontend/src/components/BreadcrumbNav/BreadcrumbNav.module.css
new file mode 100644
index 0000000..9821972
--- /dev/null
+++ b/frontend/src/components/BreadcrumbNav/BreadcrumbNav.module.css
@@ -0,0 +1,36 @@
1.container {
2 display: flex;
3 margin-top: 42px;
4 margin-bottom: 16px;
5 margin-left: 48px;
6 gap: 2px;
7}
8
9.crumb {
10 display: flex;
11 align-items: center;
12 gap: 12px;
13 background-color: var(--color-block);
14 padding: 6px 16px;
15 transition: all 0.1s ease;
16 font-size: 22px;
17}
18
19.crumb:hover {
20 background-color: var(--color-panel);
21}
22
23.crumb.first {
24 border-top-left-radius: 1000px;
25 border-bottom-left-radius: 1000px;
26}
27
28.crumb.middle {
29 border-radius: 0px;
30}
31
32.crumb.last,
33.crumb.first.last {
34 border-top-right-radius: 1000px;
35 border-bottom-right-radius: 1000px;
36} \ No newline at end of file
diff --git a/frontend/src/components/BreadcrumbNav/BreadcrumbNav.tsx b/frontend/src/components/BreadcrumbNav/BreadcrumbNav.tsx
new file mode 100644
index 0000000..7c4af15
--- /dev/null
+++ b/frontend/src/components/BreadcrumbNav/BreadcrumbNav.tsx
@@ -0,0 +1,72 @@
1import React from "react";
2import { Link, useLocation } from "react-router-dom";
3
4import styles from "./BreadcrumbNav.module.css";
5
6export interface Breadcrumb {
7 to: string;
8 label: string;
9};
10
11interface BreadcrumbNavProps {
12 chapter?: Breadcrumb;
13};
14
15const BreadcrumbNav: React.FC<BreadcrumbNavProps> = ({ chapter }) => {
16 const [breadcrumbs, setBreadcrumbs] = React.useState<Breadcrumb[]>([]);
17
18 const path = useLocation();
19
20 React.useEffect(() => {
21 let _paths = path.pathname.split("/").filter(Boolean);
22 console.log(_paths);
23 let _breadcrumbs: Breadcrumb[] = [];
24
25 if (_paths.length >= 2) {
26 _breadcrumbs.push({
27 to: "/games",
28 label: "Games List"
29 })
30
31 // To test 3 crumbs
32 // _breadcrumbs.push({
33 // to: "/games",
34 // label: "Test"
35 // })
36
37 if (_paths[0] == "maps") {
38 if (chapter) {
39 _breadcrumbs.push({
40 to: chapter.to,
41 label: chapter.label
42 });
43 }
44 }
45 }
46
47 setBreadcrumbs(_breadcrumbs);
48 }, [path])
49
50 return (
51 <nav className={styles.container}>
52 {breadcrumbs.map((crumb, i) => {
53 let _styles = ``;
54
55 if (i == 0) {
56 _styles += `${styles.first} `;
57 }
58
59 if (i + 1 == breadcrumbs.length) {
60 _styles += `${styles.last}`;
61 }
62
63 return <Link className={`${styles.crumb} ${_styles}`} key={i} to={crumb.to}>
64 <i className="triangle"></i>
65 <span className="translate-y-[-2px]">{crumb.label}</span>
66 </Link>
67 })}
68 </nav>
69 )
70}
71
72export default BreadcrumbNav;