decathlon-ui 0.3.4 → 0.3.6
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/components/product-card/product-card.component.d.ts.map +1 -1
- package/dist/components/product-card/product-card.component.js +4 -4
- package/dist/components/product-card/product-card.styles.d.ts +3 -2
- package/dist/components/product-card/product-card.styles.d.ts.map +1 -1
- package/dist/components/product-card/product-card.styles.js +11 -7
- package/dist/components/product-card/product-card.types.d.ts +3 -0
- package/dist/components/product-card/product-card.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.component.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"product-card.component.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAkJ7D,eAAO,MAAM,WAAW,8CAAmC,CAAC"}
|
|
@@ -4,17 +4,17 @@ import { Image, Text, TouchableOpacity, View } from "react-native";
|
|
|
4
4
|
import { HeartIcon, StarIcon } from "../../icons";
|
|
5
5
|
import { Badge } from "../badge";
|
|
6
6
|
import { useProductCardStyles } from "./product-card.styles";
|
|
7
|
-
const ProductCardComponent = ({ variant = "grid", imageUrl, brand, productName, rating, reviewCount, price, isFavorite = false, onFavoritePress, onPress, testID, flags = [], }) => {
|
|
8
|
-
const styles = useProductCardStyles(variant);
|
|
7
|
+
const ProductCardComponent = ({ variant = "grid", imageUrl, brand, productName, rating, reviewCount, price, isFavorite = false, onFavoritePress, onPress, testID, width, flags = [], showFavoriteButton = true, showRating = true, }) => {
|
|
8
|
+
const styles = useProductCardStyles(variant, width);
|
|
9
9
|
const handleFavoritePress = React.useCallback((e) => {
|
|
10
10
|
e.stopPropagation();
|
|
11
11
|
onFavoritePress === null || onFavoritePress === void 0 ? void 0 : onFavoritePress();
|
|
12
12
|
}, [onFavoritePress]);
|
|
13
13
|
const renderContent = React.useCallback(() => (_jsxs(View, { style: styles.cardContainer, children: [_jsxs(View, { style: styles.imageContainer, children: [_jsx(Image, { resizeMode: "cover", source: { uri: imageUrl }, style: styles.productImage, accessibilityLabel: `Imagem do produto ${productName}` }), ["grid", "shelf"].includes(variant) &&
|
|
14
14
|
(flags === null || flags === void 0 ? void 0 : flags.length) > 0 &&
|
|
15
|
-
(flags === null || flags === void 0 ? void 0 : flags.map((flag, index) => (_jsx(Badge, { text: flag.text, style: { position: "absolute", top: 0, left: 0 }, icon: flag.icon }, flag.name + index + productName)))), variant === "grid" && (_jsx(TouchableOpacity, { style: [
|
|
15
|
+
(flags === null || flags === void 0 ? void 0 : flags.map((flag, index) => (_jsx(Badge, { text: flag.text, style: { position: "absolute", top: 0, left: 0 }, icon: flag.icon }, flag.name + index + productName)))), variant === "grid" && showFavoriteButton && (_jsx(TouchableOpacity, { style: [
|
|
16
16
|
isFavorite ? styles.favoriteButton : styles.unfavoriteButton,
|
|
17
|
-
], onPress: handleFavoritePress, accessibilityLabel: isFavorite ? "Remover dos favoritos" : "Adicionar aos favoritos", accessibilityRole: "button", children: _jsx(HeartIcon, { size: 20, color: "#101010", fill: isFavorite ? "#101010" : "transparent" }) }))] }), variant !== "lastViewed" && (_jsxs(View, { style: styles.detailsContainer, children: [_jsxs(View, { style: styles.productInfo, children: [_jsx(Text, { style: styles.brandText, children: brand }), _jsx(View, { style: styles.nameContainer, children: _jsx(Text, { numberOfLines: 3, style: styles.nameText, accessibilityLabel: `Nome do produto: ${productName}`, children: productName }) })] }), variant === "grid" && (_jsxs(View, { style: styles.ratingContainer, accessibilityLabel: `Avaliação: ${rating} estrelas, ${reviewCount} avaliações`, children: [_jsx(StarIcon, { size: 11, color: "#101010", fill: "#101010" }), _jsxs(View, { style: styles.reviewCountWrapper, children: [_jsx(Text, { style: styles.ratingText, children: rating }), _jsxs(Text, { style: styles.reviewCountText, children: ["(", reviewCount, ")"] })] })] })), _jsx(View, { style: styles.priceContainer, children: _jsx(Text, { style: styles.priceText, accessibilityLabel: `Preço: ${price}`, children: price }) })] }))] })), [
|
|
17
|
+
], onPress: handleFavoritePress, accessibilityLabel: isFavorite ? "Remover dos favoritos" : "Adicionar aos favoritos", accessibilityRole: "button", children: _jsx(HeartIcon, { size: 20, color: "#101010", fill: isFavorite ? "#101010" : "transparent" }) }))] }), variant !== "lastViewed" && (_jsxs(View, { style: styles.detailsContainer, children: [_jsxs(View, { style: styles.productInfo, children: [_jsx(Text, { style: styles.brandText, children: brand }), _jsx(View, { style: styles.nameContainer, children: _jsx(Text, { numberOfLines: 3, style: styles.nameText, accessibilityLabel: `Nome do produto: ${productName}`, children: productName }) })] }), variant === "grid" && showRating && (_jsxs(View, { style: styles.ratingContainer, accessibilityLabel: `Avaliação: ${rating} estrelas, ${reviewCount} avaliações`, children: [_jsx(StarIcon, { size: 11, color: "#101010", fill: "#101010" }), _jsxs(View, { style: styles.reviewCountWrapper, children: [_jsx(Text, { style: styles.ratingText, children: rating }), _jsxs(Text, { style: styles.reviewCountText, children: ["(", reviewCount, ")"] })] })] })), _jsx(View, { style: styles.priceContainer, children: _jsx(Text, { style: styles.priceText, accessibilityLabel: `Preço: ${price}`, children: price }) })] }))] })), [
|
|
18
18
|
brand,
|
|
19
19
|
handleFavoritePress,
|
|
20
20
|
imageUrl,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ProductCardVariant } from "./product-card.types";
|
|
2
|
-
export declare const useProductCardStyles: (variant?: ProductCardVariant) => {
|
|
2
|
+
export declare const useProductCardStyles: (variant?: ProductCardVariant, customWidth?: number) => {
|
|
3
3
|
cardContainer: {
|
|
4
4
|
display: "flex";
|
|
5
|
+
width: number;
|
|
5
6
|
maxWidth: number;
|
|
6
7
|
flexDirection: "column";
|
|
7
8
|
alignItems: "stretch";
|
|
@@ -94,7 +95,7 @@ export declare const useProductCardStyles: (variant?: ProductCardVariant) => {
|
|
|
94
95
|
color: string;
|
|
95
96
|
};
|
|
96
97
|
touchable: {
|
|
97
|
-
width:
|
|
98
|
+
width: number;
|
|
98
99
|
maxWidth: number;
|
|
99
100
|
};
|
|
100
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.styles.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"product-card.styles.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,oBAAoB,GAC/B,UAAS,kBAA2B,EACpC,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
|
-
export const useProductCardStyles = (variant = "grid") => {
|
|
3
|
+
export const useProductCardStyles = (variant = "grid", customWidth) => {
|
|
4
4
|
return useMemo(() => {
|
|
5
5
|
const getImageSize = () => {
|
|
6
6
|
switch (variant) {
|
|
@@ -13,10 +13,14 @@ export const useProductCardStyles = (variant = "grid") => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const imageSize = getImageSize();
|
|
16
|
+
const cardWidth = customWidth
|
|
17
|
+
? Math.max(customWidth, imageSize)
|
|
18
|
+
: imageSize;
|
|
16
19
|
return StyleSheet.create({
|
|
17
20
|
cardContainer: {
|
|
18
21
|
display: "flex",
|
|
19
|
-
|
|
22
|
+
width: cardWidth,
|
|
23
|
+
maxWidth: cardWidth,
|
|
20
24
|
flexDirection: "column",
|
|
21
25
|
alignItems: "stretch",
|
|
22
26
|
},
|
|
@@ -33,8 +37,8 @@ export const useProductCardStyles = (variant = "grid") => {
|
|
|
33
37
|
aspectRatio: 1,
|
|
34
38
|
gap: 20,
|
|
35
39
|
justifyContent: "space-between",
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
40
|
+
width: cardWidth,
|
|
41
|
+
height: cardWidth,
|
|
38
42
|
},
|
|
39
43
|
detailsContainer: {
|
|
40
44
|
display: variant === "lastViewed" ? "none" : "flex",
|
|
@@ -108,9 +112,9 @@ export const useProductCardStyles = (variant = "grid") => {
|
|
|
108
112
|
color: "#383838",
|
|
109
113
|
},
|
|
110
114
|
touchable: {
|
|
111
|
-
width:
|
|
112
|
-
maxWidth:
|
|
115
|
+
width: cardWidth,
|
|
116
|
+
maxWidth: cardWidth,
|
|
113
117
|
},
|
|
114
118
|
});
|
|
115
|
-
}, [variant]);
|
|
119
|
+
}, [variant, customWidth]);
|
|
116
120
|
};
|
|
@@ -11,10 +11,13 @@ export interface ProductCardProps {
|
|
|
11
11
|
onFavoritePress?: () => void;
|
|
12
12
|
onPress?: () => void;
|
|
13
13
|
testID?: string;
|
|
14
|
+
width?: number;
|
|
14
15
|
flags?: {
|
|
15
16
|
name: string;
|
|
16
17
|
icon: string;
|
|
17
18
|
text: string;
|
|
18
19
|
}[];
|
|
20
|
+
showFavoriteButton?: boolean;
|
|
21
|
+
showRating?: boolean;
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=product-card.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.types.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"product-card.types.d.ts","sourceRoot":"","sources":["../../../src/components/product-card/product-card.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|