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 refer button

Steven Tey3a0ca66c186e
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
index d8b7eaf4cf..49d9d10504 100644
--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx
@@ -2,6 +2,7 @@ import { MainNav } from "@/ui/layout/main-nav";
import { AppSidebarNav } from "@/ui/layout/sidebar/app-sidebar-nav";
import { HelpButtonRSC } from "@/ui/layout/sidebar/help-button-rsc";
import { NewsRSC } from "@/ui/layout/sidebar/news-rsc";
+import { ReferButton } from "@/ui/layout/sidebar/refer-button";
import Toolbar from "@/ui/layout/toolbar/toolbar";
import { constructMetadata } from "@dub/utils";
import { ReactNode } from "react";
@@ -15,13 +16,17 @@ export default async function Layout({ children }: { children: ReactNode }) {
<div className="min-h-screen w-full bg-white">
<MainNav
sidebar={AppSidebarNav}
- toolContent={<HelpButtonRSC />}
+ toolContent={
+ <>
+ <ReferButton />
+ <HelpButtonRSC />
+ </>
+ }
newsContent={<NewsRSC />}
>
{children}
</MainNav>
</div>
- {/* <ChangelogPopup /> */}
<Toolbar show={["onboarding"]} />
</>
);
diff --git a/apps/web/ui/layout/sidebar/refer-button.tsx b/apps/web/ui/layout/sidebar/refer-button.tsx
new file mode 100644
index 0000000000..cb39a98854
--- /dev/null
+++ b/apps/web/ui/layout/sidebar/refer-button.tsx
@@ -0,0 +1,33 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import { Gift } from "@dub/ui/src/icons";
+import { cn } from "@dub/utils";
+import { AnimatePresence, motion } from "framer-motion";
+
+export function ReferButton() {
+ const { flags } = useWorkspace();
+
+ if (!flags || !flags.referrals) return null;
+
+ return (
+ <button
+ type="button"
+ className={cn(
+ "font-lg relative size-4 shrink-0 overflow-hidden rounded-full transition-all active:scale-90 active:bg-gray-50",
+ "outline-none ring-offset-2 ring-offset-neutral-100 focus-visible:ring-2 focus-visible:ring-black/50",
+ )}
+ >
+ <AnimatePresence>
+ <motion.div
+ className="absolute inset-0 flex items-center justify-center font-medium text-neutral-500 hover:text-neutral-700"
+ initial={{ opacity: 0, scale: 0 }}
+ animate={{ opacity: 1, scale: 1 }}
+ exit={{ opacity: 0, scale: 0 }}
+ >
+ <Gift className="size-4" />
+ </motion.div>
+ </AnimatePresence>
+ </button>
+ );
+}