The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
WIP selection toolbar
Tim Wilson7dc743e750e8
diff --git a/apps/web/ui/links/links-container.tsx b/apps/web/ui/links/links-container.tsxindex 34d29d73f3..7dfd3d487d 100644--- a/apps/web/ui/links/links-container.tsx+++ b/apps/web/ui/links/links-container.tsx@@ -20,6 +20,7 @@ import {useState,} from "react";import { AnimatedEmptyState } from "../shared/animated-empty-state";+import { X } from "../shared/icons";import ArchivedLinksHint from "./archived-links-hint";import { LinkCard } from "./link-card";import LinkCardPlaceholder from "./link-card-placeholder";@@ -79,8 +80,6 @@ function LinksList({}) {const searchParams = useSearchParams();- const { pagination, setPagination } = usePagination();-const [selectedLinkIds, setSelectedLinkIds] = useState<string[]>([]);const [openMenuLinkId, setOpenMenuLinkId] = useState<string | null>(null);@@ -94,33 +93,31 @@ function LinksList({].some((param) => searchParams.has(param));return (- <>+ <LinksListContext.Provider+ value={{+ selectedLinkIds,+ setSelectedLinkIds,+ openMenuLinkId,+ setOpenMenuLinkId,+ }}+ >{!links || links.length ? (- <LinksListContext.Provider- value={{- selectedLinkIds,- setSelectedLinkIds,- openMenuLinkId,- setOpenMenuLinkId,- }}- >- {/* Cards */}- <CardList variant={compact ? "compact" : "loose"} loading={loading}>- {links?.length- ? // Link cards- links.map((link) => <LinkCard key={link.id} link={link} />)- : // Loading placeholder cards- Array.from({ length: 12 }).map((_, idx) => (- <CardList.Card- key={idx}- outerClassName="pointer-events-none"- innerClassName="flex items-center gap-4"- >- <LinkCardPlaceholder />- </CardList.Card>- ))}- </CardList>- </LinksListContext.Provider>+ // Cards+ <CardList variant={compact ? "compact" : "loose"} loading={loading}>+ {links?.length+ ? // Link cards+ links.map((link) => <LinkCard key={link.id} link={link} />)+ : // Loading placeholder cards+ Array.from({ length: 12 }).map((_, idx) => (+ <CardList.Card+ key={idx}+ outerClassName="pointer-events-none"+ innerClassName="flex items-center gap-4"+ >+ <LinkCardPlaceholder />+ </CardList.Card>+ ))}+ </CardList>) : (<AnimatedEmptyStatetitle={isFiltered ? "No links found" : "No links yet"}@@ -152,35 +149,92 @@ function LinksList({{/* Pagination */}{links && (- <>- <div className="h-[90px]" />- <div className="fixed bottom-4 left-0 w-full sm:max-[1330px]:w-[calc(100%-150px)] md:left-[240px] md:w-[calc(100%-240px)] md:max-[1330px]:w-[calc(100%-240px-150px)]">+ <FloatingToolbar+ loading={!!loading}+ linksCount={count ?? links?.length ?? 0}+ />+ )}+ </LinksListContext.Provider>+ );+}++const FloatingToolbar = ({+ loading,+ linksCount,+}: {+ loading: boolean;+ linksCount: number;+}) => {+ const { selectedLinkIds, setSelectedLinkIds } = useContext(LinksListContext);+ const { pagination, setPagination } = usePagination();++ return (+ <>+ {/* Leave room at bottom of list */}+ <div className="h-[90px]" />++ <div className="fixed bottom-4 left-0 w-full sm:max-[1330px]:w-[calc(100%-150px)] md:left-[240px] md:w-[calc(100%-240px)] md:max-[1330px]:w-[calc(100%-240px-150px)]">+ <div+ className={cn(+ "relative left-1/2 w-full max-w-[768px] -translate-x-1/2 px-5",+ "max-[1330px]:left-0 max-[1330px]:translate-x-0",+ )}+ >+ <div className="overflow-hidden rounded-xl border border-neutral-200 bg-white [filter:drop-shadow(0_5px_8px_#222A351d)]"><divclassName={cn(- "relative left-1/2 w-full max-w-[768px] -translate-x-1/2 px-5",- "max-[1330px]:left-0 max-[1330px]:translate-x-0",+ "relative px-4 py-3.5 transition-[opacity,transform] duration-100",+ selectedLinkIds.length > 0 &&+ "absolute inset-0 translate-y-1/2 opacity-0",)}>- <div className="rounded-xl border border-neutral-200 bg-white px-4 py-3.5 [filter:drop-shadow(0_5px_8px_#222A351d)]">- <PaginationControls- pagination={pagination}- setPagination={setPagination}- totalCount={count ?? links?.length ?? 0}- unit={(plural) => `${plural ? "links" : "link"}`}- >- {loading ? (- <LoadingSpinner className="size-3.5" />- ) : (- <div className="hidden sm:block">- <ArchivedLinksHint />- </div>- )}- </PaginationControls>+ <PaginationControls+ pagination={pagination}+ setPagination={setPagination}+ totalCount={linksCount}+ unit={(plural) => `${plural ? "links" : "link"}`}+ >+ {loading ? (+ <LoadingSpinner className="size-3.5" />+ ) : (+ <div className="hidden sm:block">+ <ArchivedLinksHint />+ </div>+ )}+ </PaginationControls>+ </div>++ <div+ className={cn(+ "relative px-4 py-3.5 transition-[opacity,transform] duration-100",+ !selectedLinkIds.length &&+ "absolute inset-0 translate-y-1/2 opacity-0",+ )}+ >+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={() => setSelectedLinkIds([])}+ className="rounded-md p-1.5 transition-colors duration-75 hover:bg-neutral-50 active:bg-neutral-100"+ >+ <X className="size-4 text-neutral-900" />+ </button>+ <span className="text-sm font-medium text-neutral-600">+ <strong className="font-semibold">+ {selectedLinkIds.length}+ </strong>{" "}+ selected+ </span>+ </div>++ {/* Controls */}+ <div className="flex items-center gap-2"></div></div></div></div>- </>- )}+ </div>+ </div></>);-}+};