@lumx/react 3.7.6-alpha.14 → 3.7.6-alpha.15

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 CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^3.7.6-alpha.14",
11
- "@lumx/icons": "^3.7.6-alpha.14",
10
+ "@lumx/core": "^3.7.6-alpha.15",
11
+ "@lumx/icons": "^3.7.6-alpha.15",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.3.2",
@@ -112,5 +112,5 @@
112
112
  "build:storybook": "storybook build"
113
113
  },
114
114
  "sideEffects": false,
115
- "version": "3.7.6-alpha.14"
115
+ "version": "3.7.6-alpha.15"
116
116
  }
@@ -24,7 +24,6 @@ import { withNestedProps } from '@lumx/react/stories/decorators/withNestedProps'
24
24
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
25
25
  import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
26
26
 
27
-
28
27
  const aligns = [Alignment.center, Alignment.left, Alignment.right];
29
28
  const variants = [ThumbnailVariant.squared, ThumbnailVariant.rounded];
30
29
 
@@ -430,14 +429,16 @@ export const LoadingPlaceholderImage = () => {
430
429
  <FlexBox orientation="horizontal">
431
430
  <Thumbnail alt="Small image" imgRef={imgRef} image="https://picsum.photos/id/15/128/85" />
432
431
  {isShown && (
433
- <Thumbnail
434
- image={`https://picsum.photos/id/15/2500/1667?cacheBust${uniqueId()}`}
435
- alt="Large image"
436
- // Loading placeholder image
437
- loadingPlaceholderImageRef={imgRef}
438
- // Reserve space
439
- imgProps={{ width: 2500, height: 1667 }}
440
- />
432
+ <div style={{ maxHeight: 400 }}>
433
+ <Thumbnail
434
+ image={`https://picsum.photos/id/15/2500/1667?cacheBust${uniqueId()}`}
435
+ alt="Large image"
436
+ // Loading placeholder image
437
+ loadingPlaceholderImageRef={imgRef}
438
+ // Reserve space
439
+ imgProps={{ width: 2500, height: 1667 }}
440
+ />
441
+ </div>
441
442
  )}
442
443
  </FlexBox>
443
444
  </>
@@ -17,7 +17,7 @@ import { Comp, Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
17
17
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
18
18
 
19
19
  import { mdiImageBroken } from '@lumx/icons';
20
- import { mergeRefs, useMergeRefs } from '@lumx/react/utils/mergeRefs';
20
+ import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
21
21
  import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
22
22
  import { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';
23
23
  import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
@@ -199,21 +199,24 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
199
199
  >
200
200
  <span className={`${CLASSNAME}__background`}>
201
201
  <img
202
+ // Use placeholder image size
202
203
  width={loadingPlaceholderImage?.naturalWidth}
203
204
  height={loadingPlaceholderImage?.naturalHeight}
204
205
  {...imgProps}
205
206
  style={{
207
+ // Reserve space while loading (when possible)
208
+ width: isLoading ? imgProps?.width || loadingPlaceholderImage?.naturalWidth : undefined,
206
209
  ...imgProps?.style,
207
210
  ...imageErrorStyle,
208
211
  ...focusPointStyle,
209
212
  ...loadingStyle,
210
213
  }}
211
- ref={mergeRefs(setImgElement, propImgRef)}
214
+ ref={useMergeRefs(setImgElement, propImgRef)}
212
215
  className={classNames(
213
216
  handleBasicClasses({
214
217
  prefix: `${CLASSNAME}__image`,
215
218
  isLoading,
216
- hasDefinedSize: !isLoading && Boolean(imgProps?.height && imgProps.width),
219
+ hasDefinedSize: Boolean(imgProps?.height && imgProps.width),
217
220
  }),
218
221
  imgProps?.className,
219
222
  )}