@faststore/components 2.0.62-alpha.0 → 2.0.63-alpha.0

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.
package/dist/index.d.ts CHANGED
@@ -54,6 +54,8 @@ export { default as LinkButton } from './molecules/LinkButton';
54
54
  export type { LinkButtonProps } from './molecules/LinkButton';
55
55
  export { default as Modal, ModalHeader, ModalBody } from './molecules/Modal';
56
56
  export type { ModalProps, ModalHeaderProps } from './molecules/Modal';
57
+ export { default as ProductCard, ProductCardImage, ProductCardContent, } from './molecules/ProductCard';
58
+ export type { ProductCardProps, ProductCardImageProps, ProductCardContentProps, } from './molecules/ProductCard';
57
59
  export { default as ProductTitle } from './molecules/ProductTitle';
58
60
  export type { ProductTitleProps } from './molecules/ProductTitle';
59
61
  export { default as RadioField } from './molecules/RadioField';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ export { default as Gift, GiftContent, GiftImage } from './molecules/Gift';
32
32
  export { default as InputField } from './molecules/InputField';
33
33
  export { default as LinkButton } from './molecules/LinkButton';
34
34
  export { default as Modal, ModalHeader, ModalBody } from './molecules/Modal';
35
+ export { default as ProductCard, ProductCardImage, ProductCardContent, } from './molecules/ProductCard';
35
36
  export { default as ProductTitle } from './molecules/ProductTitle';
36
37
  export { default as RadioField } from './molecules/RadioField';
37
38
  export { default as RadioGroup, RadioOption } from './molecules/RadioGroup';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,UAAU,CAAA;AAExB,QAAQ;AACR,cAAc,SAAS,CAAA;AAEvB,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB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D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAE3E,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,GACT,MAAM,mBAAmB,CAAA;AAS1B,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG1E,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAO1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGtE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { HTMLAttributes } from 'react';
