From 5934b0d9a427a281636c5b7a294dcea6b8712a9d Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Tue, 17 Sep 2024 02:28:37 +0800 Subject: [PATCH] Update nav menu for desktop and mobile --- app/components/NavMenu.tsx | 264 ++++++++++++++++++++----------------- config/index.ts | 9 ++ types/index.ts | 3 + 3 files changed, 155 insertions(+), 121 deletions(-) diff --git a/app/components/NavMenu.tsx b/app/components/NavMenu.tsx index ab94d22..58106e5 100644 --- a/app/components/NavMenu.tsx +++ b/app/components/NavMenu.tsx @@ -3,17 +3,9 @@ import * as React from "react"; import { useState } from "react"; import Link from "next/link"; -import { - Battery, - Droplet, - Fuel, - type LucideIcon, - Menu, - Search, - TrendingUp, - Zap, -} from "lucide-react"; +import { ArrowRight, type LucideIcon, Menu, Search } from "lucide-react"; import { BrandLogo } from "@/components/BrandLogo"; +import Typography from "@/components/Typography"; import { UnreleasedFeature } from "@/components/UnreleasedFeature"; import { Accordion, @@ -34,104 +26,106 @@ import { } from "@/components/ui/navigation-menu"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { FUEL_TYPE_LINKS, VEHICLE_TYPE_LINKS } from "@/config"; import { cn } from "@/lib/utils"; -export const NavMenu = () => { - return ( - - +export const NavMenu = () => ( + + + + + + Monthly + + + + + Fuel Types + +
    + {/*
  • */} + {/* */} + {/* */} + {/* */} + {/*
    Monthly
    */} + {/*

    */} + {/* Car registration data for the latest month and previous*/} + {/* months, broken down by fuel type and vehicle type.*/} + {/*

    */} + {/* */} + {/*
    */} + {/*
  • */} + {FUEL_TYPE_LINKS.map(({ label, description, href, icon }) => ( + + {description} + + ))} +
+
+
+ + Vehicle Types + +
    + {VEHICLE_TYPE_LINKS.map(({ label, description, href, icon }) => ( + + {description} + + ))} +
+
+
+ - Cars + COE
    -
  • - - - -
    Monthly
    -

    - Car registration data for the latest month and previous - months, broken down by fuel type and vehicle type. -

    - -
    -
  • - - Petrol Cars + + Latest - - Hybrid Cars - - - Electric Cars - - - Diesel Cars + + Historical
- - - COE - -
    - - Latest - - - Historical - -
-
-
-
-
-
- ); -}; + +
+
+); -export const DesktopNavMenu = () => { - return ( -
- - -
-
- -
- -
+export const DesktopNavMenu = () => ( +
+ + +
+
+ +
+
- -
- ); -}; +
+ +
+); export const MobileNavMenu = () => { const [isOpen, setIsOpen] = useState(false); - const links = [ - { title: "Overview", link: "/cars" }, - { title: "Petrol Cars", link: "/cars/petrol" }, - { title: "Hybrid Cars", link: "/cars/hybrid" }, - { title: "Electric Cars", link: "/cars/electric" }, - { title: "Diesel Cars", link: "/cars/diesel" }, - ]; - return (
@@ -143,7 +137,7 @@ export const MobileNavMenu = () => { - +
{ />
- - - - Cars - - - - - - - + + + Cars + + COE + + + + + setIsOpen(false)}> + + Monthly + + + + + Fuel Type + +
+ {FUEL_TYPE_LINKS.map( + ({ label, description, href, icon: Icon }) => ( + setIsOpen(false)} + > +
+ {Icon && } +
{label}
+
+ {description} + + ), + )} +
+
+
+ + Vehicle Type + +
+ {VEHICLE_TYPE_LINKS.map(({ label, href }) => ( + setIsOpen(false)} + > + {label} + + ))} +
+
+
+
+
+
+
diff --git a/config/index.ts b/config/index.ts index 05e3163..24f661a 100644 --- a/config/index.ts +++ b/config/index.ts @@ -1,3 +1,4 @@ +import { Battery, Droplet, Fuel, Zap } from "lucide-react"; import type { AppEnv, LinkItem } from "@/types"; const DOMAIN_NAME = "sgcarstrends.com"; @@ -48,19 +49,27 @@ export const FEATURE_FLAG_UNRELEASED = export const FUEL_TYPE_LINKS: LinkItem[] = [ { label: "Petrol", + description: "Internal Combustion Engine (ICE) vehicles", href: "/cars/petrol", + icon: Fuel, }, { label: "Hybrid", + description: "Includes Petrol, Diesel and Plug-In types", href: "/cars/hybrid", + icon: Zap, }, { label: "Electric", + description: "Battery Electric Vehicles (BEV)", href: "/cars/electric", + icon: Battery, }, { label: "Diesel", + description: "Compression-ignition engine vehicles", href: "/cars/diesel", + icon: Droplet, }, ].sort((a, b) => a.label.localeCompare(b.label)); diff --git a/types/index.ts b/types/index.ts index 2a7c149..f5aaf7d 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,4 +1,5 @@ import { FUEL_TYPE } from "@/config"; +import type { LucideIcon } from "lucide-react"; export type VEHICLE_TYPE = | "Coupe/ Convertible" @@ -83,4 +84,6 @@ export enum AppEnv { export interface LinkItem { label: string; href: string; + description?: string; + icon?: LucideIcon; }