diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c2d8c5f2..f7786b1d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,25 @@ import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; +/** + * Merge and deduplicate Tailwind classes without style conflicts + * + * @param inputs - Class names to merge + * @returns A string of class names, merged and deduplicated + */ export function cn(...inputs: Array) { return twMerge(clsx(inputs)); } + +/** + * Size breakpoints in pixels based on Tailwind CSS defaults. + * + * https://tailwindcss.com/docs/responsive-design + */ +export const breakpointPixels = { + sm: 640, + md: 768, + lg: 1024, + xl: 1280, + "2xl": 1536, +} as const; diff --git a/src/routes/_home.tsx b/src/routes/_home.tsx index 2cd09e41..ecc85828 100644 --- a/src/routes/_home.tsx +++ b/src/routes/_home.tsx @@ -1,10 +1,11 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { SiFacebook } from "@icons-pack/react-simple-icons"; +import { useViewportSize } from "@mantine/hooks"; import { FolderOpen, Mail, MapPin } from "lucide-react"; import { motion } from "motion/react"; import { Link, NavLink, Outlet, type To } from "react-router"; import { type Sponsor, getSponsors } from "~/api/sponsor"; -import { Button, buttonVariants } from "~/components/ui/button"; +import { buttonVariants } from "~/components/ui/button"; import { Drawer, DrawerClose, @@ -12,9 +13,11 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerTitle, DrawerTrigger, } from "~/components/ui/drawer"; import "~/home.css"; +import { breakpointPixels, cn } from "~/lib/utils"; import { navRoutes } from "~/routes"; // biome-ignore lint/style/noDefaultExport: Route Modules require default export https://reactrouter.com/start/framework/route-module @@ -30,23 +33,31 @@ export default function Layout() { } function AppHeader() { + const { width } = useViewportSize(); + const isMobile = width < breakpointPixels.md; + return (
-
-
- vektorprogrammet logo - -
-
-
- -
- + {isMobile ? ( + + ) : ( + <> +
+
+ vektorprogrammet logo + +
+
+
+ +
+ + )}
); } @@ -109,53 +120,59 @@ const MobileMenu = ({ routes, }: { routes: Array<{ name: string; path: To }> }) => { return ( -
- - -
- -
-
- - - -
-
    - {routes.map((route) => ( -
  • - - {route.name} - -
  • - ))} -
-
- -
-
+ + +
+ + + {"Tor"} + +
+
+ + + {"Navigasjonsmeny"} + - - - - - - -
-
+ + +
+ +
+ +
+
+ + + + {"Close"} + + + + ); };