3
+ export interface ProductCardProps extends HTMLAttributes<HTMLDivElement> {
4
+ /**
5
+ * Sets a border to the component.
6
+ */
7
+ bordered?: boolean;
8
+ /**
9
+ * Sets the component's size.
10
+ */
11
+ variant?: 'wide' | 'default';
12
+ /**
13
+ * Enables a outOfStock status.
14
+ */
15
+ outOfStock?: boolean;
16
+ /**
17
+ * ID to find this component in testing tools (e.g.: cypress,
18
+ * testing-library, and jest).
19
+ */
20
+ testId?: string;
21
+ }
22
+ declare const ProductCard: React.ForwardRefExoticComponent<ProductCardProps & React.RefAttributes<HTMLDivElement>>;
23
+ export default ProductCard;
@@ -0,0 +1,6 @@
1
+ import React, { forwardRef } from 'react';
2
+ const ProductCard = forwardRef(function ProductCard({ testId = 'fs-product-card', variant = 'default', bordered = false, outOfStock, children, ...otherProps }, ref) {
3
+ return (React.createElement("article", { ref: ref, "data-fs-product-card": outOfStock ? 'out-of-stock' : '', "data-fs-product-card-variant": variant, "data-fs-product-card-bordered": bordered, "data-testid": testId, ...otherProps }, children));
4
+ });
5
+ export default ProductCard;
6
+ //# sourceMappingURL=ProductCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCard.js","sourceRoot":"","sources":["../../../src/molecules/ProductCard/ProductCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAuBzC,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EACE,MAAM,GAAG,iBAAiB,EAC1B,OAAO,GAAG,SAAS,EACnB,QAAQ,GAAG,KAAK,EAChB,UAAU,EACV,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,iCACE,GAAG,EAAE,GAAG,0BACc,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,kCACxB,OAAO,mCACN,QAAQ,iBAC1B,MAAM,KACf,UAAU,IAEb,QAAQ,CACD,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -0,0 +1,53 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ import React from 'react';
3
+ import type { PriceFormatter } from '../../atoms/Price/Price';
4
+ import { Price, LinkProps, LinkElementType } from '../../';
5
+ interface Price {
6
+ value: number;
7
+ listPrice: number;
8
+ formatter: PriceFormatter;
9
+ }
10
+ export interface ProductCardContentProps extends HTMLAttributes<HTMLElement> {
11
+ /**
12
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
13
+ */
14
+ testId?: string;
15
+ /**
16
+ * Specifies the product's title.
17
+ */
18
+ title: string;
19
+ /**
20
+ * Props for the link from ProductCard component.
21
+ */
22
+ linkProps?: Partial<LinkProps<LinkElementType>>;
23
+ /**
24
+ * Specifies product's prices.
25
+ */
26
+ price?: Price;
27
+ /**
28
+ * Enables a outOfStock status.
29
+ */
30
+ outOfStock?: boolean;
31
+ /**
32
+ * Specifies the OutOfStock badge's label.
33
+ */
34
+ outOfStockLabel?: string;
35
+ /**
36
+ * Specifies Rating Value of the product.
37
+ */
38
+ ratingValue?: number;
39
+ /**
40
+ * Callback function when button is clicked.
41
+ */
42
+ onButtonClick?: () => void;
43
+ /**
44
+ * Specifies the button's label.
45
+ */
46
+ buttonLabel?: string;
47
+ /**
48
+ * Enables a DiscountBadge to the component.
49
+ */
50
+ showDiscountBadge?: boolean;
51
+ }
52
+ declare const ProductCardContent: React.ForwardRefExoticComponent<ProductCardContentProps & React.RefAttributes<HTMLElement>>;
53
+ export default ProductCardContent;
@@ -0,0 +1,19 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { Link, Price, Badge, Button, Rating, DiscountBadge, } from '../../';
3
+ import { Star, ShoppingCart } from '../../assets';
4
+ const ProductCardContent = forwardRef(function CardContent({ testId = 'fs-product-card-content', title, linkProps, price, outOfStock, outOfStockLabel = 'Out of stock', ratingValue, showDiscountBadge, buttonLabel = 'Add', onButtonClick, children, ...otherProps }, ref) {
5
+ return (React.createElement("section", { ref: ref, "data-fs-product-card-content": true, "data-fs-product-card-badge": showDiscountBadge, "data-testid": testId, ...otherProps },
6
+ React.createElement("div", { "data-fs-product-card-heading": true },
7
+ React.createElement("h3", { "data-fs-product-card-title": true },
8
+ React.createElement(Link, { ...linkProps, title: title }, title)),
9
+ React.createElement("div", { "data-fs-product-card-prices": true },
10
+ React.createElement(Price, { value: price?.listPrice ? price.listPrice : 0, formatter: price?.formatter, testId: "list-price", "data-value": price?.listPrice, variant: "listing" }),
11
+ React.createElement(Price, { value: price?.value ? price.value : 0, formatter: price?.formatter, testId: "price", "data-value": price?.value, variant: "spot" })),
12
+ ratingValue && React.createElement(Rating, { value: ratingValue, icon: React.createElement(Star, null) })),
13
+ showDiscountBadge && !outOfStock && (React.createElement(DiscountBadge, { listPrice: price?.listPrice ? price.listPrice : 0, spotPrice: price?.value ? price.value : 0 })),
14
+ outOfStock && React.createElement(Badge, null, outOfStockLabel),
15
+ onButtonClick && !outOfStock && (React.createElement("div", { "data-fs-product-card-actions": true },
16
+ React.createElement(Button, { variant: "primary", icon: React.createElement(ShoppingCart, null), iconPosition: "left", size: "small", onClick: onButtonClick }, buttonLabel)))));
17
+ });
18
+ export default ProductCardContent;
19
+ //# sourceMappingURL=ProductCardContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCardContent.js","sourceRoot":"","sources":["../../../src/molecules/ProductCard/ProductCardContent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIzC,OAAO,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,GAGd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAmDjD,MAAM,kBAAkB,GAAG,UAAU,CACnC,SAAS,WAAW,CAClB,EACE,MAAM,GAAG,yBAAyB,EAClC,KAAK,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,eAAe,GAAG,cAAc,EAChC,WAAW,EACX,iBAAiB,EACjB,WAAW,GAAG,KAAK,EACnB,aAAa,EACb,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,iCACE,GAAG,EAAE,GAAG,sEAEoB,iBAAiB,iBAChC,MAAM,KACf,UAAU;QAEd;YACE;gBACE,oBAAC,IAAI,OAAK,SAAS,EAAE,KAAK,EAAE,KAAK,IAC9B,KAAK,CACD,CACJ;YACL;gBACE,oBAAC,KAAK,IACJ,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7C,SAAS,EAAE,KAAK,EAAE,SAAS,EAC3B,MAAM,EAAC,YAAY,gBACP,KAAK,EAAE,SAAS,EAC5B,OAAO,EAAC,SAAS,GACjB;gBACF,oBAAC,KAAK,IACJ,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACrC,SAAS,EAAE,KAAK,EAAE,SAAS,EAC3B,MAAM,EAAC,OAAO,gBACF,KAAK,EAAE,KAAK,EACxB,OAAO,EAAC,MAAM,GACd,CACE;YACL,WAAW,IAAI,oBAAC,MAAM,IAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,oBAAC,IAAI,OAAG,GAAI,CAC1D;QACL,iBAAiB,IAAI,CAAC,UAAU,IAAI,CACnC,oBAAC,aAAa,IACZ,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EACjD,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GACzC,CACH;QACA,UAAU,IAAI,oBAAC,KAAK,QAAE,eAAe,CAAS;QAC9C,aAAa,IAAI,CAAC,UAAU,IAAI,CAC/B;YACE,oBAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAE,oBAAC,YAAY,OAAG,EACtB,YAAY,EAAC,MAAM,EACnB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,aAAa,IAErB,WAAW,CACL,CACL,CACP,CACO,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,kBAAkB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ import React from 'react';
3
+ export interface ProductCardImageProps extends HTMLAttributes<HTMLDivElement> {
4
+ /**
5
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
6
+ */
7
+ testId?: string;
8
+ /**
9
+ * Specifies the ProductCard image's aspect ratio.
10
+ */
11
+ aspectRatio?: number;
12
+ }
13
+ declare const ProductCardImage: React.ForwardRefExoticComponent<ProductCardImageProps & React.RefAttributes<HTMLDivElement>>;
14
+ export default ProductCardImage;
@@ -0,0 +1,8 @@
1
+ import React, { forwardRef } from 'react';
2
+ const ProductCardImage = forwardRef(function ProductCardImage({ testId = 'fs-product-card-image', aspectRatio = 1, children, ...otherProps }, ref) {
3
+ return (React.createElement("div", { ref: ref, "data-fs-product-card-image": true, "data-testid": testId, style: {
4
+ '--fs-product-card-image-aspect-ratio': aspectRatio
5
+ }, ...otherProps }, children));
6
+ });
7
+ export default ProductCardImage;
8
+ //# sourceMappingURL=ProductCardImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCardImage.js","sourceRoot":"","sources":["../../../src/molecules/ProductCard/ProductCardImage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAazC,MAAM,gBAAgB,GAAG,UAAU,CACjC,SAAS,gBAAgB,CACvB,EACE,MAAM,GAAG,uBAAuB,EAChC,WAAW,GAAG,CAAC,EACf,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,qDAEK,MAAM,EACnB,KAAK,EACH;YACE,sCAAsC,EAAE,WAAW;SAC7B,KAEtB,UAAU,IAEb,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { default } from './ProductCard';
2
+ export type { ProductCardProps } from './ProductCard';
3
+ export { default as ProductCardImage } from './ProductCardImage';
4
+ export type { ProductCardImageProps } from './ProductCardImage';
5
+ export { default as ProductCardContent } from './ProductCardContent';
6
+ export type { ProductCardContentProps } from './ProductCardContent';
@@ -0,0 +1,4 @@
1
+ export { default } from './ProductCard';
2
+ export { default as ProductCardImage } from './ProductCardImage';
3
+ export { default as ProductCardContent } from './ProductCardContent';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/ProductCard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/components",
3
- "version": "2.0.62-alpha.0",
3
+ "version": "2.0.63-alpha.0",
4
4
  "module": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "author": "Emerson Laurentino @emersonlaurentino",
