@riosst100/pwa-marketplace 2.2.9 → 2.3.1
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/package.json +1 -1
- package/src/componentOverrideMapping.js +1 -0
- package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +1 -1
- package/src/overwrites/peregrine/lib/talons/MagentoRoute/useMagentoRoute.js +1 -1
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.module.css +1 -1
- package/src/overwrites/venia-ui/lib/components/Gallery/item.js +3 -3
- package/src/overwrites/venia-ui/lib/components/Gallery/item.module.css +3 -1
- package/src/overwrites/venia-ui/lib/components/Image/image.js +168 -0
- package/src/overwrites/venia-ui/lib/components/Image/image.module.css +62 -0
- package/src/overwrites/venia-ui/lib/components/Image/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/Image/placeholderImage.js +85 -0
- package/src/overwrites/venia-ui/lib/components/Image/resourceImage.js +91 -0
- package/src/overwrites/venia-ui/lib/components/Image/simpleImage.js +60 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.js +1 -0
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.module.css +6 -2
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.js +5 -4
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.module.css +2 -1
- package/src/talons/Header/useWebsiteSwitcher.js +1 -1
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +1 -1
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ module.exports = componentOverrideMapping = {
|
|
|
39
39
|
[`@magento/venia-ui/lib/components/ProductSort/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/ProductSort/index.js',
|
|
40
40
|
[`@magento/venia-ui/lib/components/ProductFullDetail/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/ProductFullDetail/index.js',
|
|
41
41
|
[`@magento/venia-ui/lib/components/ProductImageCarousel/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/ProductImageCarousel/index.js',
|
|
42
|
+
[`@magento/venia-ui/lib/components/Image/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/Image/index.js',
|
|
42
43
|
[`@magento/venia-ui/lib/components/QuantityStepper/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/QuantityStepper/index.js',
|
|
43
44
|
// [`@magento/venia-ui/lib/components/RichContent/index.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/RichContent/index.js',
|
|
44
45
|
[`@magento/venia-ui/lib/components/RadioGroup/radio.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/RadioGroup/radio.js',
|
|
@@ -156,7 +156,7 @@ export const useStoreSwitcher = (props = {}) => {
|
|
|
156
156
|
newPath = routeData.route.relative_url;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return newPath
|
|
159
|
+
return newPath?.startsWith('/') ? newPath.substr(1) : newPath;
|
|
160
160
|
},
|
|
161
161
|
[pathname, fetchRouteData, internalRoutes]
|
|
162
162
|
);
|
|
@@ -102,7 +102,7 @@ const GalleryItem = props => {
|
|
|
102
102
|
data-cy="GalleryItem-root"
|
|
103
103
|
className={cn(
|
|
104
104
|
classes.root,
|
|
105
|
-
'border border-gray-100 rounded-lg hover_shadow-type-1 bg-white min-h-[
|
|
105
|
+
'border border-gray-100 rounded-lg hover_shadow-type-1 bg-white min-h-[300px]'
|
|
106
106
|
)}
|
|
107
107
|
ref={itemRef}
|
|
108
108
|
>
|
|
@@ -129,7 +129,7 @@ const GalleryItem = props => {
|
|
|
129
129
|
{ratingAverage}
|
|
130
130
|
</Link>
|
|
131
131
|
</div>
|
|
132
|
-
<div className={cn('item-info px-[15px]
|
|
132
|
+
<div className={cn('item-info px-[15px] pb-[20px]')}>
|
|
133
133
|
<Link
|
|
134
134
|
onClick={handleLinkClick}
|
|
135
135
|
to={productLink}
|
|
@@ -139,7 +139,7 @@ const GalleryItem = props => {
|
|
|
139
139
|
<span>{name}</span>
|
|
140
140
|
</Link>
|
|
141
141
|
<div data-cy="GalleryItem-price" className={cn(classes.price, 'mb-2.5 pt-2.5')}>
|
|
142
|
-
<p className='font-medium text-
|
|
142
|
+
<p className='font-medium !text-[#f76b1c] text-[1.1rem] !mb-1 !leading-[14px]'>
|
|
143
143
|
<Price
|
|
144
144
|
value={priceSource.value}
|
|
145
145
|
currencyCode={priceSource.currency}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
composes: content-start from global;
|
|
3
3
|
composes: grid from global;
|
|
4
4
|
/* composes: gap-y-2xs from global; */
|
|
5
|
-
composes: max-w-[315px] from global;
|
|
5
|
+
/* composes: max-w-[315px] from global; */
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.images {
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
.imageContainer {
|
|
15
15
|
grid-area: main;
|
|
16
16
|
composes: max-h-[215px] from global;
|
|
17
|
+
/* composes: bg-[#f7f7f8] from global; */
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
.image {
|
|
21
|
+
composes: p-[16px] from global;
|
|
20
22
|
composes: block from global;
|
|
21
23
|
composes: h-full from global;
|
|
22
24
|
composes: object-contain from global;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes, {
|
|
3
|
+
bool,
|
|
4
|
+
func,
|
|
5
|
+
instanceOf,
|
|
6
|
+
number,
|
|
7
|
+
oneOfType,
|
|
8
|
+
shape,
|
|
9
|
+
string
|
|
10
|
+
} from 'prop-types';
|
|
11
|
+
import { useImage } from '@magento/peregrine/lib/talons/Image/useImage';
|
|
12
|
+
import { DEFAULT_WIDTH_TO_HEIGHT_RATIO } from '@magento/peregrine/lib/util/imageUtils';
|
|
13
|
+
|
|
14
|
+
import PlaceholderImage from './placeholderImage';
|
|
15
|
+
import ResourceImage from './resourceImage';
|
|
16
|
+
import SimpleImage from './simpleImage';
|
|
17
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
18
|
+
|
|
19
|
+
import defaultClasses from './image.module.css';
|
|
20
|
+
/**
|
|
21
|
+
* The Image component renders a placeholder until the image is loaded.
|
|
22
|
+
*
|
|
23
|
+
* @param {object} props.classes any classes to apply to this component
|
|
24
|
+
* @param {bool} props.displayPlaceholder whether or not to display a placeholder while the image loads or if it errors on load.
|
|
25
|
+
* @param {number} props.height the intrinsic height of the image & the height to request for the fallback image for browsers that don't support srcset / sizes.
|
|
26
|
+
* @param {function} props.onError callback for error loading image
|
|
27
|
+
* @param {function} props.onLoad callback for when image loads successfully
|
|
28
|
+
* @param {string} props.placeholder the placeholder source to display while the image loads or if it errors on load
|
|
29
|
+
* @param {string} props.resource the Magento path to the image ex: /v/d/vd12-rn_main_2.jpg
|
|
30
|
+
* @param {string} props.src the source of the image, ready to use in an img element
|
|
31
|
+
* @param {string} props.type the Magento image type ("image-category" / "image-product"). Used to build the resource URL.
|
|
32
|
+
* @param {number} props.width the intrinsic width of the image & the width to request for the fallback image for browsers that don't support srcset / sizes.
|
|
33
|
+
* @param {number} props.ratio is the image width to height ratio. Defaults to `DEFAULT_WIDTH_TO_HEIGHT_RATIO` from `util/images.js`.
|
|
34
|
+
* @param {Map} props.widths a map of breakpoints to possible widths used to create the img's sizes attribute.
|
|
35
|
+
*/
|
|
36
|
+
const Image = props => {
|
|
37
|
+
const {
|
|
38
|
+
alt,
|
|
39
|
+
classes: propsClasses,
|
|
40
|
+
displayPlaceholder,
|
|
41
|
+
height,
|
|
42
|
+
onError,
|
|
43
|
+
onLoad,
|
|
44
|
+
placeholder,
|
|
45
|
+
resource,
|
|
46
|
+
src,
|
|
47
|
+
type,
|
|
48
|
+
width,
|
|
49
|
+
widths,
|
|
50
|
+
ratio,
|
|
51
|
+
...rest
|
|
52
|
+
} = props;
|
|
53
|
+
|
|
54
|
+
const talonProps = useImage({
|
|
55
|
+
onError,
|
|
56
|
+
onLoad,
|
|
57
|
+
width,
|
|
58
|
+
widths,
|
|
59
|
+
height,
|
|
60
|
+
ratio
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
handleError,
|
|
65
|
+
handleImageLoad,
|
|
66
|
+
hasError,
|
|
67
|
+
isLoaded,
|
|
68
|
+
resourceWidth: talonResourceWidth,
|
|
69
|
+
resourceHeight: talonResourceHeight
|
|
70
|
+
} = talonProps;
|
|
71
|
+
|
|
72
|
+
const classes = useStyle(defaultClasses, propsClasses);
|
|
73
|
+
const containerClass = `${classes.root} ${classes.container}`;
|
|
74
|
+
const isLoadedClass = isLoaded ? classes.loaded : classes.notLoaded;
|
|
75
|
+
const imageClass = `${classes.image} ${isLoadedClass}`;
|
|
76
|
+
|
|
77
|
+
// If we have a src, use it directly. If not, assume this is a resource image.
|
|
78
|
+
const actualImage = src ? (
|
|
79
|
+
<SimpleImage
|
|
80
|
+
alt={alt}
|
|
81
|
+
className={imageClass}
|
|
82
|
+
handleError={handleError}
|
|
83
|
+
handleLoad={handleImageLoad}
|
|
84
|
+
height={talonResourceHeight}
|
|
85
|
+
src={src}
|
|
86
|
+
width={width}
|
|
87
|
+
{...rest}
|
|
88
|
+
/>
|
|
89
|
+
) : (
|
|
90
|
+
<ResourceImage
|
|
91
|
+
alt={alt}
|
|
92
|
+
className={imageClass}
|
|
93
|
+
handleError={handleError}
|
|
94
|
+
handleLoad={handleImageLoad}
|
|
95
|
+
height={talonResourceHeight}
|
|
96
|
+
resource={resource}
|
|
97
|
+
type={type}
|
|
98
|
+
width={talonResourceWidth}
|
|
99
|
+
widths={widths}
|
|
100
|
+
ratio={ratio}
|
|
101
|
+
{...rest}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div className={containerClass}>
|
|
107
|
+
<PlaceholderImage
|
|
108
|
+
alt={alt}
|
|
109
|
+
classes={classes}
|
|
110
|
+
displayPlaceholder={displayPlaceholder}
|
|
111
|
+
height={height}
|
|
112
|
+
imageHasError={hasError}
|
|
113
|
+
imageIsLoaded={isLoaded}
|
|
114
|
+
src={placeholder}
|
|
115
|
+
width={talonResourceWidth}
|
|
116
|
+
{...rest}
|
|
117
|
+
/>
|
|
118
|
+
{actualImage}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const conditionallyRequiredString = (props, propName, componentName) => {
|
|
124
|
+
// This component needs one of src or resource to be provided.
|
|
125
|
+
if (!props.src && !props.resource) {
|
|
126
|
+
return new Error(
|
|
127
|
+
`Missing both 'src' and 'resource' props in ${componentName}. ${componentName} needs at least one of these to be provided.`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return PropTypes.checkPropTypes(
|
|
132
|
+
{
|
|
133
|
+
resource: string,
|
|
134
|
+
src: string
|
|
135
|
+
},
|
|
136
|
+
props,
|
|
137
|
+
propName,
|
|
138
|
+
componentName
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
Image.propTypes = {
|
|
143
|
+
alt: string.isRequired,
|
|
144
|
+
classes: shape({
|
|
145
|
+
container: string,
|
|
146
|
+
loaded: string,
|
|
147
|
+
notLoaded: string,
|
|
148
|
+
root: string
|
|
149
|
+
}),
|
|
150
|
+
displayPlaceholder: bool,
|
|
151
|
+
height: oneOfType([number, string]),
|
|
152
|
+
onError: func,
|
|
153
|
+
onLoad: func,
|
|
154
|
+
placeholder: string,
|
|
155
|
+
resource: conditionallyRequiredString,
|
|
156
|
+
src: conditionallyRequiredString,
|
|
157
|
+
type: string,
|
|
158
|
+
width: oneOfType([number, string]),
|
|
159
|
+
widths: instanceOf(Map),
|
|
160
|
+
ratio: number
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
Image.defaultProps = {
|
|
164
|
+
displayPlaceholder: true,
|
|
165
|
+
ratio: DEFAULT_WIDTH_TO_HEIGHT_RATIO
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export default Image;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
/*
|
|
3
|
+
* For customization, we provide an empty root.
|
|
4
|
+
* These styles will be applied to the image container.
|
|
5
|
+
*/
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.container {
|
|
9
|
+
composes: relative from global;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.image {
|
|
13
|
+
/*
|
|
14
|
+
* For customization, we provide an empty image class.
|
|
15
|
+
* These styles will be applied directly to the image itself.
|
|
16
|
+
*/
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.loaded {
|
|
20
|
+
composes: absolute from global;
|
|
21
|
+
composes: left-0 from global;
|
|
22
|
+
composes: top-0 from global;
|
|
23
|
+
|
|
24
|
+
/* TODO @TW: review (B6) */
|
|
25
|
+
/* composes: visible from global; */
|
|
26
|
+
visibility: visible;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.notLoaded {
|
|
30
|
+
composes: loaded;
|
|
31
|
+
|
|
32
|
+
/* TODO @TW: review (B6) */
|
|
33
|
+
/* composes: invisible from global; */
|
|
34
|
+
visibility: hidden;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.placeholder {
|
|
38
|
+
composes: bg-transparent from global;
|
|
39
|
+
composes: left-0 from global;
|
|
40
|
+
composes: relative from global;
|
|
41
|
+
composes: top-0 from global;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.placeholder_layoutOnly {
|
|
45
|
+
composes: placeholder;
|
|
46
|
+
|
|
47
|
+
composes: bg-transparent from global;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.placeholder_product {
|
|
51
|
+
composes: bg-transparent from global;
|
|
52
|
+
composes: left-0 from global;
|
|
53
|
+
composes: relative from global;
|
|
54
|
+
composes: top-0 from global;
|
|
55
|
+
composes: w-[70%] from global;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.placeholder_layoutOnly_product {
|
|
59
|
+
composes: placeholder;
|
|
60
|
+
|
|
61
|
+
composes: bg-transparent from global;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './image';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { bool, number, oneOfType, shape, string } from 'prop-types';
|
|
3
|
+
import { transparentPlaceholder } from '@magento/peregrine/lib/util/images';
|
|
4
|
+
import { usePlaceholderImage } from '@magento/peregrine/lib/talons/Image/usePlaceholderImage';
|
|
5
|
+
|
|
6
|
+
import SimpleImage from './simpleImage';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A placeholder to use until the actual image is loaded.
|
|
10
|
+
* This is used both for user experience and layout purposes.
|
|
11
|
+
* Callers can disable the "user experience" part by setting displayPlaceholder to false.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} props.alt the alt attribute to apply to the image.
|
|
14
|
+
* @param {object} props.classes the pre-merged classes to apply to this component.
|
|
15
|
+
* @param {bool} props.displayPlaceholder whether or not to display a visual placeholder.
|
|
16
|
+
* @param {number} props.height the intrinsic height of the image.
|
|
17
|
+
* @param {string} props.imageHasError there was an error loading the actual image.
|
|
18
|
+
* @param {string} props.imageIsLoaded the actual image is loaded.
|
|
19
|
+
* @param {string} props.src the actual src of the placeholder image.
|
|
20
|
+
* @param {number} props.width the intrinsic width of the image.
|
|
21
|
+
*/
|
|
22
|
+
const PlaceholderImage = props => {
|
|
23
|
+
const {
|
|
24
|
+
alt,
|
|
25
|
+
classes,
|
|
26
|
+
displayPlaceholder,
|
|
27
|
+
height,
|
|
28
|
+
imageHasError,
|
|
29
|
+
imageIsLoaded,
|
|
30
|
+
src,
|
|
31
|
+
width,
|
|
32
|
+
...rest
|
|
33
|
+
} = props;
|
|
34
|
+
|
|
35
|
+
const talonProps = usePlaceholderImage({
|
|
36
|
+
displayPlaceholder,
|
|
37
|
+
imageHasError,
|
|
38
|
+
imageIsLoaded
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const { shouldRenderPlaceholder } = talonProps;
|
|
42
|
+
|
|
43
|
+
const placeholderClass = shouldRenderPlaceholder
|
|
44
|
+
? classes.placeholder
|
|
45
|
+
: classes.placeholder_layoutOnly;
|
|
46
|
+
|
|
47
|
+
const productPlaceholderClass = alt == "image-product" ? "!w-[70%]" : "";
|
|
48
|
+
|
|
49
|
+
const placeholderFullClass = `${classes.image} ${placeholderClass} ${productPlaceholderClass}`;
|
|
50
|
+
|
|
51
|
+
// Note: Attributes that are allowed to be overridden must appear before the spread of `rest`.
|
|
52
|
+
return (
|
|
53
|
+
<SimpleImage
|
|
54
|
+
loading="eager"
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
height={height}
|
|
57
|
+
width={width}
|
|
58
|
+
{...rest}
|
|
59
|
+
alt={alt}
|
|
60
|
+
className={placeholderFullClass}
|
|
61
|
+
src={src}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
PlaceholderImage.propTypes = {
|
|
67
|
+
alt: string.isRequired,
|
|
68
|
+
classes: shape({
|
|
69
|
+
image: string,
|
|
70
|
+
placeholder: string,
|
|
71
|
+
placeholder_layoutOnly: string
|
|
72
|
+
}).isRequired,
|
|
73
|
+
displayPlaceholder: bool,
|
|
74
|
+
height: oneOfType([number, string]),
|
|
75
|
+
imageHasError: bool,
|
|
76
|
+
imageIsLoaded: bool,
|
|
77
|
+
src: string,
|
|
78
|
+
width: oneOfType([number, string])
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
PlaceholderImage.defaultProps = {
|
|
82
|
+
src: transparentPlaceholder
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default PlaceholderImage;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { func, instanceOf, number, oneOfType, string } from 'prop-types';
|
|
3
|
+
import { useResourceImage } from '@magento/peregrine/lib/talons/Image/useResourceImage';
|
|
4
|
+
import {
|
|
5
|
+
generateSrcset,
|
|
6
|
+
generateUrl
|
|
7
|
+
} from '@magento/peregrine/lib/util/imageUtils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders a Magento resource image.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} props.alt the alt attribute to apply to the image.
|
|
13
|
+
* @param {string} props.className the class to apply to this image.
|
|
14
|
+
* @param {Func} props.handleError the function to call if the image fails to load.
|
|
15
|
+
* @param {Func} props.handleLoad the function to call if the image successfully loads.
|
|
16
|
+
* @param {number} props.height the height to request for the fallback image for browsers that don't support srcset / sizes.
|
|
17
|
+
* @param {string} props.resource the Magento path to the image ex: /v/d/vd12-rn_main_2.jpg
|
|
18
|
+
* @param {string} props.type the Magento image type ("image-category" / "image-product"). Used to build the resource URL.
|
|
19
|
+
* @param {number} props.width the intrinsic width of the image & the width to request for the fallback image for browsers that don't support srcset / sizes.
|
|
20
|
+
* @param {Map} props.widths a map of breakpoints to possible widths used to create the img's sizes attribute.
|
|
21
|
+
* @param {number} props.ratio is the image width to height ratio. Defaults to 4/5.
|
|
22
|
+
*/
|
|
23
|
+
const ResourceImage = props => {
|
|
24
|
+
const {
|
|
25
|
+
alt,
|
|
26
|
+
className,
|
|
27
|
+
handleError,
|
|
28
|
+
handleLoad,
|
|
29
|
+
height,
|
|
30
|
+
resource,
|
|
31
|
+
type,
|
|
32
|
+
width,
|
|
33
|
+
widths,
|
|
34
|
+
ratio,
|
|
35
|
+
...rest
|
|
36
|
+
} = props;
|
|
37
|
+
|
|
38
|
+
const talonProps = useResourceImage({
|
|
39
|
+
generateSrcset,
|
|
40
|
+
generateUrl,
|
|
41
|
+
height,
|
|
42
|
+
resource,
|
|
43
|
+
type,
|
|
44
|
+
width,
|
|
45
|
+
widths,
|
|
46
|
+
ratio
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const { sizes, src, srcSet } = talonProps;
|
|
50
|
+
const dimensionAttributes = {};
|
|
51
|
+
if (typeof height !== 'undefined') {
|
|
52
|
+
dimensionAttributes['--height'] = height + 'px';
|
|
53
|
+
}
|
|
54
|
+
if (typeof width !== 'undefined') {
|
|
55
|
+
dimensionAttributes['--width'] = width + 'px';
|
|
56
|
+
}
|
|
57
|
+
// Note: Attributes that are allowed to be overridden must appear before the spread of `rest`.
|
|
58
|
+
return (
|
|
59
|
+
<img
|
|
60
|
+
loading="lazy"
|
|
61
|
+
style={dimensionAttributes}
|
|
62
|
+
{...rest}
|
|
63
|
+
alt={alt}
|
|
64
|
+
className={className}
|
|
65
|
+
onError={handleError}
|
|
66
|
+
onLoad={handleLoad}
|
|
67
|
+
sizes={sizes}
|
|
68
|
+
src={src}
|
|
69
|
+
srcSet={srcSet}
|
|
70
|
+
width={width}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
ResourceImage.propTypes = {
|
|
76
|
+
alt: string.isRequired,
|
|
77
|
+
className: string,
|
|
78
|
+
handleError: func,
|
|
79
|
+
handleLoad: func,
|
|
80
|
+
resource: string.isRequired,
|
|
81
|
+
height: oneOfType([number, string]),
|
|
82
|
+
type: string,
|
|
83
|
+
width: oneOfType([number, string]),
|
|
84
|
+
widths: instanceOf(Map)
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
ResourceImage.defaultProps = {
|
|
88
|
+
type: 'image-product'
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default ResourceImage;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { func, number, oneOfType, string } from 'prop-types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Renders an img element directly using the supplied src.
|
|
6
|
+
*
|
|
7
|
+
* @param {String} props.alt - The alt attribute for the img element.
|
|
8
|
+
* @param {String} props.className - The class name to apply to the img element.
|
|
9
|
+
* @param {Func} props.handleError - The function to call if the image fails to load.
|
|
10
|
+
* @param {Func} props.handleLoad - The function to call if the image successfully loads.
|
|
11
|
+
* @param {Number} props.height - The height of the img element.
|
|
12
|
+
* @param {String} props.src - The src attribute for the img element.
|
|
13
|
+
* @param {Number} props.width - The width of the img element.
|
|
14
|
+
*/
|
|
15
|
+
const SimpleImage = props => {
|
|
16
|
+
const {
|
|
17
|
+
alt,
|
|
18
|
+
className,
|
|
19
|
+
handleError,
|
|
20
|
+
handleLoad,
|
|
21
|
+
height,
|
|
22
|
+
src,
|
|
23
|
+
width,
|
|
24
|
+
...rest
|
|
25
|
+
} = props;
|
|
26
|
+
const dimensionAttributes = {};
|
|
27
|
+
if (typeof height !== 'undefined') {
|
|
28
|
+
dimensionAttributes['--height'] = height + 'px';
|
|
29
|
+
}
|
|
30
|
+
if (typeof width !== 'undefined') {
|
|
31
|
+
dimensionAttributes['--width'] = width + 'px';
|
|
32
|
+
}
|
|
33
|
+
// Note: Attributes that are allowed to be overridden must appear before the spread of `rest`.
|
|
34
|
+
return (
|
|
35
|
+
<img
|
|
36
|
+
loading="lazy"
|
|
37
|
+
style={dimensionAttributes}
|
|
38
|
+
{...rest}
|
|
39
|
+
alt={alt}
|
|
40
|
+
className={className}
|
|
41
|
+
height={height}
|
|
42
|
+
onError={handleError}
|
|
43
|
+
onLoad={handleLoad}
|
|
44
|
+
src={src}
|
|
45
|
+
width={width}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
SimpleImage.propTypes = {
|
|
51
|
+
alt: string.isRequired,
|
|
52
|
+
className: string,
|
|
53
|
+
handleError: func,
|
|
54
|
+
handleLoad: func,
|
|
55
|
+
height: oneOfType([number, string]),
|
|
56
|
+
src: string.isRequired,
|
|
57
|
+
width: oneOfType([number, string])
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default SimpleImage;
|
|
@@ -23,21 +23,25 @@
|
|
|
23
23
|
|
|
24
24
|
.imageContainer {
|
|
25
25
|
composes: w-full from global;
|
|
26
|
+
grid-area: 1 / 1 / 2 / 4;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
.currentImage {
|
|
29
30
|
composes: block from global;
|
|
30
31
|
composes: h-full from global;
|
|
31
32
|
composes: object-center from global;
|
|
32
|
-
composes: object-
|
|
33
|
+
composes: object-contain from global;
|
|
33
34
|
composes: w-full from global;
|
|
34
35
|
|
|
35
36
|
composes: lg_object-top from global;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
.carouselContainer {
|
|
40
|
+
composes: flex items-center justify-center p-4 bg-[#f7f7f8] rounded-md max-h-[660px] from global;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
.currentImage_placeholder {
|
|
39
44
|
composes: currentImage;
|
|
40
|
-
|
|
41
45
|
composes: bg-subtle from global;
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -30,7 +30,8 @@ const Thumbnail = props => {
|
|
|
30
30
|
isActive,
|
|
31
31
|
item: { file, label },
|
|
32
32
|
onClickHandler,
|
|
33
|
-
itemIndex
|
|
33
|
+
itemIndex,
|
|
34
|
+
alt = ''
|
|
34
35
|
} = props;
|
|
35
36
|
|
|
36
37
|
const talonProps = useThumbnail({
|
|
@@ -50,7 +51,7 @@ const Thumbnail = props => {
|
|
|
50
51
|
|
|
51
52
|
return file ? (
|
|
52
53
|
<Image
|
|
53
|
-
alt={
|
|
54
|
+
alt={alt}
|
|
54
55
|
classes={{ image: classes.image }}
|
|
55
56
|
height={DEFAULT_THUMBNAIL_HEIGHT}
|
|
56
57
|
resource={file}
|
|
@@ -58,12 +59,12 @@ const Thumbnail = props => {
|
|
|
58
59
|
/>
|
|
59
60
|
) : (
|
|
60
61
|
<Image
|
|
61
|
-
alt={
|
|
62
|
+
alt={alt}
|
|
62
63
|
classes={{ image: classes.image }}
|
|
63
64
|
src={transparentPlaceholder}
|
|
64
65
|
/>
|
|
65
66
|
);
|
|
66
|
-
}, [file, isDesktop,
|
|
67
|
+
}, [file, isDesktop, alt, classes.image]);
|
|
67
68
|
|
|
68
69
|
return (
|
|
69
70
|
<button
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
composes: lg_h-auto from global;
|
|
16
16
|
composes: lg_w-auto from global;
|
|
17
17
|
composes: hidden from global;
|
|
18
|
+
composes: bg-[#e6e9ea] from global;
|
|
18
19
|
box-shadow: 0 0 0 1px #E6E9EA;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
composes: lg_block from global;
|
|
33
34
|
composes: lg_h-full from global;
|
|
34
35
|
composes: lg_object-center from global;
|
|
35
|
-
composes: lg_object-
|
|
36
|
+
composes: lg_object-contain from global;
|
|
36
37
|
composes: rounded-[4px] from global;
|
|
37
38
|
composes: lg_w-full from global;
|
|
38
39
|
}
|
|
@@ -156,7 +156,7 @@ export const useWebsiteSwitcher = (props = {}) => {
|
|
|
156
156
|
newPath = routeData.route.relative_url;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return newPath
|
|
159
|
+
return newPath?.startsWith('/') ? newPath.substr(1) : newPath;
|
|
160
160
|
},
|
|
161
161
|
[pathname, fetchRouteData, internalRoutes]
|
|
162
162
|
);
|
|
@@ -156,7 +156,7 @@ export const useWebsiteSwitcher = (props = {}) => {
|
|
|
156
156
|
newPath = routeData.route.relative_url;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
return newPath
|
|
159
|
+
return newPath?.startsWith('/') ? newPath.substr(1) : newPath;
|
|
160
160
|
},
|
|
161
161
|
[pathname, fetchRouteData, internalRoutes]
|
|
162
162
|
);
|