The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
animatepresence
Steven Tey04a6b5956546
diff --git a/apps/web/app/app.dub.co/embed/inline/page-client.tsx b/apps/web/app/app.dub.co/embed/inline/page-client.tsxindex a8ef5fc09f..0ea6bea4ec 100644--- a/apps/web/app/app.dub.co/embed/inline/page-client.tsx+++ b/apps/web/app/app.dub.co/embed/inline/page-client.tsx@@ -13,6 +13,7 @@ import {Wordmark,} from "@dub/ui";import { cn, getPrettyUrl } from "@dub/utils";+import { AnimatePresence } from "framer-motion";import { CSSProperties, useState } from "react";import { EmbedActivity } from "../activity";import { EmbedLeaderboard } from "../leaderboard";@@ -112,13 +113,17 @@ export function EmbedInlinePageClient({selectAction={(option) => {setSelectedTab(option);}}- className="w-full rounded-lg"+ className="w-full rounded-lg bg-neutral-50"+ optionClassName="w-full flex justify-center py-1.5"+ indicatorClassName="bg-white"/>- {selectedTab === "Leaderboard" ? (- <EmbedLeaderboard />- ) : (- <EmbedSales salesCount={link.sales} />- )}+ <AnimatePresence mode="wait">+ {selectedTab === "Leaderboard" ? (+ <EmbedLeaderboard />+ ) : (+ <EmbedSales salesCount={link.sales} />+ )}+ </AnimatePresence></div><LinkToken /></div>diff --git a/apps/web/app/app.dub.co/embed/leaderboard.tsx b/apps/web/app/app.dub.co/embed/leaderboard.tsxindex aac14e4f51..54a694de3a 100644--- a/apps/web/app/app.dub.co/embed/leaderboard.tsx+++ b/apps/web/app/app.dub.co/embed/leaderboard.tsx@@ -2,8 +2,13 @@ import z from "@/lib/zod";import { LeaderboardPartnerSchema } from "@/lib/zod/schemas/partners";import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";import { Crown, Table, Users, useTable } from "@dub/ui";-import { currencyFormatter, fetcher } from "@dub/utils";+import {+ currencyFormatter,+ TAB_ITEM_ANIMATION_SETTINGS,+ fetcher,+} from "@dub/utils";import { cn } from "@dub/utils/src/functions";+import { motion } from "framer-motion";import useSWR from "swr";export function EmbedLeaderboard() {@@ -74,13 +79,16 @@ export function EmbedLeaderboard() {});return (- <div className="relative my-4 rounded-md border border-neutral-200">+ <motion.div+ className="relative my-4 rounded-md border border-neutral-200"+ {...TAB_ITEM_ANIMATION_SETTINGS}+ ><Table{...tableProps}table={table}containerClassName="border-none max-h-[16.5rem] overflow-auto"/><div className="pointer-events-none absolute -bottom-px left-0 h-16 w-full rounded-b-lg bg-gradient-to-t from-white sm:bottom-0" />- </div>+ </motion.div>);}diff --git a/apps/web/app/app.dub.co/embed/sales.tsx b/apps/web/app/app.dub.co/embed/sales.tsxindex 3bd314a827..a40851820d 100644--- a/apps/web/app/app.dub.co/embed/sales.tsx+++ b/apps/web/app/app.dub.co/embed/sales.tsx@@ -1,9 +1,15 @@import { SALES_PAGE_SIZE } from "@/lib/partners/constants";import { PartnerSaleResponse } from "@/lib/types";import { Gift, Table, usePagination, useTable } from "@dub/ui";-import { currencyFormatter, fetcher, formatDate } from "@dub/utils";-import useSWR from "swr";+import {+ currencyFormatter,+ fetcher,+ formatDate,+ TAB_ITEM_ANIMATION_SETTINGS,+} from "@dub/utils";+import { motion } from "framer-motion";+import useSWR from "swr";export function EmbedSales({ salesCount }: { salesCount: number }) {const { pagination, setPagination } = usePagination(SALES_PAGE_SIZE);const { data: sales, isLoading } = useSWR<PartnerSaleResponse[]>(@@ -72,11 +78,13 @@ export function EmbedSales({ salesCount }: { salesCount: number }) {});return (- <Table- {...tableProps}- table={table}- containerClassName="rounded-md border border-neutral-200 my-4"- scrollWrapperClassName="min-h-[14.05rem]"- />+ <motion.div {...TAB_ITEM_ANIMATION_SETTINGS}>+ <Table+ {...tableProps}+ table={table}+ containerClassName="rounded-md border border-neutral-200 my-4"+ scrollWrapperClassName="min-h-[14.05rem]"+ />+ </motion.div>);}diff --git a/packages/utils/src/constants/framer-motion.ts b/packages/utils/src/constants/framer-motion.tsindex cb1e41353a..28a3afbdfd 100644--- a/packages/utils/src/constants/framer-motion.ts+++ b/packages/utils/src/constants/framer-motion.ts@@ -8,16 +8,9 @@ export const STAGGER_CHILD_VARIANTS = {show: { opacity: 1, y: 0, transition: { duration: 0.4, type: "spring" } },};-export const SWIPE_REVEAL_ANIMATION_SETTINGS = {- initial: { height: 0 },- animate: { height: "auto" },- exit: { height: 0 },- transition: { duration: 0.15, ease: "easeOut" },-};--export const FADE_IN_ANIMATION_SETTINGS = {- initial: { opacity: 0 },- animate: { opacity: 1 },- exit: { opacity: 0 },- transition: { duration: 0.2 },+export const TAB_ITEM_ANIMATION_SETTINGS = {+ initial: { opacity: 0, y: -10 },+ animate: { opacity: 1, y: 0 },+ exit: { opacity: 0, y: -10 },+ transition: { duration: 0.2, type: "easeInOut" },};