@@ -30,5 +30,5 @@
30
30
  "node": "16.18.0",
31
31
  "yarn": "1.19.1"
32
32
  },
33
- "gitHead": "62683f903ca899d767fae418db5169cadf15e0f4"
33
+ "gitHead": "2f3645ace573036dfa23787a46992432389e242c"
34
34
  }
package/src/index.ts CHANGED
@@ -93,6 +93,16 @@ export { default as LinkButton } from './molecules/LinkButton'
93
93
  export type { LinkButtonProps } from './molecules/LinkButton'
94
94
  export { default as Modal, ModalHeader, ModalBody } from './molecules/Modal'
95
95
  export type { ModalProps, ModalHeaderProps } from './molecules/Modal'
96
+ export {
97
+ default as ProductCard,
98
+ ProductCardImage,
99
+ ProductCardContent,
100
+ } from './molecules/ProductCard'
101
+ export type {
102
+ ProductCardProps,
103
+ ProductCardImageProps,
104
+ ProductCardContentProps,
105
+ } from './molecules/ProductCard'
96
106
  export { default as ProductTitle } from './molecules/ProductTitle'
97
107
  export type { ProductTitleProps } from './molecules/ProductTitle'
98
108
  export { default as RadioField } from './molecules/RadioField'
@@ -0,0 +1,51 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { HTMLAttributes } from 'react'
3
+
4
+ export interface ProductCardProps extends HTMLAttributes<HTMLDivElement> {
5
+ /**
6
+ * Sets a border to the component.
7
+ */
8
+ bordered?: boolean
9
+ /**
10
+ * Sets the component's size.
11
+ */
12
+ variant?: 'wide' | 'default'
13
+ /**
14
+ * Enables a outOfStock status.
15
+ */
16
+ outOfStock?: boolean
17
+ /**
18
+ * ID to find this component in testing tools (e.g.: cypress,
19
+ * testing-library, and jest).
20
+ */
21
+ testId?: string
22
+ }
23
+
24
+ const ProductCard = forwardRef<HTMLDivElement, ProductCardProps>(
25
+ function ProductCard(
26
+ {
27
+ testId = 'fs-product-card',
28
+ variant = 'default',
29
+ bordered = false,
30
+ outOfStock,
31
+ children,
32
+ ...otherProps
33
+ },
34
+ ref
35
+ ) {
36
+ return (
37
+ <article
38
+ ref={ref}
39
+ data-fs-product-card={outOfStock ? 'out-of-stock' : ''}
40
+ data-fs-product-card-variant={variant}
41
+ data-fs-product-card-bordered={bordered}
42
+ data-testid={testId}
43
+ {...otherProps}
44
+ >
45
+ {children}
46
+ </article>
47
+ )
48
+ }
49
+ )
50
+
51
+ export default ProductCard
@@ -0,0 +1,142 @@
1
+ import type { HTMLAttributes } from 'react'
2
+ import React, { forwardRef } from 'react'
3
+
4
+ import type { PriceFormatter } from '../../atoms/Price/Price'
5
+
6
+ import {
7
+ Link,
8
+ Price,
9
+ Badge,
10
+ Button,
11
+ Rating,
12
+ DiscountBadge,
13
+ LinkProps,
14
+ LinkElementType,
15
+ } from '../../'
16
+ import { Star, ShoppingCart } from '../../assets'
17
+
18
+ interface Price {
19
+ value: number
20
+ listPrice: number
21
+ formatter: PriceFormatter
22
+ }
23
+
24
+ export interface ProductCardContentProps extends HTMLAttributes<HTMLElement> {
25
+ /**
26
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
27
+ */
28
+ testId?: string
29
+ /**
30
+ * Specifies the product's title.
31
+ */
32
+ title: string
33
+ /**
34
+ * Props for the link from ProductCard component.
35
+ */
36
+ linkProps?: Partial<LinkProps<LinkElementType>>
37
+ /**
38
+ * Specifies product's prices.
39
+ */
40
+ price?: Price
41
+ /**
42
+ * Enables a outOfStock status.
43
+ */
44
+ outOfStock?: boolean
45
+ /**
46
+ * Specifies the OutOfStock badge's label.
47
+ */
48
+ outOfStockLabel?: string
49
+ /**
50
+ * Specifies Rating Value of the product.
51
+ */
52
+ ratingValue?: number
53
+ /**
54
+ * Callback function when button is clicked.
55
+ */
56
+ onButtonClick?: () => void
57
+ /**
58
+ * Specifies the button's label.
59
+ */
60
+ buttonLabel?: string
61
+ /**
62
+ * Enables a DiscountBadge to the component.
63
+ */
64
+ showDiscountBadge?: boolean
65
+ }
66
+
67
+ const ProductCardContent = forwardRef<HTMLElement, ProductCardContentProps>(
68
+ function CardContent(
69
+ {
70
+ testId = 'fs-product-card-content',
71
+ title,
72
+ linkProps,
73
+ price,
74
+ outOfStock,
75
+ outOfStockLabel = 'Out of stock',
76
+ ratingValue,
77
+ showDiscountBadge,
78
+ buttonLabel = 'Add',
79
+ onButtonClick,
80
+ children,
81
+ ...otherProps
82
+ },
83
+ ref
84
+ ) {
85
+ return (
86
+ <section
87
+ ref={ref}
88
+ data-fs-product-card-content
89
+ data-fs-product-card-badge={showDiscountBadge}
90
+ data-testid={testId}
91
+ {...otherProps}
92
+ >
93
+ <div data-fs-product-card-heading>
94
+ <h3 data-fs-product-card-title>
95
+ <Link {...linkProps} title={title}>
96
+ {title}
97
+ </Link>
98
+ </h3>
99
+ <div data-fs-product-card-prices>
100
+ <Price
101
+ value={price?.listPrice ? price.listPrice : 0}
102
+ formatter={price?.formatter}
103
+ testId="list-price"
104
+ data-value={price?.listPrice}
105
+ variant="listing"
106
+ />
107
+ <Price
108
+ value={price?.value ? price.value : 0}
109
+ formatter={price?.formatter}
110
+ testId="price"
111
+ data-value={price?.value}
112
+ variant="spot"
113
+ />
114
+ </div>
115
+ {ratingValue && <Rating value={ratingValue} icon={<Star />} />}
116
+ </div>
117
+ {showDiscountBadge && !outOfStock && (
118
+ <DiscountBadge
119
+ listPrice={price?.listPrice ? price.listPrice : 0}
120
+ spotPrice={price?.value ? price.value : 0}
121
+ />
122
+ )}
123
+ {outOfStock && <Badge>{outOfStockLabel}</Badge>}
124
+ {onButtonClick && !outOfStock && (
125
+ <div data-fs-product-card-actions>
126
+ <Button
127
+ variant="primary"
128
+ icon={<ShoppingCart />}
129
+ iconPosition="left"
130
+ size="small"
131
+ onClick={onButtonClick}
132
+ >
133
+ {buttonLabel}
134
+ </Button>
135
+ </div>
136
+ )}
137
+ </section>
138
+ )
139
+ }
140
+ )
141
+
142
+ export default ProductCardContent
@@ -0,0 +1,43 @@
1
+ import type { HTMLAttributes } from 'react'
2
+ import React, { forwardRef } from 'react'
3
+
4
+ export interface ProductCardImageProps extends HTMLAttributes<HTMLDivElement> {
5
+ /**
6
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
7
+ */
8
+ testId?: string
9
+ /**
10
+ * Specifies the ProductCard image's aspect ratio.
11
+ */
12
+ aspectRatio?: number
13
+ }
14
+
15
+ const ProductCardImage = forwardRef<HTMLDivElement, ProductCardImageProps>(
16
+ function ProductCardImage(
17
+ {
18
+ testId = 'fs-product-card-image',
19
+ aspectRatio = 1,
20
+ children,
21
+ ...otherProps
22
+ },
23
+ ref
24
+ ) {
25
+ return (
26
+ <div
27
+ ref={ref}
28
+ data-fs-product-card-image
29
+ data-testid={testId}
30
+ style={
31
+ {
32
+ '--fs-product-card-image-aspect-ratio': aspectRatio
33
+ } as React.CSSProperties
34
+ }
35
+ {...otherProps}
36
+ >
37
+ {children}
38
+ </div>
39
+ )
40
+ }
41
+ )
42
+
43
+ export default ProductCardImage
@@ -0,0 +1,8 @@
1
+ export { default } from './ProductCard'
2
+ export type { ProductCardProps } from './ProductCard'
3
+
4
+ export { default as ProductCardImage } from './ProductCardImage'
5
+ export type { ProductCardImageProps } from './ProductCardImage'
6
+
7
+ export { default as ProductCardContent } from './ProductCardContent'
8
+ export type { ProductCardContentProps } from './ProductCardContent'