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.

Update program cards UI

Tim Wilson626be5f8e905
diff --git a/apps/web/app/api/partner-profile/programs/route.ts b/apps/web/app/api/partner-profile/programs/route.ts
index 36a0f047ba..9054364c81 100644
--- a/apps/web/app/api/partner-profile/programs/route.ts
+++ b/apps/web/app/api/partner-profile/programs/route.ts
@@ -19,15 +19,16 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
},
}
: true,
+ links: {
+ take: 1,
+ orderBy: {
+ createdAt: "asc",
+ },
+ },
},
});
return NextResponse.json(
- z.array(ProgramEnrollmentSchema).parse(
- programEnrollments.map((enrollment) => ({
- ...enrollment,
- links: null, // hacky way of not having to fetch link
- })),
- ),
+ z.array(ProgramEnrollmentSchema).parse(programEnrollments),
);
});
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/page-client.tsx
index 2bf397cbe5..08eb0802d0 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/programs/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/page-client.tsx
@@ -38,7 +38,7 @@ export function PartnersDashboardPageClient() {
learnMoreHref="https://d.to/conversions"
/>
) : (
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
+ <div className="mt-3.5 grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{isLoading ? (
Array.from({ length: 3 }).map((_, idx) => (
<ProgramCardSkeleton key={idx} />
diff --git a/apps/web/ui/partners/program-card.tsx b/apps/web/ui/partners/program-card.tsx
index 0c1aa5f328..d7b515f843 100644
--- a/apps/web/ui/partners/program-card.tsx
+++ b/apps/web/ui/partners/program-card.tsx
@@ -1,7 +1,13 @@
import { usePartnerEarningsTimeseries } from "@/lib/swr/use-partner-earnings-timeseries";
import { ProgramEnrollmentProps, ProgramProps } from "@/lib/types";
-import { BlurImage, MiniAreaChart, StatusBadge } from "@dub/ui";
-import { cn, currencyFormatter, formatDate, OG_AVATAR_URL } from "@dub/utils";
+import { BlurImage, Link4, MiniAreaChart } from "@dub/ui";
+import {
+ cn,
+ formatDate,
+ getPrettyUrl,
+ nFormatter,
+ OG_AVATAR_URL,
+} from "@dub/utils";
import { addDays } from "date-fns";
import Link from "next/link";
import { useMemo } from "react";
@@ -33,36 +39,37 @@ export function ProgramCard({
}) {
const { program, status, createdAt } = programEnrollment;
+ const defaultLink = programEnrollment.links?.[0];
+
const card = (
<div
className={cn(
- "block rounded-md border border-neutral-300 bg-white p-4",
+ "block rounded-xl border border-neutral-200 bg-white p-5",
status === "approved"
? "hover:drop-shadow-card-hover transition-[filter]"
: "",
)}
>
- <div className="flex items-center gap-4">
- <div className="flex size-10 items-center justify-center rounded-full border border-neutral-200 bg-gradient-to-t from-neutral-100">
- <BlurImage
- width={96}
- height={96}
- src={program.logo || `${OG_AVATAR_URL}${program.name}`}
- alt={program.name}
- className="size-6 rounded-full"
- />
- </div>
- <div className="flex flex-col gap-0.5">
- <span className="text-base font-medium text-neutral-900">
+ <div className="">
+ <BlurImage
+ width={96}
+ height={96}
+ src={program.logo || `${OG_AVATAR_URL}${program.name}`}
+ alt={program.name}
+ className="size-8 rounded-full border border-black/10"
+ />
+ <div className="mt-3 flex flex-col">
+ <span className="text-base font-semibold text-neutral-800">
{program.name}
</span>
- <StatusBadge
- variant={ProgramEnrollmentStatusBadges[status].variant}
- icon={null}
- className="rounded-full py-0.5"
- >
- {ProgramEnrollmentStatusBadges[status].label}
- </StatusBadge>
+ {defaultLink && (
+ <div className="flex items-center gap-1 text-neutral-500">
+ <Link4 className="size-3" />
+ <span className="text-sm font-medium">
+ {getPrettyUrl(defaultLink.shortLink)}
+ </span>
+ </div>
+ )}
</div>
</div>
{status === "approved" ? (
@@ -107,23 +114,27 @@ function ProgramCardEarnings({ program }: { program: ProgramProps }) {
})),
[timeseries],
);
+
return (
- <div className="mt-4 grid h-24 grid-cols-[min-content,minmax(0,1fr)] gap-4 rounded-md border border-neutral-100 bg-neutral-50 p-5">
- <div>
+ <div className="mt-4 grid grid-cols-[min-content,minmax(0,1fr)] gap-4 rounded-md border border-neutral-200 bg-neutral-50">
+ <div className="py-3 pl-4">
<div className="whitespace-nowrap text-sm text-neutral-500">
Earnings
</div>
{total !== undefined ? (
- <div className="mt-1 text-2xl font-medium leading-none text-neutral-800">
- {currencyFormatter(total / 100 || 0)}
+ <div className="text-xl font-medium text-neutral-800">
+ $
+ {nFormatter((total || 0) / 100, {
+ digits: total < 1000_00 ? 2 : 1,
+ })}
</div>
) : (
<div className="mt-1 h-6 w-20 animate-pulse rounded-md bg-neutral-200" />
)}
</div>
{chartData && (
- <div className="relative h-full">
- <MiniAreaChart data={chartData} />
+ <div className="relative h-full px-3">
+ <MiniAreaChart data={chartData} padding={{ top: 16, bottom: 16 }} />
</div>
)}
</div>
@@ -132,15 +143,13 @@ function ProgramCardEarnings({ program }: { program: ProgramProps }) {
export function ProgramCardSkeleton() {
return (
- <div className="rounded-md border border-neutral-300 p-4">
- <div className="flex items-center gap-4">
- <div className="size-12 rounded-full bg-neutral-200" />
- <div className="flex flex-col gap-0.5">
- <div className="h-6 w-24 min-w-0 rounded-md bg-neutral-200" />
- <div className="h-3.5 w-20 animate-pulse rounded-md bg-neutral-200" />
- </div>
+ <div className="rounded-xl border border-neutral-200 p-5">
+ <div className="size-8 rounded-full bg-neutral-200" />
+ <div className="mt-3 flex flex-col">
+ <div className="my-0.5 h-5 w-24 min-w-0 rounded-md bg-neutral-200" />
+ <div className="my-0.5 h-4 w-20 animate-pulse rounded-md bg-neutral-200" />
</div>
- <div className="mt-6 grid h-[90px] animate-pulse rounded-md bg-neutral-100" />
+ <div className="mt-4 h-[72px] animate-pulse rounded-md bg-neutral-100" />
</div>
);
}
diff --git a/apps/web/ui/partners/program-invite-card.tsx b/apps/web/ui/partners/program-invite-card.tsx
index 83d1a146ed..6daa247d41 100644
--- a/apps/web/ui/partners/program-invite-card.tsx
+++ b/apps/web/ui/partners/program-invite-card.tsx
@@ -2,7 +2,7 @@ import { acceptProgramInviteAction } from "@/lib/actions/partners/accept-program
import { mutatePrefix } from "@/lib/swr/mutate";
import { ProgramEnrollmentProps } from "@/lib/types";
import { ProgramRewardDescription } from "@/ui/partners/program-reward-description";
-import { BlurImage, Button, StatusBadge } from "@dub/ui";
+import { BlurImage, Button, Envelope, Link4, StatusBadge } from "@dub/ui";
import { OG_AVATAR_URL } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import { toast } from "sonner";
@@ -25,45 +25,49 @@ export function ProgramInviteCard({
});
return (
- <div className="hover:drop-shadow-card-hover relative flex flex-col items-center justify-center gap-2 rounded-md border border-neutral-300 bg-neutral-50 p-4 transition-[filter]">
- <StatusBadge
- variant="new"
- icon={null}
- className="absolute left-4 top-4 rounded-full py-0.5"
- >
- Invited
- </StatusBadge>
- <div className="flex size-10 items-center justify-center rounded-full border border-neutral-200 bg-white">
+ <div className="hover:drop-shadow-card-hover relative flex flex-col rounded-xl border border-neutral-200 bg-neutral-50 p-5 transition-[filter]">
+ <div className="flex justify-between gap-2">
<BlurImage
- width={96}
- height={96}
+ width={64}
+ height={64}
src={program.logo || `${OG_AVATAR_URL}${program.name}`}
alt={program.name}
- className="size-6 rounded-full"
+ className="size-8 rounded-full"
/>
+ <StatusBadge variant="new" icon={Envelope} className="py-0.5">
+ Invited
+ </StatusBadge>
</div>
- <div className="grid max-w-xs gap-1 pb-1 text-center">
- <p className="font-medium text-neutral-900">{program.name}</p>
- <p className="text-balance text-xs text-neutral-600">
- <ProgramRewardDescription
- reward={program.rewards?.[0]}
- discount={program.discounts?.[0]}
- amountClassName="font-light"
- periodClassName="font-light"
- />
+
+ <p className="mt-3 font-medium text-neutral-900">{program.name}</p>
+ {program.domain && (
+ <p className="flex items-center gap-1 text-neutral-500">
+ <Link4 className="size-3" />
+ <span className="text-sm font-medium">{program.domain}</span>
</p>
+ )}
+ <p className="mt-2 text-balance text-xs text-neutral-600">
+ <ProgramRewardDescription
+ reward={program.rewards?.[0]}
+ discount={program.discounts?.[0]}
+ amountClassName="font-light"
+ periodClassName="font-light"
+ />
+ </p>
+
+ <div className="mt-2 flex grow flex-col justify-end">
+ <Button
+ text="Accept invite"
+ className="h-8"
+ loading={isPending}
+ onClick={async () =>
+ await executeAsync({
+ partnerId: programEnrollment.partnerId,
+ programId: programEnrollment.programId,
+ })
+ }
+ />
</div>
- <Button
- text="Accept invite"
- className="h-8"
- loading={isPending}
- onClick={async () =>
- await executeAsync({
- partnerId: programEnrollment.partnerId,
- programId: programEnrollment.programId,
- })
- }
- />
</div>
);
}
diff --git a/packages/ui/src/icons/nucleo/envelope.tsx b/packages/ui/src/icons/nucleo/envelope.tsx
new file mode 100644
index 0000000000..a1bd8b4bef
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/envelope.tsx
@@ -0,0 +1,38 @@
+import { SVGProps } from "react";
+
+export function Envelope(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <path
+ d="M1.75,5.75l6.767,3.733c.301,.166,.665,.166,.966,0l6.767-3.733"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <rect
+ height="11.5"
+ width="14.5"
+ fill="none"
+ rx="2"
+ ry="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ transform="translate(18 18) rotate(180)"
+ x="1.75"
+ y="3.25"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 8fd7602de8..93ee87d798 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -75,6 +75,7 @@ export * from "./download";
export * from "./duplicate";
export * from "./earth";
export * from "./earth-position";
+export * from "./envelope";
export * from "./envelope-alert";
export * from "./envelope-arrow-right";
export * from "./eye";
diff --git a/packages/ui/src/mini-area-chart.tsx b/packages/ui/src/mini-area-chart.tsx
index 6e2073a4a2..f3c59c8a34 100644
--- a/packages/ui/src/mini-area-chart.tsx
+++ b/packages/ui/src/mini-area-chart.tsx
@@ -7,10 +7,13 @@ import { Area, AreaClosed } from "@visx/shape";
import { motion } from "framer-motion";
import { useId, useMemo } from "react";
+const defaultPadding = { top: 8, right: 2, bottom: 2, left: 2 };
+
export type MiniAreaChartProps = {
data: { date: Date; value: number }[];
curve?: boolean;
color?: string;
+ padding?: Partial<typeof defaultPadding>;
};
export function MiniAreaChart(props: MiniAreaChartProps) {
@@ -26,15 +29,16 @@ export function MiniAreaChart(props: MiniAreaChartProps) {
);
}
-const padding = { top: 8, right: 2, bottom: 2, left: 2 };
-
function MiniAreaChartInner({
width,
height,
data,
curve = true,
color,
+ padding: paddingProp,
}: MiniAreaChartProps & { width: number; height: number }) {
+ const padding = { ...defaultPadding, ...paddingProp };
+
const id = useId();
const zeroedData = useMemo(