Skip to content

Commit f0b6e12

Browse files
committed
fix: fixed navigation for the time being
1 parent 788ba26 commit f0b6e12

File tree

14 files changed

+1432
-754
lines changed

14 files changed

+1432
-754
lines changed

apps/forge/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
<!-- Dynamically load Futura -->
3535
<script>
36-
const isDevelopment = process.env.NODE_ENV === 'development';
37-
const fontDir = isDevelopment ? 'http://localhost:4000/fonts' : '/cdn/fonts';
36+
const isDevelopment = '%MODE%' === 'development';
37+
const fontUrl = isDevelopment ? 'http://localhost:4000/fonts' : 'https://cdn.iforge.sheffield.ac.uk/fonts';
3838

3939
const style = document.createElement('style');
4040
style.innerHTML = `

apps/forge/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"@radix-ui/react-slot": "^1.1.0",
2727
"@reduxjs/toolkit": "^2.2.8",
2828
"@tailwindcss/typography": "^0.5.15",
29-
"@tanstack/react-query": "^5.59.3",
30-
"@tanstack/react-query-devtools": "^5.59.3",
31-
"@tanstack/react-router": "^1.63.5",
29+
"@tanstack/react-query": "^5.59.13",
30+
"@tanstack/react-query-devtools": "^5.59.13",
31+
"@tanstack/react-router": "^1.64.3",
3232
"@tanstack/react-table": "^8.20.5",
3333
"@tanstack/router-devtools": "1.62.1",
3434
"@udecode/plate-serializer-md": "^33.0.0",
@@ -41,7 +41,7 @@
4141
"embla-carousel-autoplay": "^8.3.0",
4242
"embla-carousel-react": "^8.3.0",
4343
"embla-carousel-wheel-gestures": "^8.0.1",
44-
"framer-motion": "^11.11.4",
44+
"framer-motion": "^11.11.8",
4545
"fuse.js": "^7.0.0",
4646
"jotai": "^2.10.0",
4747
"js-cookie": "^3.0.5",
@@ -53,7 +53,7 @@
5353
"postcss": "^8.4.47",
5454
"posthog-js": "^1.167.0",
5555
"react": "^18.3.1",
56-
"react-cookie": "^7.2.0",
56+
"react-cookie": "^7.2.1",
5757
"react-day-picker": "^9.1.3",
5858
"react-dom": "^18.3.1",
5959
"react-helmet-async": "^2.0.5",
@@ -76,13 +76,13 @@
7676
"zod": "^3.23.8"
7777
},
7878
"devDependencies": {
79-
"@tanstack/router-cli": "^1.63.5",
80-
"@tanstack/router-vite-plugin": "^1.63.5",
79+
"@tanstack/router-cli": "^1.64.0",
80+
"@tanstack/router-vite-plugin": "^1.64.0",
8181
"@types/js-cookie": "^3.0.6",
8282
"@types/md5": "^2.3.5",
8383
"@types/node": "^22.7.5",
8484
"@types/react": "^18.3.11",
85-
"@types/react-dom": "^18.3.0",
85+
"@types/react-dom": "^18.3.1",
8686
"@types/uuid": "^9.0.8",
8787
"@vitejs/plugin-react-swc": "^3.7.1",
8888
"sharp": "^0.33.5",

apps/forge/src/components/dev/Tailwind-Indicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const TailwindIndicator = () => {
2-
if (process.env.NODE_ENV === "production") return null;
2+
if (import.meta.env.PROD) return null;
33

44
return (
55
<div className="fixed top-1 left-1 z-50 flex h-6 w-6 items-center justify-center bg-gray-800 p-3 rounded-lg font-mono text-xs text-white">

apps/forge/src/components/navbar/appNav/appLinkDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const DropdownLink: React.FC<DropdownLinkProps> = ({ link, onClick, activeId, on
1717
const isActive = linkItem.id === activeId;
1818

1919
// Link styles
20-
const linkClasses = `flex justify-center items-center p-2 text-sm font-medium rounded-md text-card-foreground hover:bg-accent ${
20+
const linkClasses = `flex justify-center items-center p-2 text-sm font-medium rounded-md text-card-foreground hover:bg-accent font-futura ${
2121
isActive ? "border-2 border-accent/40" : ""
2222
}`;
2323

apps/forge/src/components/navbar/appSwitcher/ListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { cn } from "@/lib/utils";
2+
import { RoutePath } from "@/types/router";
23
import { Link } from "@tanstack/react-router";
34
import { NavigationMenuLink } from "@ui/components/ui/navigation-menu";
45
import React, { AnchorHTMLAttributes, ReactNode } from "react";
56

67
interface ListItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
78
icon?: ReactNode;
89
title: string;
9-
to: string;
10+
to: RoutePath;
1011
onClick?: () => void;
1112
}
1213

