Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Update responsive menu (#1135)

Luke Vella056534506131
diff --git a/apps/web/src/app/components/responsive-menu.tsx b/apps/web/src/app/components/responsive-menu.tsx
index 90bdf1081..679690516 100644
--- a/apps/web/src/app/components/responsive-menu.tsx
+++ b/apps/web/src/app/components/responsive-menu.tsx
@@ -1,24 +1,10 @@
"use client";
import { cn } from "@rallly/ui";
-import { Button } from "@rallly/ui/button";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@rallly/ui/select";
import Link from "next/link";
-import { usePathname, useRouter } from "next/navigation";
+import { usePathname } from "next/navigation";
import React from "react";
-import { useBreakpoint } from "@/utils/breakpoint";
-
-const ResponsiveMenuContext = React.createContext<"desktop" | "mobile">(
- "desktop",
-);
-
-function DesktopMenuItem({
+export function ResponsiveMenuItem({
href,
children,
}: {
@@ -30,10 +16,10 @@ function DesktopMenuItem({
<li>
<Link
className={cn(
- "flex h-9 min-w-0 grow items-center gap-x-2.5 rounded-md border px-2.5 text-sm font-medium",
+ "flex h-9 min-w-0 grow items-center gap-x-2.5 rounded-md px-2.5 text-sm font-medium",
pathname === href
- ? "bg-gray-50"
- : "text-gray-500 hover:bg-gray-100 active:bg-gray-200",
+ ? "text-foreground bg-gray-200"
+ : "hover:text-foreground focus:text-foreground border-transparent text-gray-500 focus:bg-gray-200",
)}
href={href}
>
@@ -43,76 +29,10 @@ function DesktopMenuItem({
);
}
-function MobileMenuItem({
- href,
- children,
-}: {
- href: string;
- children: React.ReactNode;
-}) {
+export function ResponsiveMenu({ children }: { children: React.ReactNode }) {
return (
- <SelectItem value={href}>
- <div className="flex items-center gap-x-2">{children}</div>
- </SelectItem>
+ <ul className="scrollbar-none -mx-3 flex gap-2.5 overflow-x-auto px-3">
+ {children}
+ </ul>
);
}
-
-export function ResponsiveMenuItem(props: {
- href: string;
- children: React.ReactNode;
-}) {
- const breakpoint = React.useContext(ResponsiveMenuContext);
-
- switch (breakpoint) {
- case "desktop":
- return <DesktopMenuItem {...props} />;
- case "mobile":
- return <MobileMenuItem {...props} />;
- }
-}
-
-function DesktopMenu({ children }: { children: React.ReactNode }) {
- return (
- <ResponsiveMenuContext.Provider value="desktop">
- <ul className="inline-flex gap-2.5">{children}</ul>
- </ResponsiveMenuContext.Provider>
- );
-}
-
-function MobileMenu({ children }: { children: React.ReactNode }) {
- const pathname = usePathname();
- const router = useRouter();
-
- if (!pathname) {
- return null;
- }
-
- return (
- <ResponsiveMenuContext.Provider value="mobile">
- <Select
- value={pathname}
- onValueChange={(destination) => {
- router.push(destination);
- }}
- >
- <SelectTrigger asChild className="w-full">
- <Button>
- <SelectValue />
- </Button>
- </SelectTrigger>
- <SelectContent>{children}</SelectContent>
- </Select>
- </ResponsiveMenuContext.Provider>
- );
-}
-
-export function ResponsiveMenu({ children }: { children?: React.ReactNode }) {
- const breakpoint = useBreakpoint();
-
- switch (breakpoint) {
- case "desktop":
- return <DesktopMenu>{children}</DesktopMenu>;
- case "mobile":
- return <MobileMenu>{children}</MobileMenu>;
- }
-}