@openedx/paragon 23.16.1 → 23.18.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/Card/CardImageCap.js +22 -15
- package/dist/Card/CardImageCap.js.map +1 -1
- package/dist/core.css +8 -0
- package/dist/core.css.map +1 -1
- package/dist/core.min.css +1 -1
- package/package.json +1 -1
- package/src/Card/CardImageCap.jsx +45 -28
- package/styles/scss/core/_utilities.scss +24 -0
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ const CardImageCap = React.forwardRef(({
|
|
|
22
22
|
logoSkeletonWidth,
|
|
23
23
|
className,
|
|
24
24
|
imageLoadingType,
|
|
25
|
+
skeletonDuringImageLoad,
|
|
25
26
|
}, ref) => {
|
|
26
27
|
const { orientation, isLoading } = useContext(CardContext);
|
|
27
28
|
const [showImageCap, setShowImageCap] = useState(false);
|
|
@@ -29,24 +30,30 @@ const CardImageCap = React.forwardRef(({
|
|
|
29
30
|
|
|
30
31
|
const wrapperClassName = `pgn__card-wrapper-image-cap ${orientation}`;
|
|
31
32
|
|
|
33
|
+
const loadingSkeleton = () => (
|
|
34
|
+
<Skeleton
|
|
35
|
+
containerClassName="pgn__card-image-cap-loader"
|
|
36
|
+
height={orientation === 'horizontal' ? '100%' : skeletonHeight}
|
|
37
|
+
width={skeletonWidth}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const loadingLogoSkeleton = () => (
|
|
42
|
+
<Skeleton
|
|
43
|
+
containerClassName="pgn__card-logo-cap"
|
|
44
|
+
height={logoSkeletonHeight}
|
|
45
|
+
width={logoSkeletonWidth}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
|
|
32
49
|
if (isLoading) {
|
|
33
50
|
return (
|
|
34
51
|
<div
|
|
35
52
|
className={classNames(wrapperClassName, className)}
|
|
36
53
|
data-testid="image-loader-wrapper"
|
|
37
54
|
>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
height={orientation === 'horizontal' ? '100%' : skeletonHeight}
|
|
41
|
-
width={skeletonWidth}
|
|
42
|
-
/>
|
|
43
|
-
{logoSkeleton && (
|
|
44
|
-
<Skeleton
|
|
45
|
-
containerClassName="pgn__card-logo-cap"
|
|
46
|
-
height={logoSkeletonHeight}
|
|
47
|
-
width={logoSkeletonWidth}
|
|
48
|
-
/>
|
|
49
|
-
)}
|
|
55
|
+
{loadingSkeleton()}
|
|
56
|
+
{logoSkeleton && loadingLogoSkeleton()}
|
|
50
57
|
</div>
|
|
51
58
|
);
|
|
52
59
|
}
|
|
@@ -70,24 +77,30 @@ const CardImageCap = React.forwardRef(({
|
|
|
70
77
|
return (
|
|
71
78
|
<div className={classNames(className, wrapperClassName)} ref={ref}>
|
|
72
79
|
{!!src && (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
<>
|
|
81
|
+
{skeletonDuringImageLoad && !showImageCap && loadingSkeleton()}
|
|
82
|
+
<img
|
|
83
|
+
className={classNames('pgn__card-image-cap', { show: showImageCap })}
|
|
84
|
+
src={src}
|
|
85
|
+
onError={(event) => handleSrcFallback(event, fallbackSrc, 'imageCap')}
|
|
86
|
+
onLoad={() => setShowImageCap(true)}
|
|
87
|
+
alt={srcAlt}
|
|
88
|
+
loading={imageLoadingType}
|
|
89
|
+
/>
|
|
90
|
+
</>
|
|
81
91
|
)}
|
|
82
92
|
{!!logoSrc && (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
<>
|
|
94
|
+
{skeletonDuringImageLoad && !showLogoCap && loadingLogoSkeleton()}
|
|
95
|
+
<img
|
|
96
|
+
className={classNames('pgn__card-logo-cap', { show: showLogoCap })}
|
|
97
|
+
src={logoSrc}
|
|
98
|
+
onError={(event) => handleSrcFallback(event, fallbackLogoSrc, 'logoCap')}
|
|
99
|
+
onLoad={() => setShowLogoCap(true)}
|
|
100
|
+
alt={logoAlt}
|
|
101
|
+
loading={imageLoadingType}
|
|
102
|
+
/>
|
|
103
|
+
</>
|
|
91
104
|
)}
|
|
92
105
|
</div>
|
|
93
106
|
);
|
|
@@ -120,6 +133,9 @@ CardImageCap.propTypes = {
|
|
|
120
133
|
logoSkeletonWidth: PropTypes.number,
|
|
121
134
|
/** Specifies loading type for images */
|
|
122
135
|
imageLoadingType: PropTypes.oneOf(['eager', 'lazy']),
|
|
136
|
+
/** Render the loading skeleton when the image is loading in
|
|
137
|
+
* addition to when the whole card is in `isLoading` state */
|
|
138
|
+
skeletonDuringImageLoad: PropTypes.bool,
|
|
123
139
|
};
|
|
124
140
|
|
|
125
141
|
CardImageCap.defaultProps = {
|
|
@@ -136,6 +152,7 @@ CardImageCap.defaultProps = {
|
|
|
136
152
|
skeletonWidth: undefined,
|
|
137
153
|
logoSkeletonWidth: undefined,
|
|
138
154
|
imageLoadingType: 'eager',
|
|
155
|
+
skeletonDuringImageLoad: false,
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
export default CardImageCap;
|
|
@@ -122,3 +122,27 @@ $indexes: map.merge(
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
// Dynamic viewport
|
|
127
|
+
//
|
|
128
|
+
// Following the pattern of `vh-100` and `min-vh-100` from
|
|
129
|
+
// https://github.com/twbs/bootstrap/blob/v4-dev/scss/utilities/_sizing.scss
|
|
130
|
+
//
|
|
131
|
+
// More info on MDN
|
|
132
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/length#dynamic_viewport_units
|
|
133
|
+
|
|
134
|
+
.dvh-100 {
|
|
135
|
+
// fallback for browsers that don't support dynamic viewport units
|
|
136
|
+
height: 100vh !important;
|
|
137
|
+
|
|
138
|
+
// dynamic units for modern browsers
|
|
139
|
+
height: 100dvh !important;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.min-dvh-100 {
|
|
143
|
+
// fallback for browsers that don't support dynamic viewport units
|
|
144
|
+
min-height: 100vh !important;
|
|
145
|
+
|
|
146
|
+
// dynamic units for modern browsers
|
|
147
|
+
min-height: 100dvh !important;
|
|
148
|
+
}
|