Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Added NavigationMenu for marketing pages

Steven Tey1dced4b85d1d
diff --git a/components/layout/home/index.tsx b/components/layout/home/index.tsx
index 5f6e4853ef..23fc0a3dc9 100644
--- a/components/layout/home/index.tsx
+++ b/components/layout/home/index.tsx
@@ -7,6 +7,7 @@ import { Github, Logo, Twitter } from "@/components/shared/icons";
import Meta from "../meta";
import { motion, AnimatePresence } from "framer-motion";
import { FADE_IN_ANIMATION_SETTINGS } from "@/lib/constants";
+import NavigationMenu from "./navigation-menu";
export default function HomeLayout({
meta,
@@ -40,33 +41,39 @@ export default function HomeLayout({
</Link>
</div>
- <AnimatePresence>
- {!session && status !== "loading" ? (
- <motion.a
- {...FADE_IN_ANIMATION_SETTINGS}
- href={
- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "https://app.dub.sh/login"
- : "http://app.localhost:3000/login"
- }
- className="rounded-full border border-black bg-black py-1.5 px-5 text-sm text-white transition-all hover:bg-white hover:text-black"
- >
- Sign in
- </motion.a>
- ) : (
- <motion.a
- {...FADE_IN_ANIMATION_SETTINGS}
- href={
- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "https://app.dub.sh"
- : "http://app.localhost:3000"
- }
- className="rounded-full border border-black bg-black py-1.5 px-5 text-sm text-white transition-all hover:bg-white hover:text-black"
- >
- Dashboard
- </motion.a>
+ <NavigationMenu />
+
+ <div className="w-24">
+ {status !== "loading" && (
+ <AnimatePresence>
+ {session ? (
+ <motion.a
+ {...FADE_IN_ANIMATION_SETTINGS}
+ href={
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "https://app.dub.sh"
+ : "http://app.localhost:3000"
+ }
+ className="rounded-full border border-black bg-black py-1.5 px-5 text-sm text-white transition-all hover:bg-white hover:text-black"
+ >
+ Dashboard
+ </motion.a>
+ ) : (
+ <motion.a
+ {...FADE_IN_ANIMATION_SETTINGS}
+ href={
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "https://app.dub.sh/login"
+ : "http://app.localhost:3000/login"
+ }
+ className="rounded-full border border-black bg-black py-1.5 px-5 text-sm text-white transition-all hover:bg-white hover:text-black"
+ >
+ Sign in
+ </motion.a>
+ )}
+ </AnimatePresence>
)}
- </AnimatePresence>
+ </div>
</div>
</div>
</div>
diff --git a/components/layout/home/navigation-menu.tsx b/components/layout/home/navigation-menu.tsx
new file mode 100644
index 0000000000..ef5fb647c1
--- /dev/null
+++ b/components/layout/home/navigation-menu.tsx
@@ -0,0 +1,183 @@
+import { ChevronDown } from "@/components/shared/icons";
+import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
+import clsx from "classnames";
+import React from "react";
+
+const comparisons = [
+ {
+ title: "Bitly",
+ slug: "bitly",
+ },
+ {
+ title: "Rebrandly",
+ slug: "rebrandly",
+ },
+ {
+ title: "Short.io",
+ slug: "short-io",
+ },
+ {
+ title: "Cuttly",
+ slug: "cuttly",
+ },
+];
+
+export default function NavigationMenu() {
+ return (
+ <NavigationMenuPrimitive.Root className="relative hidden md:block">
+ <NavigationMenuPrimitive.List className="flex flex-row space-x-2 p-2">
+ <NavigationMenuPrimitive.Item>
+ <NavigationMenuPrimitive.Trigger
+ className={clsx(
+ "group flex items-center space-x-2 rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",
+ "text-sm font-medium",
+ "text-gray-700 dark:text-gray-100",
+ "focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",
+ )}
+ >
+ <p>Features</p>
+ <ChevronDown className="h-4 w-4 transition-all group-radix-state-open:rotate-180" />
+ </NavigationMenuPrimitive.Trigger>
+
+ <NavigationMenuPrimitive.Content
+ className={clsx(
+ "absolute top-0 left-0 w-auto rounded-lg",
+ "radix-motion-from-start:animate-enter-from-left",
+ "radix-motion-from-end:animate-enter-from-right",
+ "radix-motion-to-start:animate-exit-to-left",
+ "radix-motion-to-end:animate-exit-to-right",
+ )}
+ >
+ <div className="w-[21rem] p-3 lg:w-[23rem]">
+ <div className="grid grid-cols-6 gap-4">
+ <div className="col-span-2 w-full rounded-md bg-gray-100 p-4 dark:bg-gray-900"></div>
+
+ <div className="col-span-4 flex w-full flex-col space-y-3 rounded-md bg-gray-100 p-4 dark:bg-gray-900">
+ <div className="h-12 w-full rounded-md bg-white dark:bg-gray-700"></div>
+ <div className="h-12 w-full rounded-md bg-white dark:bg-gray-700"></div>
+ <div className="h-12 w-full rounded-md bg-white dark:bg-gray-700"></div>
+ <div className="h-12 w-full rounded-md bg-white dark:bg-gray-700"></div>
+ </div>
+ </div>
+ </div>
+ </NavigationMenuPrimitive.Content>
+ </NavigationMenuPrimitive.Item>
+
+ <NavigationMenuPrimitive.Item>
+ <NavigationMenuPrimitive.Trigger
+ className={clsx(
+ "group flex items-center space-x-2 rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",
+ "text-sm font-medium text-gray-700 dark:text-gray-100",
+ "focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",
+ )}
+ >
+ <p>Comparisons</p>
+ <ChevronDown className="h-4 w-4 transition-all group-radix-state-open:rotate-180" />
+ </NavigationMenuPrimitive.Trigger>
+
+ <NavigationMenuPrimitive.Content
+ className={clsx(
+ "absolute top-0 left-0 w-auto rounded-lg",
+ "radix-motion-from-start:animate-enter-from-left",
+ "radix-motion-from-end:animate-enter-from-right",
+ "radix-motion-to-start:animate-exit-to-left",
+ "radix-motion-to-end:animate-exit-to-right",
+ )}
+ >
+ <div className="w-[16rem] p-3 lg:w-[18rem]">
+ <div className="grid w-full gap-2">
+ {comparisons.map(({ title, slug }) => (
+ <NavigationMenuPrimitive.Link
+ key={slug}
+ className={clsx(
+ "w-full rounded-md px-4 py-3 hover:bg-gray-100 dark:hover:bg-gray-900",
+ "focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",
+ )}
+ href={`/vs/${slug}`}
+ >
+ <span className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ {title}
+ </span>
+
+ <div className="mt-1 text-sm text-gray-500 dark:text-gray-400">
+ Lorem ipsum dolor sit amet.
+ </div>
+ </NavigationMenuPrimitive.Link>
+ ))}
+ </div>
+ </div>
+ </NavigationMenuPrimitive.Content>
+ </NavigationMenuPrimitive.Item>
+
+ <NavigationMenuPrimitive.Item asChild>
+ <NavigationMenuPrimitive.Link
+ href="/pricing"
+ className={clsx(
+ "rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",
+ "text-sm font-medium text-gray-700 dark:text-gray-100",
+ )}
+ >
+ Pricing
+ </NavigationMenuPrimitive.Link>
+ </NavigationMenuPrimitive.Item>
+
+ <NavigationMenuPrimitive.Item asChild>
+ <NavigationMenuPrimitive.Link
+ href="/blog"
+ className={clsx(
+ "rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",
+ "text-sm font-medium text-gray-700 dark:text-gray-100",
+ )}
+ >
+ Blog
+ </NavigationMenuPrimitive.Link>
+ </NavigationMenuPrimitive.Item>
+
+ <NavigationMenuPrimitive.Item asChild>
+ <NavigationMenuPrimitive.Link
+ href="/docs"
+ className={clsx(
+ "rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900",
+ "text-sm font-medium text-gray-700 dark:text-gray-100",
+ )}
+ >
+ Docs
+ </NavigationMenuPrimitive.Link>
+ </NavigationMenuPrimitive.Item>
+
+ <NavigationMenuPrimitive.Indicator
+ className={clsx(
+ "z-10",
+ "top-[100%] flex h-2 items-end justify-center overflow-hidden",
+ "radix-state-visible:animate-fade-in",
+ "radix-state-hidden:animate-fade-out",
+ "transition-[width_transform] duration-[250ms] ease-[ease]",
+ )}
+ >
+ <div className="relative top-1 h-2 w-2 rotate-45 bg-white dark:bg-gray-800" />
+ </NavigationMenuPrimitive.Indicator>
+ </NavigationMenuPrimitive.List>
+
+ <div
+ className={clsx(
+ "absolute flex justify-center",
+ "left-[-30%] top-[100%] w-[140%]",
+ )}
+ style={{
+ perspective: "2000px",
+ }}
+ >
+ <NavigationMenuPrimitive.Viewport
+ className={clsx(
+ "relative mt-2 overflow-hidden rounded-md bg-white shadow-lg dark:bg-gray-800",
+ "w-radix-navigation-menu-viewport",
+ "h-radix-navigation-menu-viewport",
+ "radix-state-open:animate-scale-in-content",
+ "radix-state-closed:animate-scale-out-content",
+ "origin-[top_center] transition-[width_height] duration-300 ease-[ease]",
+ )}
+ />
+ </div>
+ </NavigationMenuPrimitive.Root>
+ );
+}
diff --git a/package.json b/package.json
index e48e334a02..6ff80c33ce 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"@planetscale/database": "^1.5.0",
"@prisma/client": "^4.6.1",
"@radix-ui/react-accordion": "^1.0.1",
+ "@radix-ui/react-navigation-menu": "^1.1.2",
"@radix-ui/react-popover": "^1.0.2",
"@radix-ui/react-slider": "^1.1.0",
"@radix-ui/react-switch": "^1.0.1",
@@ -63,6 +64,7 @@
"stripe": "^11.1.0",
"swr": "^1.3.0",
"tailwind-scrollbar-hide": "^1.1.7",
+ "tailwindcss-radix": "^2.8.0",
"topojson-client": "^3.1.0",
"use-debounce": "^8.0.4"
},
diff --git a/tailwind.config.js b/tailwind.config.js
index e94030afcf..ac223feeaf 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -22,6 +22,15 @@ module.exports = {
"slide-right-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1)",
"slide-down-fade": "slide-down-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1)",
"slide-left-fade": "slide-left-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1)",
+ // Navigation menu
+ "enter-from-right": "enter-from-right 0.25s ease",
+ "enter-from-left": "enter-from-left 0.25s ease",
+ "exit-to-right": "exit-to-right 0.25s ease",
+ "exit-to-left": "exit-to-left 0.25s ease",
+ "scale-in-content": "scale-in-content 0.2s ease",
+ "scale-out-content": "scale-out-content 0.2s ease",
+ "fade-in": "fade-in 0.2s ease",
+ "fade-out": "fade-out 0.2s ease",
// Custom wiggle animation
wiggle: "wiggle 0.75s infinite",
},
@@ -43,6 +52,31 @@ module.exports = {
"0%": { opacity: 0, transform: "translateX(2px)" },
"100%": { opacity: 1, transform: "translateX(0)" },
},
+ // Navigation menu
+ "enter-from-right": {
+ "0%": { transform: "translateX(200px)", opacity: 0 },
+ "100%": { transform: "translateX(0)", opacity: 1 },
+ },
+ "enter-from-left": {
+ "0%": { transform: "translateX(-200px)", opacity: 0 },
+ "100%": { transform: "translateX(0)", opacity: 1 },
+ },
+ "exit-to-right": {
+ "0%": { transform: "translateX(0)", opacity: 1 },
+ "100%": { transform: "translateX(200px)", opacity: 0 },
+ },
+ "exit-to-left": {
+ "0%": { transform: "translateX(0)", opacity: 1 },
+ "100%": { transform: "translateX(-200px)", opacity: 0 },
+ },
+ "scale-in-content": {
+ "0%": { transform: "rotateX(-30deg) scale(0.9)", opacity: 0 },
+ "100%": { transform: "rotateX(0deg) scale(1)", opacity: 1 },
+ },
+ "scale-out-content": {
+ "0%": { transform: "rotateX(0deg) scale(1)", opacity: 1 },
+ "100%": { transform: "rotateX(-10deg) scale(0.95)", opacity: 0 },
+ },
// Custom wiggle animation
wiggle: {
"0%, 100%": {
@@ -60,17 +94,8 @@ module.exports = {
},
plugins: [
require("@tailwindcss/forms"),
- require("tailwind-scrollbar-hide"),
require("@tailwindcss/line-clamp"),
- plugin(({ addVariant }) => {
- addVariant("radix-state-checked", '&[data-state="checked"]');
- addVariant("radix-state-unchecked", '&[data-state="unchecked"]');
- addVariant("radix-state-open", '&[data-state="open"]');
- addVariant("radix-state-closed", '&[data-state="closed"]');
- addVariant(
- "group-radix-state-open",
- ':merge(.group)[data-state="open"] &',
- );
- }),
+ require("tailwind-scrollbar-hide"),
+ require("tailwindcss-radix")(),
],
};
diff --git a/yarn.lock b/yarn.lock
index cbc4198869..470b71edf0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -884,6 +884,17 @@
"@radix-ui/react-primitive" "1.0.1"
"@radix-ui/react-slot" "1.0.1"
+"@radix-ui/[email protected]":
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-collection/-/react-collection-1.0.2.tgz#d50da00bfa2ac14585319efdbbb081d4c5a29a97"
+ integrity sha512-s8WdQQ6wNXpaxdZ308KSr8fEWGrg4un8i4r/w7fhiS4ElRNjk5rRcl0/C6TANG2LvLOGIxtzo/jAg6Qf73TEBw==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-context" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.2"
+ "@radix-ui/react-slot" "1.0.1"
+
"@radix-ui/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz#37595b1f16ec7f228d698590e78eeed18ff218ae"
@@ -917,6 +928,18 @@
"@radix-ui/react-use-callback-ref" "1.0.0"
"@radix-ui/react-use-escape-keydown" "1.0.2"
+"@radix-ui/[email protected]":
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.3.tgz#63844d8e6bbcd010a513e7176d051c3c4044e09e"
+ integrity sha512-nXZOvFjOuHS1ovumntGV7NNoLaEp9JEvTht3MBjP44NSW5hUKj/8OnfN3+8WmB+CEhN44XaGhpHoSsUIEl5P7Q==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/primitive" "1.0.0"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.2"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+ "@radix-ui/react-use-escape-keydown" "1.0.2"
+
"@radix-ui/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-focus-guards/-/react-focus-guards-1.0.0.tgz#339c1c69c41628c1a5e655f15f7020bf11aa01fa"
@@ -942,6 +965,27 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-use-layout-effect" "1.0.0"
+"@radix-ui/react-navigation-menu@^1.1.2":
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.1.2.tgz#ca5ee35ddbc4e57a9403be92f9573435173e35c8"
+ integrity sha512-1fSjOAGTThYSgJ5pENG2V8we7+6KDbfbiyt66HmLTeo0W3PAmmciclm0o97VlcVZW7q5Vg2hN7Cbj4XKo5u2sw==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/primitive" "1.0.0"
+ "@radix-ui/react-collection" "1.0.2"
+ "@radix-ui/react-compose-refs" "1.0.0"
+ "@radix-ui/react-context" "1.0.0"
+ "@radix-ui/react-direction" "1.0.0"
+ "@radix-ui/react-dismissable-layer" "1.0.3"
+ "@radix-ui/react-id" "1.0.0"
+ "@radix-ui/react-presence" "1.0.0"
+ "@radix-ui/react-primitive" "1.0.2"
+ "@radix-ui/react-use-callback-ref" "1.0.0"
+ "@radix-ui/react-use-controllable-state" "1.0.0"
+ "@radix-ui/react-use-layout-effect" "1.0.0"
+ "@radix-ui/react-use-previous" "1.0.0"
+ "@radix-ui/react-visually-hidden" "1.0.2"
+
"@radix-ui/react-popover@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@radix-ui/react-popover/-/react-popover-1.0.2.tgz#f761c8aafb61519522b8e80501c589e619073a2c"
@@ -1005,6 +1049,14 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-slot" "1.0.1"
+"@radix-ui/[email protected]":
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-1.0.2.tgz#54e22f49ca59ba88d8143090276d50b93f8a7053"
+ integrity sha512-zY6G5Qq4R8diFPNwtyoLRZBxzu1Z+SXMlfYpChN7Dv8gvmx9X3qhDqiLWvKseKVJMuedFeU/Sa0Sy/Ia+t06Dw==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-slot" "1.0.1"
+
"@radix-ui/react-slider@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@radix-ui/react-slider/-/react-slider-1.1.0.tgz#b3fdaca27619150e9e6067ad9f979a4535f68d5e"
@@ -1125,6 +1177,14 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-primitive" "1.0.1"
+"@radix-ui/[email protected]":
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.0.2.tgz#29b117a59ef09a984bdad12cb98d81e8350be450"
+ integrity sha512-qirnJxtYn73HEk1rXL12/mXnu2rwsNHDID10th2JGtdK25T9wX+mxRmGt7iPSahw512GbZOc0syZX1nLQGoEOg==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/react-primitive" "1.0.2"
+
"@radix-ui/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-1.0.0.tgz#0dc8e6a829ea2828d53cbc94b81793ba6383bf3c"
@@ -6313,6 +6373,11 @@ tailwind-scrollbar-hide@^1.1.7:
resolved "https://registry.yarnpkg.com/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz#90b481fb2e204030e3919427416650c54f56f847"
integrity sha512-X324n9OtpTmOMqEgDUEA/RgLrNfBF/jwJdctaPZDzB3mppxJk7TLIDmOreEDm1Bq4R9LSPu4Epf8VSdovNU+iA==
+tailwindcss-radix@^2.8.0:
+ version "2.8.0"
+ resolved "https://registry.yarnpkg.com/tailwindcss-radix/-/tailwindcss-radix-2.8.0.tgz#bac081a3a497cdc30d70f8e7425b795ffde0020a"
+ integrity sha512-1k1UfoIYgVyBl13FKwwoKavjnJ5VEaUClCTAsgz3VLquN4ay/lyaMPzkbqD71sACDs2fRGImytAUlMb4TzOt1A==
+
tailwindcss@^3.1.8, tailwindcss@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.2.4.tgz#afe3477e7a19f3ceafb48e4b083e292ce0dc0250"