trepur_components 0.4.3 → 0.4.4
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/Image/index.js +36 -15
- package/package.json +1 -1
|
@@ -44,7 +44,8 @@ const imageProps = {
|
|
|
44
44
|
overlayColour: _propTypes.default.string,
|
|
45
45
|
overlayTextColour: _propTypes.default.string,
|
|
46
46
|
overlayOpacity: _propTypes.default.string,
|
|
47
|
-
overlayTextOpacity: _propTypes.default.string
|
|
47
|
+
overlayTextOpacity: _propTypes.default.string,
|
|
48
|
+
overlayText: _propTypes.default.string
|
|
48
49
|
};
|
|
49
50
|
exports.imageProps = imageProps;
|
|
50
51
|
|
|
@@ -53,6 +54,10 @@ const Image = _ref => {
|
|
|
53
54
|
imageProps
|
|
54
55
|
} = _ref;
|
|
55
56
|
const [isHovering, setIsHovering] = (0, _react.useState)(false);
|
|
57
|
+
const overlayOpacity = imageProps !== null && imageProps !== void 0 && imageProps.overlayOpacity ? imageProps === null || imageProps === void 0 ? void 0 : imageProps.overlayOpacity : 'opacity-100';
|
|
58
|
+
const opacity = isHovering ? overlayOpacity : 'opacity-0';
|
|
59
|
+
const overlayColour = imageProps !== null && imageProps !== void 0 && imageProps.overlayColour ? imageProps === null || imageProps === void 0 ? void 0 : imageProps.overlayColour : 'bg-white';
|
|
60
|
+
const overlayTextColour = imageProps !== null && imageProps !== void 0 && imageProps.overlayTextColour ? imageProps === null || imageProps === void 0 ? void 0 : imageProps.overlayTextColour : 'text-black';
|
|
56
61
|
const widthClassList = (0, _classnames.default)({
|
|
57
62
|
'w-6': imageProps.width === 1,
|
|
58
63
|
'w-10': imageProps.width === 2,
|
|
@@ -83,33 +88,49 @@ const Image = _ref => {
|
|
|
83
88
|
'h-full': imageProps.height === undefined,
|
|
84
89
|
'h-full': ![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].includes(imageProps.height)
|
|
85
90
|
});
|
|
86
|
-
const rounded = imageProps !== null && imageProps !== void 0 && imageProps.rounded ? 'rounded-full' : '';
|
|
87
91
|
const classList = (0, _classnames.default)({
|
|
88
|
-
[imageProps === null || imageProps === void 0 ? void 0 : imageProps.wrapperClasses]: imageProps === null || imageProps === void 0 ? void 0 : imageProps.wrapperClasses
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
[imageProps === null || imageProps === void 0 ? void 0 : imageProps.wrapperClasses]: imageProps === null || imageProps === void 0 ? void 0 : imageProps.wrapperClasses
|
|
93
|
+
});
|
|
94
|
+
const imageClassList = (0, _classnames.default)({
|
|
95
|
+
[imageProps === null || imageProps === void 0 ? void 0 : imageProps.imageClasses]: imageProps === null || imageProps === void 0 ? void 0 : imageProps.imageClasses,
|
|
96
|
+
[widthClassList]: true,
|
|
97
|
+
[heightClassList]: true,
|
|
98
|
+
'rounded-2xl': imageProps === null || imageProps === void 0 ? void 0 : imageProps.rounded
|
|
99
|
+
});
|
|
100
|
+
const overlayClassList = (0, _classnames.default)({
|
|
101
|
+
[widthClassList]: true,
|
|
102
|
+
[heightClassList]: true,
|
|
103
|
+
[opacity]: true,
|
|
104
|
+
[overlayColour]: true
|
|
105
|
+
}, 'absolute z-10 transition-opacity duration-700');
|
|
106
|
+
const overlayTextWrapperClassList = (0, _classnames.default)({
|
|
107
|
+
[widthClassList]: true,
|
|
108
|
+
[heightClassList]: true,
|
|
109
|
+
[opacity]: true
|
|
110
|
+
}, 'flex absolute z-20 transition-opacity duration-700');
|
|
111
|
+
const overlayTextClassList = (0, _classnames.default)({
|
|
112
|
+
[overlayTextColour]: true
|
|
113
|
+
}, 'm-auto text-center');
|
|
91
114
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
92
115
|
className: classList
|
|
93
|
-
}, (imageProps === null || imageProps === void 0 ? void 0 : imageProps.
|
|
94
|
-
className:
|
|
95
|
-
}),
|
|
96
|
-
className:
|
|
116
|
+
}, (imageProps === null || imageProps === void 0 ? void 0 : imageProps.overlayText) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
117
|
+
className: overlayClassList
|
|
118
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: overlayTextWrapperClassList,
|
|
97
120
|
onMouseEnter: () => setIsHovering(true),
|
|
98
121
|
onMouseLeave: () => setIsHovering(false)
|
|
99
122
|
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
100
|
-
className:
|
|
101
|
-
}, imageProps
|
|
123
|
+
className: overlayTextClassList
|
|
124
|
+
}, imageProps.overlayText))), /*#__PURE__*/_react.default.createElement("img", _extends({}, (imageProps === null || imageProps === void 0 ? void 0 : imageProps.id) && {
|
|
102
125
|
id: imageProps === null || imageProps === void 0 ? void 0 : imageProps.id
|
|
103
126
|
}, {
|
|
104
|
-
className:
|
|
127
|
+
className: imageClassList,
|
|
105
128
|
src: imageProps === null || imageProps === void 0 ? void 0 : imageProps.image
|
|
106
129
|
}, (imageProps === null || imageProps === void 0 ? void 0 : imageProps.altText) && {
|
|
107
130
|
alt: imageProps === null || imageProps === void 0 ? void 0 : imageProps.altText
|
|
108
131
|
}, (imageProps === null || imageProps === void 0 ? void 0 : imageProps.title) && {
|
|
109
132
|
title: imageProps === null || imageProps === void 0 ? void 0 : imageProps.title
|
|
110
|
-
}))
|
|
111
|
-
className: "".concat(widthClassList, " text-center ").concat(isHovering ? 'block' : 'hidden')
|
|
112
|
-
}));
|
|
133
|
+
})));
|
|
113
134
|
};
|
|
114
135
|
|
|
115
136
|
Image.propTypes = {
|