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.

WIP featured cards

Tim Wilson95760823e424
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/page-client.tsx
index f280567d06..38586c9d77 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/page-client.tsx
@@ -14,7 +14,7 @@ import {
import { cn, fetcher } from "@dub/utils";
import useSWR from "swr";
import { MarketplaceEmptyState } from "./marketplace-empty-state";
-import { ProgramCard } from "./program-card";
+import { FeaturedProgramCard, ProgramCard } from "./program-card";
import ProgramSort from "./program-sort";
import { useProgramNetworkFilters } from "./use-program-network-filters";
@@ -50,6 +50,15 @@ export function ProgramMarketplacePageClient() {
return (
<div className="flex flex-col gap-6">
+ <div>
+ <h2 className="text-content-emphasis text-base font-semibold">
+ Featured programs
+ </h2>
+ <div className="@3xl/page:grid-cols-2 mt-4 grid grid-cols-1 gap-4">
+ <FeaturedProgramCard program={programs?.[0]} />
+ <FeaturedProgramCard program={programs?.[1]} />
+ </div>
+ </div>
<div>
<div className="xs:flex-row xs:items-center flex flex-col justify-between gap-4">
<div className="flex items-center gap-2">
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
index 0b8a228b71..6ef5a994d5 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
@@ -23,6 +23,24 @@ import {
import * as HoverCard from "@radix-ui/react-hover-card";
import { useRouter } from "next/navigation";
+const getClickHandlers = (
+ url: string | undefined,
+ router: ReturnType<typeof useRouter>,
+) => ({
+ onClick: url
+ ? (e) => {
+ if (isClickOnInteractiveChild(e)) return;
+ e.metaKey || e.ctrlKey ? window.open(url, "_blank") : router.push(url);
+ }
+ : undefined,
+ onAuxClick: url
+ ? (e) => {
+ if (isClickOnInteractiveChild(e)) return;
+ window.open(url, "_blank");
+ }
+ : undefined,
+});
+
export function ProgramCard({ program }: { program?: NetworkProgramProps }) {
const { queryParams } = useRouterStuff();
const router = useRouter();
@@ -35,24 +53,7 @@ export function ProgramCard({ program }: { program?: NetworkProgramProps }) {
return (
<div
className={cn(program?.id && "cursor-pointer hover:drop-shadow-sm")}
- onClick={
- url
- ? (e) => {
- if (isClickOnInteractiveChild(e)) return;
- e.metaKey || e.ctrlKey
- ? window.open(url, "_blank")
- : router.push(url);
- }
- : undefined
- }
- onAuxClick={
- url
- ? (e) => {
- if (isClickOnInteractiveChild(e)) return;
- window.open(url, "_blank");
- }
- : undefined
- }
+ {...getClickHandlers(url, router)}
>
<div className="border-border-subtle rounded-xl border bg-white p-6">
<div className="flex justify-between gap-4">
@@ -66,7 +67,6 @@ export function ProgramCard({ program }: { program?: NetworkProgramProps }) {
<div className="size-12 animate-pulse rounded-full bg-neutral-200" />
)}
- {/* TODO: Status */}
{statusBadge && (
<StatusBadge {...statusBadge} className="px-1.5 py-0.5">
{statusBadge.label}
@@ -190,6 +190,171 @@ export function ProgramCard({ program }: { program?: NetworkProgramProps }) {
);
}
+export function FeaturedProgramCard({
+ program,
+}: {
+ program?: NetworkProgramProps;
+}) {
+ const { queryParams } = useRouterStuff();
+ const router = useRouter();
+
+ const statusBadge = program?.status
+ ? ProgramNetworkStatusBadges[program.status]
+ : null;
+ const url = program ? `/programs/${program.slug}` : undefined;
+
+ return (
+ <div
+ className={cn(
+ "border-border-subtle relative overflow-hidden rounded-xl border p-6",
+ program?.id &&
+ "cursor-pointer border-transparent bg-black hover:drop-shadow-sm",
+ )}
+ {...getClickHandlers(url, router)}
+ >
+ {program?.marketplaceHeaderImage && (
+ <img
+ src={program.marketplaceHeaderImage}
+ alt=""
+ className="absolute inset-0 size-full object-cover opacity-80"
+ />
+ )}
+
+ <div className="relative">
+ <div className="flex justify-between gap-4">
+ {program ? (
+ <img
+ src={program.logo || `${OG_AVATAR_URL}${program.name}`}
+ alt={program.name}
+ className="size-12 rounded-full"
+ />
+ ) : (
+ <div className="size-12 animate-pulse rounded-full bg-neutral-200" />
+ )}
+
+ {statusBadge && (
+ <StatusBadge {...statusBadge} className="px-1.5 py-0.5">
+ {statusBadge.label}
+ </StatusBadge>
+ )}
+ </div>
+
+ <div className="mt-4 flex flex-col">
+ {/* Name */}
+ {program ? (
+ <span className="text-content-inverted text-3xl font-semibold">
+ {program.name}
+ </span>
+ ) : (
+ <div className="h-9 w-40 animate-pulse rounded bg-neutral-200" />
+ )}
+
+ <div className="text-content-inverted mt-1 flex items-center gap-1">
+ <Link4 className="size-3.5" />
+ {/* Domain */}
+ {program ? (
+ <a
+ href={program.url || `https://${program.domain}`}
+ target="_blank"
+ rel="noreferrer noopener"
+ className="text-sm font-medium"
+ >
+ {getPrettyUrl(program.url) || program.domain}
+ </a>
+ ) : (
+ <div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />
+ )}
+ </div>
+
+ <div className="mt-4 flex gap-8">
+ {program ? (
+ <>
+ {Boolean(program?.rewards?.length || program?.discount) && (
+ <div>
+ <span className="text-content-muted block text-xs font-medium">
+ Rewards
+ </span>
+ <div className="mt-1 flex items-center gap-1.5">
+ {program.rewards?.map((reward) => (
+ <RewardOrDiscountIcon
+ key={reward.id}
+ icon={REWARD_EVENTS[reward.event].icon}
+ description={formatRewardDescription({ reward })}
+ onClick={() =>
+ queryParams({
+ set: {
+ rewardType: reward.event,
+ },
+ del: "page",
+ })
+ }
+ />
+ ))}
+ {program.discount && (
+ <RewardOrDiscountIcon
+ icon={Gift}
+ description={formatDiscountDescription({
+ discount: program.discount,
+ })}
+ onClick={() =>
+ queryParams({
+ set: {
+ rewardType: "discount",
+ },
+ del: "page",
+ })
+ }
+ />
+ )}
+ </div>
+ </div>
+ )}
+ {Boolean(program?.categories?.length) && (
+ <div className="min-w-0">
+ <span className="text-content-muted block text-xs font-medium">
+ Industry
+ </span>
+ <div className="mt-1 flex items-center gap-1.5">
+ {program.categories
+ .slice(0, 1)
+ ?.map((category) => (
+ <CategoryButton key={category} category={category} />
+ ))}
+ {program.categories.length > 1 && (
+ <Tooltip
+ content={
+ <div className="flex flex-col gap-0.5 p-2">
+ {program.categories.slice(1).map((category) => (
+ <CategoryButton
+ key={category}
+ category={category}
+ />
+ ))}
+ </div>
+ }
+ >
+ <div className="text-content-subtle -ml-1.5 flex size-6 items-center justify-center rounded-md text-xs font-medium">
+ +{program.categories.length - 1}
+ </div>
+ </Tooltip>
+ )}
+ </div>
+ </div>
+ )}
+ </>
+ ) : (
+ <div>
+ <div className="h-3.5 w-12 animate-pulse rounded bg-neutral-200" />
+ <div className="mt-1 h-6 w-24 animate-pulse rounded bg-neutral-200" />
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
const RewardOrDiscountIcon = ({
icon: Icon,
description,