The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add home page / dashboard links to NavLogo context menu
Tim Wilson8b7e8e272ec4
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsxindex c240cefb5e..416f6d9e95 100644--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx@@ -5,7 +5,7 @@ import UserDropdown from "@/ui/layout/user-dropdown";import UserSurveyPopup from "@/ui/layout/user-survey";import WorkspaceSwitcher from "@/ui/layout/workspace-switcher";import { Divider } from "@/ui/shared/icons";-import { Logo, MaxWidthWrapper } from "@dub/ui";+import { MaxWidthWrapper, NavLogo } from "@dub/ui";import { constructMetadata } from "@dub/utils";import Link from "next/link";import { ReactNode, Suspense } from "react";@@ -23,7 +23,7 @@ export default function Layout({ children }: { children: ReactNode }) {<div className="flex h-16 items-center justify-between"><div className="flex items-center"><Link href="/" className="hidden sm:block">- <Logo className="h-8 w-8 transition-all duration-75 active:scale-95" />+ <NavLogo variant="symbol" /></Link><Divider className="hidden h-8 w-8 text-gray-200 sm:ml-3 sm:block" /><WorkspaceSwitcher />diff --git a/packages/ui/src/nav-logo.tsx b/packages/ui/src/nav-logo.tsxindex d82654ab61..b60eae2de2 100644--- a/packages/ui/src/nav-logo.tsx+++ b/packages/ui/src/nav-logo.tsx@@ -1,8 +1,7 @@"use client";import * as Popover from "@radix-ui/react-popover";-import { BoxSelect, Home, Type } from "lucide-react";-import { useRouter } from "next/navigation";+import { Home, LayoutGrid, Type } from "lucide-react";import { MouseEvent, useCallback, useState } from "react";import { toast } from "sonner";import { Button } from "./button";@@ -54,9 +53,15 @@ async function copy(text: string) {* The Dub logo with a custom context menu for copying/navigation,* for use in the top site nav*/-export default function NavLogo({ className }: { className?: string }) {- const router = useRouter();-+export function NavLogo({+ variant = "full",+ isInApp = true,+ className,+}: {+ variant?: "full" | "symbol";+ isInApp?: boolean;+ className?: string;+}) {const [isPopoverOpen, setIsPopoverOpen] = useState(false);const handleContextMenu = useCallback((e: MouseEvent<HTMLDivElement>) => {@@ -68,7 +73,11 @@ export default function NavLogo({ className }: { className?: string }) {<Popover.Root open={isPopoverOpen} onOpenChange={setIsPopoverOpen}><Popover.Anchor asChild><div onContextMenu={handleContextMenu}>- <LogoType className={className} />+ {variant === "full" ? (+ <LogoType className={className} />+ ) : (+ <Logo className="h-8 w-8 transition-all duration-75 active:scale-95" />+ )}</div></Popover.Anchor><Popover.Portal>@@ -96,20 +105,31 @@ export default function NavLogo({ className }: { className?: string }) {icon={<Type strokeWidth={2} className="h-4 w-4" />}className="h-9 justify-start px-3 font-medium hover:text-gray-700"/>- <Button+ {/* TODO: Uncomment once /brand page is live */}+ {/* <Buttontext="Brand Guidelines"variant="outline"onClick={() => window.open("https://dub.co/brand", "_blank")}icon={<BoxSelect strokeWidth={2} className="h-4 w-4" />}className="h-9 justify-start px-3 font-medium hover:text-gray-700"- />- <Button- text="Home Page"- variant="outline"- onClick={() => window.open("https://dub.co", "_blank")}- icon={<Home strokeWidth={2} className="h-4 w-4" />}- className="h-9 justify-start px-3 font-medium hover:text-gray-700"- />+ /> */}+ {isInApp ? (+ <Button+ text="Home Page"+ variant="outline"+ onClick={() => window.open("https://dub.co", "_blank")}+ icon={<Home strokeWidth={2} className="h-4 w-4" />}+ className="h-9 justify-start px-3 font-medium hover:text-gray-700"+ />+ ) : (+ <Button+ text="Dashboard"+ variant="outline"+ onClick={() => window.open("https://app.dub.co", "_blank")}+ icon={<LayoutGrid strokeWidth={2} className="h-4 w-4" />}+ className="h-9 justify-start px-3 font-medium hover:text-gray-700"+ />+ )}</div></Popover.Content></Popover.Portal>diff --git a/packages/ui/src/nav.tsx b/packages/ui/src/nav.tsxindex 0f19ddeadd..6f28e23f11 100644--- a/packages/ui/src/nav.tsx+++ b/packages/ui/src/nav.tsx@@ -10,7 +10,7 @@ import useSWR from "swr";import { FEATURES_LIST } from "./content";import { useScroll } from "./hooks";import { MaxWidthWrapper } from "./max-width-wrapper";-import NavLogo from "./nav-logo";+import { NavLogo } from "./nav-logo";export const navItems = [{