@lumx/react 3.5.0 → 3.5.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
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^3.5.
|
|
11
|
-
"@lumx/icons": "^3.5.
|
|
10
|
+
"@lumx/core": "^3.5.1",
|
|
11
|
+
"@lumx/icons": "^3.5.1",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"build:storybook": "storybook build"
|
|
118
118
|
},
|
|
119
119
|
"sideEffects": false,
|
|
120
|
-
"version": "3.5.
|
|
120
|
+
"version": "3.5.1"
|
|
121
121
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { mdiAbTesting } from '@lumx/icons';
|
|
3
|
+
import { mdiAbTesting, mdiImageBroken } from '@lumx/icons';
|
|
4
4
|
import { Alignment, AspectRatio, Badge, FlexBox, Icon, Size, Thumbnail, ThumbnailVariant } from '@lumx/react';
|
|
5
5
|
import { CustomLink } from '@lumx/react/stories/utils/CustomLink';
|
|
6
6
|
import { IMAGE_SIZES, imageArgType, IMAGES } from '@lumx/react/stories/controls/image';
|
|
@@ -44,6 +44,10 @@ export const IsLoading = {
|
|
|
44
44
|
args: { ...Simple.args, isLoading: true },
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
export const WithoutSource = {
|
|
48
|
+
args: { image: IMAGES.emptyImage, size: Size.xxl, aspectRatio: AspectRatio.square },
|
|
49
|
+
};
|
|
50
|
+
|
|
47
51
|
/** Thumbnail error fallback and size variants */
|
|
48
52
|
export const ErrorFallback = {
|
|
49
53
|
args: { image: 'foo' },
|
|
@@ -3,8 +3,9 @@ import { useEffect, useState } from 'react';
|
|
|
3
3
|
export type LoadingState = 'isLoading' | 'isLoaded' | 'hasError';
|
|
4
4
|
|
|
5
5
|
function getState(img: HTMLImageElement | null | undefined, event?: Event) {
|
|
6
|
-
// Error event occurred.
|
|
7
|
-
if (event?.type === 'error') {
|
|
6
|
+
// Error event occurred or image has no source.
|
|
7
|
+
if (event?.type === 'error' || (img?.complete && !img.getAttribute('src'))) {
|
|
8
|
+
console.log('HAS ERROR');
|
|
8
9
|
return 'hasError';
|
|
9
10
|
}
|
|
10
11
|
// Image is undefined or incomplete.
|
|
@@ -15,13 +15,22 @@ const portrait3 = '/demo-assets/portrait3.jpg';
|
|
|
15
15
|
const square1 = '/demo-assets/square1.jpg';
|
|
16
16
|
const square2 = '/demo-assets/square2.jpg';
|
|
17
17
|
const defaultSvg = '/demo-assets/defaultSvg.svg';
|
|
18
|
+
const emptyImage = '';
|
|
18
19
|
|
|
19
20
|
export const AVATAR_IMAGES = { avatar1, avatar2, avatar3, avatar4 };
|
|
20
21
|
export const SQUARE_IMAGES = { square1, square2 };
|
|
21
22
|
export const SVG_IMAGES = { defaultSvg };
|
|
23
|
+
export const EMPTY_IMAGES = { emptyImage };
|
|
22
24
|
export const LANDSCAPE_IMAGES = { landscape1, landscape1s200, landscape2, landscape3 };
|
|
23
25
|
export const PORTRAIT_IMAGES = { portrait1, portrait1s200, portrait2, portrait3 };
|
|
24
|
-
export const IMAGES = {
|
|
26
|
+
export const IMAGES = {
|
|
27
|
+
...LANDSCAPE_IMAGES,
|
|
28
|
+
...PORTRAIT_IMAGES,
|
|
29
|
+
...SQUARE_IMAGES,
|
|
30
|
+
...AVATAR_IMAGES,
|
|
31
|
+
...SVG_IMAGES,
|
|
32
|
+
...EMPTY_IMAGES,
|
|
33
|
+
};
|
|
25
34
|
|
|
26
35
|
export const avatarImageArgType = getSelectArgType(AVATAR_IMAGES);
|
|
27
36
|
export const squareImageArgType = getSelectArgType(SQUARE_IMAGES);
|
|
@@ -56,10 +65,14 @@ export const PORTRAIT_IMAGE_SIZES: Record<keyof typeof PORTRAIT_IMAGES, Size> =
|
|
|
56
65
|
export const SVG_IMAGE_SIZES: Record<keyof typeof SVG_IMAGES, Size> = {
|
|
57
66
|
defaultSvg: { width: 0, height: 0 },
|
|
58
67
|
};
|
|
68
|
+
export const EMPTY_IMAGES_SIZES: Record<keyof typeof EMPTY_IMAGES, Size> = {
|
|
69
|
+
emptyImage: { width: 0, height: 0 },
|
|
70
|
+
};
|
|
59
71
|
export const IMAGE_SIZES: Record<keyof typeof IMAGES, Size> = {
|
|
60
72
|
...LANDSCAPE_IMAGE_SIZES,
|
|
61
73
|
...PORTRAIT_IMAGE_SIZES,
|
|
62
74
|
...SQUARE_IMAGE_SIZES,
|
|
63
75
|
...AVATAR_IMAGE_SIZES,
|
|
64
76
|
...SVG_IMAGE_SIZES,
|
|
77
|
+
...EMPTY_IMAGES_SIZES,
|
|
65
78
|
};
|