|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | import Benchmark from "benchmark";
|
| 3 | +import {cva} from "class-variance-authority"; |
| 4 | +import {extendTailwindMerge} from "tailwind-merge"; |
3 | 5 |
|
4 | 6 | import {tv} from "./src/index.js";
|
5 | 7 |
|
@@ -322,6 +324,57 @@ export const avatarWithCustomConfig = tv(
|
322 | 324 | },
|
323 | 325 | );
|
324 | 326 |
|
| 327 | +// CVA without tw-merge config |
| 328 | +const cvaNoMerge = { |
| 329 | + avatar: cva("relative flex shrink-0 overflow-hidden rounded-full", { |
| 330 | + variants: { |
| 331 | + size: { |
| 332 | + xs: "h-6 w-6", |
| 333 | + sm: "h-8 w-8", |
| 334 | + md: "h-10 w-10", |
| 335 | + lg: "h-12 w-12", |
| 336 | + xl: "h-14 w-14", |
| 337 | + }, |
| 338 | + }, |
| 339 | + defaultVariants: { |
| 340 | + size: "md", |
| 341 | + }, |
| 342 | + compoundVariants: [ |
| 343 | + { |
| 344 | + size: ["xs", "sm"], |
| 345 | + class: "ring-1", |
| 346 | + }, |
| 347 | + { |
| 348 | + size: ["md", "lg", "xl", "2xl"], |
| 349 | + class: "ring-2", |
| 350 | + }, |
| 351 | + ], |
| 352 | + }), |
| 353 | + image: cva("aspect-square h-full w-full", { |
| 354 | + variants: { |
| 355 | + withBorder: { |
| 356 | + true: "border-1.5 border-white", |
| 357 | + }, |
| 358 | + }, |
| 359 | + }), |
| 360 | + fallback: cva("flex h-full w-full items-center justify-center rounded-full bg-muted", { |
| 361 | + variants: { |
| 362 | + size: { |
| 363 | + xs: "text-xs", |
| 364 | + sm: "text-sm", |
| 365 | + md: "text-base", |
| 366 | + lg: "text-lg", |
| 367 | + xl: "text-xl", |
| 368 | + }, |
| 369 | + }, |
| 370 | + defaultVariants: { |
| 371 | + size: "md", |
| 372 | + }, |
| 373 | + }), |
| 374 | +}; |
| 375 | + |
| 376 | +const cvaMerge = extendTailwindMerge({extend: twMergeConfig}); |
| 377 | + |
325 | 378 | // add tests
|
326 | 379 | suite
|
327 | 380 | .add("TV without slots & tw-merge (enabled)", function () {
|
@@ -360,6 +413,16 @@ suite
|
360 | 413 | fallback();
|
361 | 414 | image();
|
362 | 415 | })
|
| 416 | + .add("CVA without slots & tw-merge (enabled)", function () { |
| 417 | + cvaMerge(cvaNoMerge.avatar({size: "md"})); |
| 418 | + cvaMerge(cvaNoMerge.fallback()); |
| 419 | + cvaMerge(cvaNoMerge.image()); |
| 420 | + }) |
| 421 | + .add("CVA without slots & tw-merge (disabled)", function () { |
| 422 | + cvaNoMerge.avatar({size: "md"}); |
| 423 | + cvaNoMerge.fallback(); |
| 424 | + cvaNoMerge.image(); |
| 425 | + }) |
363 | 426 |
|
364 | 427 | // add listeners
|
365 | 428 | .on("cycle", function (event) {
|
|
0 commit comments