@tapcart/mobile-components 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ import { Slot } from "@radix-ui/react-slot";
15
15
  import { cva } from "class-variance-authority";
16
16
  import { IconLoader2 } from "@tabler/icons-react";
17
17
  import { cn } from "../../lib/utils";
18
- const buttonVariants = cva("flex rounded items-center justify-center text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:bg-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate", {
18
+ const buttonVariants = cva("w-full flex rounded items-center justify-center text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:bg-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate", {
19
19
  variants: {
20
20
  size: {
21
21
  default: "h-10 py-3 px-4",
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ type ProductCardProps = {
3
+ product: {
4
+ variants: {
5
+ compare_at_price: number | null;
6
+ price: number;
7
+ }[];
8
+ images: {
9
+ src: string;
10
+ }[];
11
+ title: string;
12
+ tags: string[];
13
+ };
14
+ className?: string;
15
+ quickAdd: (e: React.MouseEvent<HTMLButtonElement>, product: any) => void;
16
+ openProduct: (e: React.MouseEvent<HTMLDivElement>, product: any) => void;
17
+ imageRatio: "1:1" | "2:3" | "4:5";
18
+ imageFit: "fit" | "fill";
19
+ theme: {
20
+ textColors: {
21
+ priceProduct: string;
22
+ productTitle: string;
23
+ };
24
+ font: {
25
+ productTitle: string;
26
+ productPrice: string;
27
+ };
28
+ };
29
+ };
30
+ declare const ProductCard: React.FC<ProductCardProps>;
31
+ export default ProductCard;
32
+ //# sourceMappingURL=product-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":";AAGA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE;QACP,QAAQ,EAAE;YAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/D,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACzE,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACzE,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAClC,QAAQ,EAAE,KAAK,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE;QACL,UAAU,EAAE;YACV,YAAY,EAAE,MAAM,CAAC;YACrB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,IAAI,EAAE;YACJ,YAAY,EAAE,MAAM,CAAC;YACrB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0E3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, AspectRatio, Text, Badge, Loading } from "@tapcart/mobile-components";
3
+ import { useEffect, useState } from "react";
4
+ const ProductCard = ({ product, className, quickAdd, openProduct, imageRatio, imageFit, theme, }) => {
5
+ const [loading, setLoading] = useState(true);
6
+ useEffect(() => {
7
+ // Simulate loading
8
+ const timer = setTimeout(() => setLoading(false), 1000);
9
+ return () => clearTimeout(timer);
10
+ }, []);
11
+ const variant = product.variants[0];
12
+ const aspectRatio = {
13
+ "1:1": 1,
14
+ "2:3": 2 / 3,
15
+ "4:5": 4 / 5,
16
+ }[imageRatio];
17
+ if (loading) {
18
+ return _jsx(Loading, {});
19
+ }
20
+ return (_jsxs("div", Object.assign({ className: `${className}`, onClick: (e) => openProduct(e, product) }, { children: [_jsxs(AspectRatio, Object.assign({ ratio: aspectRatio }, { children: [_jsx("img", { className: `w-full h-full object-${imageFit} rounded-t-lg`, src: product.images[0].src, alt: product.title }), product.tags.includes("SUMMER") && (_jsx(Badge, Object.assign({ variant: "secondary", className: "absolute bottom-[15px] rounded-none bg-[#e2fe9f] pointer-events-none" }, { children: "SUMMER" })))] })), _jsx(Button, Object.assign({ variant: "quickadd", size: "sm", onClick: (e) => quickAdd(e, product) }, { children: "+ Quick add" })), _jsx(Text, Object.assign({ className: `text-xs mt-[8px] ${theme.font.productTitle}`, style: { color: theme.textColors.productTitle } }, { children: product.title })), _jsxs("div", Object.assign({ className: "flex mt-[4px]" }, { children: [variant.compare_at_price && (_jsxs(Text, Object.assign({ className: `text-sm mr-[8px] line-through text-red-500 ${theme.font.productPrice}` }, { children: ["$", variant.compare_at_price] }))), _jsxs(Text, Object.assign({ className: `text-sm ${theme.font.productPrice}`, style: { color: theme.textColors.priceProduct } }, { children: ["$", variant.price] }))] }))] })));
21
+ };
22
+ export default ProductCard;