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 ReferButton to mobile

Steven Tey15882bc4d25b
diff --git a/apps/web/app/app.dub.co/embed/widget/page-client.tsx b/apps/web/app/app.dub.co/embed/widget/page-client.tsx
index 52dc8c6217..461d5823a8 100644
--- a/apps/web/app/app.dub.co/embed/widget/page-client.tsx
+++ b/apps/web/app/app.dub.co/embed/widget/page-client.tsx
@@ -13,6 +13,7 @@ import {
Check2,
Copy,
EnvelopeArrowRight,
+ Gift,
GiftFill,
LinkedIn,
QRCode,
@@ -208,7 +209,7 @@ export function EmbedWidgetPageClient({
{ label: "Signups", value: link.leads },
{ label: "Total earned", value: earnings },
].map(({ label, value }) => (
- <div className="flex flex-col gap-1.5 rounded-lg bg-neutral-100 p-2 shadow-sm">
+ <div className="flex flex-col gap-1.5 rounded-lg border border-neutral-200 bg-neutral-50 p-2">
<span className="text-xs text-neutral-500">{label}</span>
<span className="text-sm font-semibold text-neutral-600">
{label === "Total earned"
@@ -247,18 +248,14 @@ export function EmbedWidgetPageClient({
))}
</div>
) : (
- <p className="mt-8 text-center text-xs text-neutral-400">
- No sales yet
- </p>
+ <EmptyState />
)
) : isLoading ? (
<div className="mt-8 flex items-center justify-center">
<LoadingSpinner className="size-4" />
</div>
) : (
- <p className="mt-8 text-center text-xs text-neutral-400">
- No sales yet
- </p>
+ <EmptyState />
)}
</div>
</>
@@ -281,3 +278,15 @@ export function EmbedWidgetPageClient({
</div>
);
}
+
+const EmptyState = () => {
+ return (
+ <div className="flex h-40 w-full flex-col items-center justify-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50">
+ <Gift className="size-6 text-neutral-400" />
+ <p className="max-w-60 text-pretty text-center text-xs text-neutral-400">
+ No sales yet. When you refer a friend and they make a purchase, they'll
+ show up here.
+ </p>
+ </div>
+ );
+};
diff --git a/apps/web/ui/layout/page-content/index.tsx b/apps/web/ui/layout/page-content/index.tsx
index 8515cb6394..425c6b541a 100644
--- a/apps/web/ui/layout/page-content/index.tsx
+++ b/apps/web/ui/layout/page-content/index.tsx
@@ -2,6 +2,7 @@ import { MaxWidthWrapper } from "@dub/ui";
import { cn } from "@dub/utils";
import { PropsWithChildren, ReactNode } from "react";
import { HelpButtonRSC } from "../sidebar/help-button-rsc";
+import { ReferButton } from "../sidebar/refer-button";
import UserDropdown from "../sidebar/user-dropdown";
import { NavButton } from "./nav-button";
@@ -48,6 +49,7 @@ export function PageContent({
<div className="hidden md:block">{titleControls}</div>
)}
<div className="flex items-center gap-4 md:hidden">
+ <ReferButton />
<HelpButtonRSC />
<UserDropdown />
</div>
diff --git a/apps/web/ui/layout/sidebar/refer-button.tsx b/apps/web/ui/layout/sidebar/refer-button.tsx
index 9812169b18..402ed4fc2a 100644
--- a/apps/web/ui/layout/sidebar/refer-button.tsx
+++ b/apps/web/ui/layout/sidebar/refer-button.tsx
@@ -2,6 +2,7 @@
import useWorkspace from "@/lib/swr/use-workspace";
import { DubWidget } from "@dub/embed-react";
+import { useMediaQuery } from "@dub/ui";
import { Gift } from "@dub/ui/src/icons";
import { cn } from "@dub/utils";
import { AnimatePresence, motion } from "framer-motion";
@@ -10,6 +11,7 @@ import { toast } from "sonner";
export function ReferButton() {
const { id: workspaceId, flags, referralLinkId } = useWorkspace();
+ const { isMobile } = useMediaQuery();
const [publicToken, setPublicToken] = useState<string | null>(null);
@@ -39,7 +41,11 @@ export function ReferButton() {
if (!flags?.referrals || !referralLinkId || !publicToken) return null;
return (
- <DubWidget token={publicToken} trigger="manual" placement="top-left">
+ <DubWidget
+ token={publicToken}
+ trigger="manual"
+ placement={isMobile ? "top-right" : "top-left"}
+ >
<button
type="button"
className={cn(