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.

Fix scrollbar during animation

Tim Wilsonc13184b9a253
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 4a8753af23..25166dcd8d 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
@@ -27,12 +27,15 @@ import {
nFormatter,
} from "@dub/utils";
import { Link, Program } from "@prisma/client";
+import { motion } from "framer-motion";
import { CSSProperties, useState } from "react";
import useSWR from "swr";
import { LinkToken } from "../token";
type Tab = "invite" | "rewards";
+const heroAnimationDuration = 0.2;
+
export function EmbedWidgetPageClient({
program,
link,
@@ -64,7 +67,7 @@ export function EmbedWidgetPageClient({
>
<AnimatedSizeContainer
height
- transition={{ type: "easeInOut", duration: 0.2 }}
+ transition={{ type: "easeInOut", duration: heroAnimationDuration }}
className="flex flex-col justify-end"
>
<div className="flex h-full flex-col justify-end px-5 pt-5">
@@ -95,7 +98,7 @@ export function EmbedWidgetPageClient({
</AnimatedSizeContainer>
<AnimatedSizeContainer
height
- transition={{ type: "easeInOut", duration: 0.2 }}
+ transition={{ type: "easeInOut", duration: heroAnimationDuration }}
>
<div
className={cn(
@@ -203,61 +206,68 @@ export function EmbedWidgetPageClient({
<h2 className="text-sm font-semibold text-neutral-900">
Activity
</h2>
- <div className="mt-3 grid grid-cols-3 gap-2">
- {[
- { label: "Clicks", value: link.clicks },
- { 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">
- <span className="text-xs text-neutral-500">{label}</span>
- <span className="text-sm font-semibold text-neutral-600">
- {label === "Total earned"
- ? currencyFormatter(value / 100, {
- minimumFractionDigits: 2,
- maximumFractionDigits: 2,
- })
- : nFormatter(value)}
- </span>
- </div>
- ))}
- </div>
- <div className="mt-4">
- {sales ? (
- sales.length ? (
- <div className="mt-4 grid grid-cols-1 divide-y divide-neutral-200 rounded-md border border-neutral-200">
- {sales.slice(0, 3).map((sale) => (
- <div
- key={sale.id}
- className="flex items-center justify-between gap-4 px-3 py-2.5"
- >
- <div className="flex min-w-0 flex-col">
- <span className="truncate text-sm font-medium text-neutral-600">
- {sale.customer.email}
- </span>
- </div>
- <div className="flex flex-col">
- <span className="text-sm font-medium text-neutral-600">
- {currencyFormatter(sale.earnings / 100, {
- minimumFractionDigits: 2,
- maximumFractionDigits: 2,
- })}
- </span>
+ <motion.div
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: "auto", opacity: 1 }}
+ transition={{ duration: heroAnimationDuration }}
+ className="overflow-clip"
+ >
+ <div className="mt-3 grid grid-cols-3 gap-2">
+ {[
+ { label: "Clicks", value: link.clicks },
+ { 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">
+ <span className="text-xs text-neutral-500">{label}</span>
+ <span className="text-sm font-semibold text-neutral-600">
+ {label === "Total earned"
+ ? currencyFormatter(value / 100, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ })
+ : nFormatter(value)}
+ </span>
+ </div>
+ ))}
+ </div>
+ <div className="mt-4">
+ {sales ? (
+ sales.length ? (
+ <div className="mt-4 grid grid-cols-1 divide-y divide-neutral-200 rounded-md border border-neutral-200">
+ {sales.slice(0, 3).map((sale) => (
+ <div
+ key={sale.id}
+ className="flex items-center justify-between gap-4 px-3 py-2.5"
+ >
+ <div className="flex min-w-0 flex-col">
+ <span className="truncate text-sm font-medium text-neutral-600">
+ {sale.customer.email}
+ </span>
+ </div>
+ <div className="flex flex-col">
+ <span className="text-sm font-medium text-neutral-600">
+ {currencyFormatter(sale.earnings / 100, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ })}
+ </span>
+ </div>
</div>
- </div>
- ))}
+ ))}
+ </div>
+ ) : (
+ <EmptyState />
+ )
+ ) : isLoading ? (
+ <div className="mt-8 flex items-center justify-center">
+ <LoadingSpinner className="size-4" />
</div>
) : (
<EmptyState />
- )
- ) : isLoading ? (
- <div className="mt-8 flex items-center justify-center">
- <LoadingSpinner className="size-4" />
- </div>
- ) : (
- <EmptyState />
- )}
- </div>
+ )}
+ </div>
+ </motion.div>
</>
)}
<LinkToken />