Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: improve colors and sorting
Marc Seitza5097e7512b8
diff --git a/app/(static)/open-source-investors/ClientPage.tsx b/app/(static)/open-source-investors/ClientPage.tsxindex dbdbfda0..5bca3628 100644--- a/app/(static)/open-source-investors/ClientPage.tsx+++ b/app/(static)/open-source-investors/ClientPage.tsx@@ -6,6 +6,8 @@ import { useMemo, useState } from "react";import InvestorTable from "@/components/investors/table";import SearchBar from "@/components/investors/search";import Stats from "@/components/investors/stats";+import Link from "next/link";+import { cn } from "@/lib/utils";const searchOptions = {threshold: 0.3,@@ -15,6 +17,22 @@ const searchOptions = {keys: ["fields.name", "fields.twitterUrl", "fields.company", "fields.title", "fields.openSourceInvestments"],};+function compare(a: any, b: any) {+ // Define the order of the checkSize labels+ const checkSizesOrder = ["$5k - $50k", "$50k+", "$100k+", "$250k+", "Unknown"];++ const orderA = checkSizesOrder.indexOf(a.fields.checkSize);+ const orderB = checkSizesOrder.indexOf(b.fields.checkSize);++ // Ensure that the checkSize exists in our order array. If not, place it at the end.+ if (orderA === -1) return 1;+ if (orderB === -1) return -1;++ // Sort according to the checkSize order+ return orderA - orderB;+}++export default function Dashboard({ data }: any) {const { records: allInvestors } = data;@@ -23,13 +41,31 @@ export default function Dashboard({ data }: any) {const searchParams = useSearchParams();const category = searchParams!.get("category");+ const checkSizes = [+ { id: "7", label: "All" },+ { id: "1", label: "$5k - $50k" },+ { id: "2", label: "$50k+" },+ { id: "3", label: "$100k+" },+ { id: "4", label: "$250k+" },+ ];++ const selectedCheckSize = checkSizes.find(+ (checkSize) => checkSize.id === category+ );+ const labelForSelectedCategory = selectedCheckSize+ ? selectedCheckSize.label+ : null;++// Define filtered & sorted investor arrayconst ALL_INVESTORS = allInvestors// .filter((angel: any) => !angel.hidden)- // .sort(compare)- // .filter((person: any) => {- // return !category ? true : person.checksize_id.toString() === category;- // });+ .sort(compare)+ .filter((person: any) => {+ if (!labelForSelectedCategory || labelForSelectedCategory === "All")+ return true;+ return person.fields.checkSize === labelForSelectedCategory;+ });// Fuzzy search with highlightingconst fuse = new Fuse(ALL_INVESTORS, searchOptions);@@ -51,7 +87,28 @@ export default function Dashboard({ data }: any) {</div></div><Stats angelsLength={angels.length} />- <div className="sm:flex flex-col md:flex-row justify-end mt-4">+ <div className="sm:flex flex-col md:flex-row justify-between mt-4">+ <span className="isolate mt-5 inline-flex rounded-md shadow-sm w-fit">+ {checkSizes.map((checkSize) => (+ <Link+ href={+ checkSize.id !== "7"+ ? `/open-source-investors/?category=${checkSize.id}`+ : "/open-source-investors"+ }+ key={checkSize.id}+ className={cn(+ category === checkSize.id ||+ (!category && checkSize.id === "7")+ ? "bg-gray-200"+ : "bg-white hover:bg-gray-50",+ "relative inline-flex items-center first-of-type:rounded-l-md last-of-type:rounded-r-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 focus:z-10 focus:outline-none focus:ring-gray-500 -ml-px first-of-type:-ml-0"+ )}+ >+ {checkSize.label}+ </Link>+ ))}+ </span><SearchBar search={search} setSearch={setSearch} /></div><div className="mt-8 flex flex-col">diff --git a/components/investors/table.tsx b/components/investors/table.tsxindex e701ddf8..760bcd9d 100644--- a/components/investors/table.tsx+++ b/components/investors/table.tsx@@ -20,12 +20,10 @@ interface Fields {openSourceInvestments: string;checkSize:| "Unknown"- | "$2-5k"- | "$5-15k"- | "$15-25k"- | "$25-50k"- | "$50-100k"- | "$100k+";+ | "$5k - $50k"+ | "$50k+"+ | "$100k+"+ | "$250k+"}export default function Table({ investors }: { investors: Investor[]; }) {@@ -124,14 +122,14 @@ export default function Table({ investors }: { investors: Investor[]; }) {<spanclassName={cn(person.fields.checkSize === "Unknown"+ ? "bg-gray-100 text-gray-800"+ : person.fields.checkSize === "$5k - $50k"? "bg-green-100 text-green-800"- : person.fields.checkSize === "$2-5k"+ : person.fields.checkSize === "$50k+"? "bg-blue-100 text-blue-800"- : person.fields.checkSize === "$5-15k"- ? "bg-red-100 text-red-800"- : person.fields.checkSize === "$15-25k"- ? "bg-cyan-100 text-cyan-800"- : person.fields.checkSize === "$25-50k"+ : person.fields.checkSize === "$100k+"+ ? "bg-purple-100 text-purple-800"+ : person.fields.checkSize === "$250k+"? "bg-yellow-100 text-yellow-800": "bg-orange-100 text-orange-800","inline-flex rounded-full px-[9px] py-[2px] text-xs font-semibold leading-5"