The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add empty states
Tim Wilsond90fd7a35caf
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/directory-empty-state.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/directory-empty-state.tsxnew file mode 100644index 0000000000..cc7d853c1c--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/directory-empty-state.tsx@@ -0,0 +1,93 @@+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";+import { Button } from "@dub/ui";+import { Star, StarFill } from "@dub/ui/icons";+import { SVGProps, useId } from "react";++export function DirectoryEmptyState({+ isFiltered,+ isStarred,+ onClearAllFilters,+}: {+ isFiltered: boolean;+ isStarred: boolean;+ onClearAllFilters: () => void;+}) {+ return (+ <AnimatedEmptyState+ title="No partners found"+ description={+ isFiltered || isStarred ? (+ <>+ Press{" "}+ <span className="text-content-default bg-bg-emphasis rounded-md px-1 py-0.5 text-xs font-semibold">+ Esc+ </span>{" "}+ to clear all filters.+ </>+ ) : (+ "There are no partners for you to discover yet."+ )+ }+ className="border-none md:min-h-[400px]"+ cardClassName="py-3"+ cardCount={2}+ cardContent={(idx) => (+ <div className="flex grow items-center gap-4">+ {idx % 2 === 0 || isStarred ? (+ <StarFill className="size-3 shrink-0 text-amber-500" />+ ) : (+ <Star className="text-content-muted size-3 shrink-0" />+ )}+ <DemoAvatar className="text-content-default size-9 shrink-0" />+ <div className="flex grow flex-col gap-2">+ <div className="h-2.5 w-full min-w-0 rounded bg-neutral-200" />+ <div className="h-2.5 w-12 min-w-0 rounded bg-neutral-200" />+ </div>+ </div>+ )}+ addButton={+ <Button+ type="button"+ text="Clear all filters"+ className="h-9 rounded-lg"+ onClick={onClearAllFilters}+ />+ }+ />+ );+}++function DemoAvatar(props: SVGProps<SVGSVGElement>) {+ const id = useId();++ return (+ <svg+ width="40"+ height="41"+ viewBox="0 0 40 41"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g clipPath={`url(#${id}-clip)`}>+ <path+ d="M20 40.5C31.0457 40.5 40 31.5457 40 20.5C40 9.4543 31.0457 0.5 20 0.5C8.9543 0.5 0 9.4543 0 20.5C0 31.5457 8.9543 40.5 20 40.5Z"+ fill="#F5F5F5"+ />+ <path+ d="M20.0005 22.537C23.0005 22.537 25.4326 20.105 25.4326 17.1049C25.4326 14.1049 23.0005 11.6729 20.0005 11.6729C17.0004 11.6729 14.5684 14.1049 14.5684 17.1049C14.5684 20.105 17.0004 22.537 20.0005 22.537Z"+ fill="#D9D9D9"+ />+ <circle cx="20.0003" cy="40.1297" r="11.8519" fill="#D9D9D9" />+ </g>+ <defs>+ <clipPath id={`${id}-clip`}>+ <path+ d="M0 20.5C0 9.45431 8.95431 0.5 20 0.5C31.0457 0.5 40 9.45431 40 20.5C40 31.5457 31.0457 40.5 20 40.5C8.95431 40.5 0 31.5457 0 20.5Z"+ fill="white"+ />+ </clipPath>+ </defs>+ </svg>+ );+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsxindex 12264aa38e..97fced5f9d 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx@@ -46,6 +46,7 @@ import Link from "next/link";import { useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import useSWR from "swr";+import { DirectoryEmptyState } from "./directory-empty-state";import { usePartnerNetworkFilters } from "./use-partner-network-filters";const tabs = [@@ -253,9 +254,11 @@ export function ProgramPartnersDirectoryPageClient() {</div></div>) : (- <div className="text-content-subtle py-12 text-sm">- No partners found- </div>+ <DirectoryEmptyState+ isFiltered={activeFilters.length > 0}+ isStarred={searchParams.get("starred") == "true"}+ onClearAllFilters={onRemoveAll}+ />)}</div>);diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsxindex 4ec9320faf..690e75a9a0 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx@@ -156,7 +156,7 @@ export function usePartnerNetworkFilters({const onRemoveAll = useCallback(() =>queryParams({- del: [...Object.keys(multiFilters), "country"],+ del: [...Object.keys(multiFilters), "country", "starred"],}),[queryParams],);diff --git a/apps/web/ui/shared/animated-empty-state.tsx b/apps/web/ui/shared/animated-empty-state.tsxindex cb92f6054e..68ad9f0b12 100644--- a/apps/web/ui/shared/animated-empty-state.tsx+++ b/apps/web/ui/shared/animated-empty-state.tsx@@ -9,6 +9,7 @@ export function AnimatedEmptyState({title,description,cardContent,+ cardCount = 3,addButton,pillContent,learnMoreHref,@@ -16,10 +17,12 @@ export function AnimatedEmptyState({learnMoreClassName,learnMoreText,className,+ cardClassName,}: {title: string;description: ReactNode;cardContent: ReactNode | ((index: number) => ReactNode);+ cardCount?: number;addButton?: ReactNode;pillContent?: string;learnMoreHref?: string;@@ -27,6 +30,7 @@ export function AnimatedEmptyState({learnMoreClassName?: string;learnMoreText?: string;className?: string;+ cardClassName?: string;}) {return (<div@@ -41,9 +45,9 @@ export function AnimatedEmptyState({className="animate-infinite-scroll-y flex flex-col [animation-duration:10s]">{[...Array(6)].map((_, idx) => (- <Card key={idx}>+ <Card key={idx} className={cardClassName}>{typeof cardContent === "function"- ? cardContent(idx % 3)+ ? cardContent(idx % cardCount): cardContent}</Card>))}@@ -76,9 +80,17 @@ export function AnimatedEmptyState({);}-function Card({ children }: PropsWithChildren) {+function Card({+ children,+ className,+}: PropsWithChildren<{ className?: string }>) {return (- <div className="mt-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 shadow-[0_4px_12px_0_#0000000D]">+ <div+ className={cn(+ "mt-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 shadow-[0_4px_12px_0_#0000000D]",+ className,+ )}+ >{children}</div>);diff --git a/packages/ui/src/icons/nucleo/star.tsx b/packages/ui/src/icons/nucleo/star.tsxindex c7e120e322..ded8288a1b 100644--- a/packages/ui/src/icons/nucleo/star.tsx+++ b/packages/ui/src/icons/nucleo/star.tsx@@ -13,7 +13,7 @@ export function Star(props: SVGProps<SVGSVGElement>) {<polygonfill="none"points="9 1.75 11.24 6.289 16.25 7.017 12.625 10.551 13.481 15.54 9 13.185 4.519 15.54 5.375 10.551 1.75 7.017 6.76 6.289 9 1.75"- stroke="#212121"+ stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"strokeWidth="1.5"