ShoppingCartIcon.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { type ComponentProps, type ReactNode } from "react";
  2. import clsx from "clsx";
  3. interface ShoppingCartIconProps extends ComponentProps<"svg"> {
  4. icon?: ReactNode;
  5. }
  6. export default function ShoppingCartIcon({
  7. className,
  8. icon,
  9. }: ShoppingCartIconProps) {
  10. // 如果传了 icon → 直接返回自定义图标
  11. if (icon) {
  12. return <>{icon}</>;
  13. }
  14. // 没传 → 返回默认购物车图标
  15. return (
  16. <svg
  17. className={clsx("fill-primary h-5 w-5 dark:fill-transparent", className)}
  18. fill="none"
  19. stroke="currentColor"
  20. strokeWidth="1.5"
  21. viewBox="0 0 24 24"
  22. xmlns="http://www.w3.org/2000/svg"
  23. >
  24. <path
  25. d="M2.25 3h1.386c.51 0 .955.343 1.087.835l.383 1.437M7.5 14.25a3 3 0 0 0-3 3h15.75m-12.75-3h11.218c1.121-2.3 2.1-4.684 2.924-7.138a60.114 60.114 0 0 0-16.536-1.84M7.5 14.25 5.106 5.272M6 20.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm12.75 0a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"
  26. strokeLinecap="round"
  27. strokeLinejoin="round"
  28. />
  29. </svg>
  30. );
  31. }