apps/forge/src/components/navbar/appSwitcher/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import React from "react";
21
import ContextMenuWrapper from "@/components/navbar/appSwitcher/ContextMenu.tsx";
32
import ListItem from "@/components/navbar/appSwitcher/ListItem";
4-
import useCurrentApp from "@/hooks/useCurrentApp.ts";
5-
import { cn } from "@/lib/utils.ts";
3+
import { cn, currentAppToColor } from "@/lib/utils.ts";
64
import { Link } from "@tanstack/react-router";
75
import {
86
NavigationMenu,
@@ -13,6 +11,7 @@ import {
1311
NavigationMenuTrigger,
1412
} from "@ui/components/ui/navigation-menu";
1513
import { BookOpen, PenLine, Printer } from "lucide-react";
14+
import useCurrentApp from "@/hooks/useCurrentApp";
1615

1716
interface AppSwitcherProps {
1817
onLinkClick?: () => void;
@@ -32,7 +31,9 @@ export default function AppSwitcher({ onLinkClick }: AppSwitcherProps) {
3231
<NavigationMenuList>
3332
<NavigationMenuItem>
3433
<ContextMenuWrapper>
35-
<NavigationMenuTrigger className="bg-card font-futura">iForge | {currentapp}</NavigationMenuTrigger>
34+
<NavigationMenuTrigger className="bg-card font-futura">
35+
<span className={`border-b-2 ${currentAppToColor(currentapp)}`}>iForge | {currentapp}</span>
36+
</NavigationMenuTrigger>
3637
</ContextMenuWrapper>
3738
<NavigationMenuContent>
3839
<ul className="grid gap-3 p-4 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">

apps/forge/src/components/navbar/userNav/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useUser } from "@/lib/utils";
33
import { Link } from "@tanstack/react-router";
44
import { Badge } from "@ui/components/ui/badge";
55
import { Button } from "@ui/components/ui/button";
6-
import React from "react";
76

87
import { USER_EMAIL_DOMAIN } from "@/config/constants.ts";
98
import {

apps/forge/src/components/title/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import React from "react";
33
import { Helmet } from "react-helmet-async";
44

55
interface TitleProps {
6-
prompt: string;
6+
prompt: string;
77
}
88

99
const Title: React.FC<TitleProps> = ({ prompt }) => {
10-
const isDevelopment = process.env.NODE_ENV === "development";
10+
const isDevelopment = import.meta.env.DEV;
1111

12-
return (
13-
<Helmet>
14-
<title>{isDevelopment ? `DEV iForge | ${prompt}` : `iForge | ${prompt}`}</title>
15-
</Helmet>
16-
);
12+
return (
13+
<Helmet>
14+
<title>{isDevelopment ? `DEV iForge | ${prompt}` : `iForge | ${prompt}`}</title>
15+
</Helmet>
16+
);
1717
};
1818

1919
export default Title;
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
import { Apps } from "@/types/app.ts";
2-
import { useMatches, useParentMatches } from "@tanstack/react-router";
2+
import { useLocation } from "@tanstack/react-router";
3+
import { useMemo } from "react";
34

4-
const useCurrentApp = (): Apps | undefined => {
5-
const parent = useParentMatches();
6-
const matchWithTitle = useMatches()
7-
.reverse()
8-
.find((d) => d.staticData?.title);
5+
const useCurrentApp = (): Apps => {
6+
const pathname = useLocation({
7+
select: (location) => location.pathname,
8+
});
99

10-
if (!matchWithTitle) {
11-
if (parent.length === 0) {
12-
return "Error"; // not found
13-
}
14-
console.error("No match with title found", parent);
15-
throw new Error("Page has no title. This should have been set in the root directory in a file with the app's name");
16-
}
10+
return useMemo(() => {
11+
// Split the pathname and get the first segment
12+
const segments = pathname.split("/").filter(Boolean);
13+
const firstSegment = segments[0]?.toLowerCase();
1714

18-
return matchWithTitle.staticData.title;
15+
switch (firstSegment) {
16+
case "":
17+
case undefined:
18+
return "Main";
19+
case "signin":
20+
return "Sign In";
21+
case "printing":
22+
return "Printing";
23+
case "user":
24+
return "User";
25+
case "admin":
26+
return "Admin";
27+
case "training":
28+
return "Training";
29+
case "auth":
30+
return "Auth";
31+
case "socials":
32+
return "Socials";
33+
default:
34+
return "Error";
35+
}
36+
}, [pathname]); // Only recalculate when pathname changes
1937
};
2038

2139
export default useCurrentApp;

apps/forge/src/lib/utils.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { RootState } from "@/redux/store";
22
import { ErrorCodes } from "@ignis/errors";
3-
import { Location, Training } from "@ignis/types/training";
43
import { deserializeMd as deserializeMd_ } from "@udecode/plate-serializer-md";
54
import { createPlateEditor } from "@ui/components/plate-ui/plate-editor";
65
import { isAxiosError } from "axios";
76
import { type ClassValue, clsx } from "clsx";
87
import md5 from "md5";
98
import { useSelector } from "react-redux";
109
import { twMerge } from "tailwind-merge";
11-
import { LOCATIONS, UCARD_LENGTH } from "./constants";
10+
import { UCARD_LENGTH } from "./constants";
11+
import { Apps } from "@/types/app";
1212

1313
export function cn(...inputs: ClassValue[]) {
1414
return twMerge(clsx(inputs));
@@ -98,3 +98,24 @@ export function serializeTrainingTags(badges_: TrainingTag[]): Required<Training
9898

9999
return training as Required<TrainingForTags>;
100100
}
101+
102+
export function currentAppToColor(currentApp: Apps): string {
103+
switch (currentApp) {
104+
case "Admin":
105+
return "border-purple-600";
106+
case "Auth":
107+
return "border-fuchisa-600";
108+
case "Main":
109+
return "border-red-700";
110+
case "Printing":
111+
return "border-orange-500";
112+
case "Sign In":
113+
return "border-rose-700";
114+
case "Training":
115+
return "border-green-700";
116+
case "User":
117+
return "border-indigo-600";
118+
default:
119+
return "";
120+
}
121+
}

0 commit comments

Comments
 (0)