|
1 | 1 | import { AdjustmentsHorizontalIcon, CheckIcon, XMarkIcon } from "@heroicons/react/20/solid"; |
2 | 2 | import { Form, type MetaFunction, useFetcher } from "@remix-run/react"; |
3 | 3 | import { type LoaderFunctionArgs } from "@remix-run/server-runtime"; |
| 4 | +import { AnimatePresence, motion } from "framer-motion"; |
4 | 5 | import { useEffect, useMemo, useState } from "react"; |
5 | 6 | import { typedjson, useTypedLoaderData } from "remix-typedjson"; |
6 | 7 | import { PageBody, PageContainer } from "~/components/layout/AppLayout"; |
7 | 8 | import { AppliedFilter } from "~/components/primitives/AppliedFilter"; |
| 9 | +import { Badge } from "~/components/primitives/Badge"; |
8 | 10 | import { Button } from "~/components/primitives/Buttons"; |
9 | 11 | import { Checkbox } from "~/components/primitives/Checkbox"; |
10 | 12 | import { DateTime } from "~/components/primitives/DateTime"; |
@@ -53,7 +55,7 @@ import { |
53 | 55 | } from "~/utils/modelFormatters"; |
54 | 56 | import { formatNumberCompact } from "~/utils/numberFormatter"; |
55 | 57 | import { Spinner } from "~/components/primitives/Spinner"; |
56 | | -import { SimpleTooltip } from "~/components/primitives/Tooltip"; |
| 58 | + |
57 | 59 | import { type loader as compareLoader } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.models.compare/route"; |
58 | 60 |
|
59 | 61 | export const meta: MetaFunction = () => { |
@@ -262,21 +264,31 @@ function FiltersBar({ |
262 | 264 | )} |
263 | 265 | </div> |
264 | 266 | <div className="flex shrink-0 items-center gap-2"> |
265 | | - {compareDisabled ? ( |
266 | | - <SimpleTooltip |
267 | | - button={ |
268 | | - <Button variant="secondary/small" disabled> |
269 | | - Compare |
270 | | - </Button> |
271 | | - } |
272 | | - content="Choose 2–4 models to compare" |
273 | | - asChild |
274 | | - /> |
275 | | - ) : ( |
276 | | - <Button variant="secondary/small" onClick={onCompare}> |
277 | | - Compare ({compareSet.size}) |
278 | | - </Button> |
279 | | - )} |
| 267 | + <Button |
| 268 | + variant="secondary/small" |
| 269 | + disabled={compareDisabled} |
| 270 | + className="px-1.5" |
| 271 | + tooltip={compareDisabled ? "Choose 2–4 models to compare" : "Compare selected models"} |
| 272 | + onClick={compareDisabled ? undefined : onCompare} |
| 273 | + > |
| 274 | + <span className="flex items-center overflow-hidden"> |
| 275 | + <span className={!compareDisabled ? "text-text-bright" : undefined}>Compare</span> |
| 276 | + <AnimatePresence initial={false}> |
| 277 | + {compareSet.size >= 2 && ( |
| 278 | + <motion.span |
| 279 | + key="badge" |
| 280 | + initial={{ width: 0, marginLeft: 0, opacity: 0 }} |
| 281 | + animate={{ width: "auto", marginLeft: 4, opacity: 1 }} |
| 282 | + exit={{ width: 0, marginLeft: 0, opacity: 0 }} |
| 283 | + transition={{ duration: 0.15, ease: "easeInOut" }} |
| 284 | + className="inline-flex" |
| 285 | + > |
| 286 | + <Badge variant="rounded">{compareSet.size}</Badge> |
| 287 | + </motion.span> |
| 288 | + )} |
| 289 | + </AnimatePresence> |
| 290 | + </span> |
| 291 | + </Button> |
280 | 292 | <Switch |
281 | 293 | variant="secondary/small" |
282 | 294 | label="All details" |
|
0 commit comments