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.

add product hunt banner

Steven Tey03afa158f3c8
diff --git a/apps/web/app/[domain]/layout.tsx b/apps/web/app/[domain]/layout.tsx
index 0d67cb836f..abfea7e63c 100644
--- a/apps/web/app/[domain]/layout.tsx
+++ b/apps/web/app/[domain]/layout.tsx
@@ -1,10 +1,11 @@
-import { Footer, Nav, NavMobile } from "@dub/ui";
+import { Footer, Nav, NavMobile, ProductHunt } from "@dub/ui";
export default function CustomDomainLayout(props) {
return (
<div className="flex min-h-screen flex-col justify-between bg-gray-50">
<NavMobile />
<Nav />
+ <ProductHunt />
{props.children}
<Footer />
</div>
diff --git a/apps/web/app/app.dub.co/(auth)/layout.tsx b/apps/web/app/app.dub.co/(auth)/layout.tsx
index df7a5ad971..2e72101d4f 100644
--- a/apps/web/app/app.dub.co/(auth)/layout.tsx
+++ b/apps/web/app/app.dub.co/(auth)/layout.tsx
@@ -1,4 +1,4 @@
-import { Background } from "@dub/ui";
+import { Background, ProductHunt } from "@dub/ui";
import { ReactNode } from "react";
export const runtime = "edge";
@@ -8,6 +8,7 @@ export default function AuthLayout({ children }: { children: ReactNode }) {
<>
<Background />
<div className="relative z-10 flex h-screen w-screen justify-center">
+ <ProductHunt />
{children}
</div>
</>
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
index 4d74ac3c76..a23cffa3bb 100644
--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
@@ -3,7 +3,7 @@ import UpgradeBanner from "@/ui/layout/upgrade-banner";
import UserDropdown from "@/ui/layout/user-dropdown";
import WorkspaceSwitcher from "@/ui/layout/workspace-switcher";
import { Divider } from "@/ui/shared/icons";
-import { Logo, MaxWidthWrapper } from "@dub/ui";
+import { Logo, MaxWidthWrapper, ProductHunt } from "@dub/ui";
import { HOME_DOMAIN, constructMetadata } from "@dub/utils";
import Link from "next/link";
import { ReactNode, Suspense } from "react";
@@ -15,6 +15,7 @@ export const metadata = constructMetadata();
export default function Layout({ children }: { children: ReactNode }) {
return (
<Providers>
+ <ProductHunt />
<div className="min-h-screen w-full bg-gray-50">
<div className="sticky left-0 right-0 top-0 z-20 border-b border-gray-200 bg-white">
<MaxWidthWrapper>
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 10a0ebe0fa..f0f48249c9 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -1,7 +1,7 @@
{
"name": "@dub/ui",
"description": "UI components for Dub.co",
- "version": "0.0.58",
+ "version": "0.0.64",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
diff --git a/packages/ui/src/client-only.tsx b/packages/ui/src/client-only.tsx
new file mode 100644
index 0000000000..157051f753
--- /dev/null
+++ b/packages/ui/src/client-only.tsx
@@ -0,0 +1,11 @@
+import { ReactNode, useEffect, useState } from "react";
+
+export const ClientOnly = ({ children }: { children: ReactNode }) => {
+ const [clientReady, setClientReady] = useState<boolean>(false);
+
+ useEffect(() => {
+ setClientReady(true);
+ }, []);
+
+ return clientReady ? <>{children}</> : null;
+};
diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx
index 33813e90a2..e6728c12c2 100644
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@ -34,10 +34,12 @@ export * from "./content";
// misc
export * from "./blur-image";
+export * from "./client-only";
export * from "./copy-button";
export * from "./counting-numbers";
export * from "./icon-menu";
export * from "./inline-snippet";
export * from "./link-preview";
+export * from "./product-hunt";
export * from "./progress-bar";
export * from "./tab-select";
diff --git a/packages/ui/src/input-select.tsx b/packages/ui/src/input-select.tsx
index a386a4fb93..f5fcd5f0d9 100644
--- a/packages/ui/src/input-select.tsx
+++ b/packages/ui/src/input-select.tsx
@@ -1,4 +1,3 @@
-"use client";
import { Command, useCommandState } from "cmdk";
import { Check, ChevronDown, Search, X } from "lucide-react";
import {
diff --git a/packages/ui/src/product-hunt.tsx b/packages/ui/src/product-hunt.tsx
new file mode 100644
index 0000000000..ed8f5fe406
--- /dev/null
+++ b/packages/ui/src/product-hunt.tsx
@@ -0,0 +1,71 @@
+import { AnimatePresence, motion } from "framer-motion";
+import Cookies from "js-cookie";
+import { X } from "lucide-react";
+import Image from "next/image";
+import Link from "next/link";
+import { useState } from "react";
+import { ClientOnly } from "./client-only";
+
+export function ProductHunt() {
+ return (
+ <ClientOnly>
+ <ProductHuntChild />
+ </ClientOnly>
+ );
+}
+
+function ProductHuntChild() {
+ const [closed, setClosed] = useState(
+ Cookies.get("hideProductHuntBanner") === "1",
+ );
+ const handleClose = () => {
+ setClosed(true);
+ Cookies.set("hideProductHuntBanner", "1");
+ };
+
+ return (
+ <AnimatePresence>
+ {!closed && (
+ <motion.div
+ key="product-hunt-banner"
+ className="xs:left-4 xs:mx-auto xs:max-w-xs group fixed bottom-4 z-40 mx-2 rounded-lg border border-gray-200 bg-white p-2 pb-4 pr-4 shadow-md"
+ initial={{ opacity: 0, y: 50 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ y: 250 }}
+ >
+ <div className="xs:visible invisible absolute right-4 top-4 h-3 w-3 group-hover:invisible">
+ <div className="absolute inset-0 m-auto h-3 w-3 animate-ping items-center justify-center rounded-full bg-green-500" />
+ <div className="absolute inset-0 z-10 m-auto h-3 w-3 rounded-full bg-green-500" />
+ </div>
+ <button
+ className="xs:invisible visible absolute right-2.5 top-2.5 rounded-full p-1 transition-colors hover:bg-gray-100 active:scale-90 group-hover:visible"
+ onClick={handleClose}
+ >
+ <X className="h-4 w-4 text-gray-500" />
+ </button>
+ <Link
+ href="https://d.to/ph?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-dub"
+ target="_blank"
+ >
+ <Image
+ src="https://assets.dub.co/misc/product-hunt.png"
+ alt="Product Hunt"
+ width={100}
+ height={100}
+ className="h-24"
+ />
+ <div className="-mt-2 px-4">
+ <p className="mb-1 font-medium text-gray-800">
+ We're live on Product Hunt!
+ </p>
+ <p className="text-sm text-gray-500 underline-offset-4 transition-all group-hover:text-gray-800 group-hover:underline">
+ Join the conversation and help us get to #1 Product of the Day
+ ↗
+ </p>
+ </div>
+ </Link>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ );
+}