@lumx/react 2.1.9-alpha-thumbnail4 → 2.1.9-alpha-thumbnail9
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/esm/_internal/Avatar2.js +2 -1
- package/esm/_internal/Avatar2.js.map +1 -1
- package/esm/_internal/List2.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +18 -8
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/package.json +4 -4
- package/src/components/avatar/Avatar.tsx +1 -0
- package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +30 -30
- package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +1 -1
- package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +30 -30
- package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +1 -1
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +10 -10
- package/src/components/table/__snapshots__/Table.test.tsx.snap +3 -3
- package/src/components/thumbnail/Thumbnail.stories.tsx +14 -38
- package/src/components/thumbnail/Thumbnail.test.tsx +0 -6
- package/src/components/thumbnail/Thumbnail.tsx +18 -6
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +50 -85
- package/src/hooks/useOnResize.ts +0 -6
- package/src/stories/generated/List/Demos.stories.tsx +2 -0
- package/src/components/thumbnail/useClickable.ts +0 -26
- package/src/components/thumbnail/useFocusPoint.ts +0 -162
|
@@ -39,13 +39,13 @@ Array [
|
|
|
39
39
|
/>
|
|
40
40
|
</SlideshowItem>
|
|
41
41
|
<SlideshowItem
|
|
42
|
-
key="/demo-assets/
|
|
42
|
+
key="/demo-assets/landscape1-s200.jpg-1"
|
|
43
43
|
>
|
|
44
44
|
<ImageBlock
|
|
45
45
|
align="left"
|
|
46
46
|
alt="Image 2"
|
|
47
47
|
captionPosition="below"
|
|
48
|
-
image="/demo-assets/
|
|
48
|
+
image="/demo-assets/landscape1-s200.jpg"
|
|
49
49
|
theme="light"
|
|
50
50
|
thumbnailProps={
|
|
51
51
|
Object {
|
|
@@ -55,13 +55,13 @@ Array [
|
|
|
55
55
|
/>
|
|
56
56
|
</SlideshowItem>
|
|
57
57
|
<SlideshowItem
|
|
58
|
-
key="/demo-assets/
|
|
58
|
+
key="/demo-assets/landscape2.jpg-2"
|
|
59
59
|
>
|
|
60
60
|
<ImageBlock
|
|
61
61
|
align="left"
|
|
62
62
|
alt="Image 3"
|
|
63
63
|
captionPosition="below"
|
|
64
|
-
image="/demo-assets/
|
|
64
|
+
image="/demo-assets/landscape2.jpg"
|
|
65
65
|
theme="light"
|
|
66
66
|
thumbnailProps={
|
|
67
67
|
Object {
|
|
@@ -71,13 +71,13 @@ Array [
|
|
|
71
71
|
/>
|
|
72
72
|
</SlideshowItem>
|
|
73
73
|
<SlideshowItem
|
|
74
|
-
key="/demo-assets/
|
|
74
|
+
key="/demo-assets/landscape3.jpg-3"
|
|
75
75
|
>
|
|
76
76
|
<ImageBlock
|
|
77
77
|
align="left"
|
|
78
78
|
alt="Image 4"
|
|
79
79
|
captionPosition="below"
|
|
80
|
-
image="/demo-assets/
|
|
80
|
+
image="/demo-assets/landscape3.jpg"
|
|
81
81
|
theme="light"
|
|
82
82
|
thumbnailProps={
|
|
83
83
|
Object {
|
|
@@ -87,13 +87,13 @@ Array [
|
|
|
87
87
|
/>
|
|
88
88
|
</SlideshowItem>
|
|
89
89
|
<SlideshowItem
|
|
90
|
-
key="/demo-assets/
|
|
90
|
+
key="/demo-assets/portrait1.jpg-4"
|
|
91
91
|
>
|
|
92
92
|
<ImageBlock
|
|
93
93
|
align="left"
|
|
94
94
|
alt="Image 5"
|
|
95
95
|
captionPosition="below"
|
|
96
|
-
image="/demo-assets/
|
|
96
|
+
image="/demo-assets/portrait1.jpg"
|
|
97
97
|
theme="light"
|
|
98
98
|
thumbnailProps={
|
|
99
99
|
Object {
|
|
@@ -103,13 +103,13 @@ Array [
|
|
|
103
103
|
/>
|
|
104
104
|
</SlideshowItem>
|
|
105
105
|
<SlideshowItem
|
|
106
|
-
key="/demo-assets/
|
|
106
|
+
key="/demo-assets/portrait1-s200.jpg-5"
|
|
107
107
|
>
|
|
108
108
|
<ImageBlock
|
|
109
109
|
align="left"
|
|
110
110
|
alt="Image 6"
|
|
111
111
|
captionPosition="below"
|
|
112
|
-
image="/demo-assets/
|
|
112
|
+
image="/demo-assets/portrait1-s200.jpg"
|
|
113
113
|
theme="light"
|
|
114
114
|
thumbnailProps={
|
|
115
115
|
Object {
|
|
@@ -60,7 +60,7 @@ exports[`<Table> Snapshots and structure should render story 'Default' 1`] = `
|
|
|
60
60
|
alt="Frozen yogurt"
|
|
61
61
|
aspectRatio="square"
|
|
62
62
|
className="lumx-spacing-margin-right-big"
|
|
63
|
-
fallback="
|
|
63
|
+
fallback="M19,3A2,2 0 0,1 21,5V11H19V13H19L17,13V15H15V17H13V19H11V21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H19M21,15V19A2,2 0 0,1 19,21H19L15,21V19H17V17H19V15H21M19,8.5A0.5,0.5 0 0,0 18.5,8H5.5A0.5,0.5 0 0,0 5,8.5V15.5A0.5,0.5 0 0,0 5.5,16H11V15H13V13H15V11H17V9H19V8.5Z"
|
|
64
64
|
image="/demo-assets/landscape1.jpg"
|
|
65
65
|
loading="lazy"
|
|
66
66
|
size="m"
|
|
@@ -129,7 +129,7 @@ exports[`<Table> Snapshots and structure should render story 'Default' 1`] = `
|
|
|
129
129
|
alt="Ice cream sandwich"
|
|
130
130
|
aspectRatio="square"
|
|
131
131
|
className="lumx-spacing-margin-right-big"
|
|
132
|
-
fallback="
|
|
132
|
+
fallback="M19,3A2,2 0 0,1 21,5V11H19V13H19L17,13V15H15V17H13V19H11V21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H19M21,15V19A2,2 0 0,1 19,21H19L15,21V19H17V17H19V15H21M19,8.5A0.5,0.5 0 0,0 18.5,8H5.5A0.5,0.5 0 0,0 5,8.5V15.5A0.5,0.5 0 0,0 5.5,16H11V15H13V13H15V11H17V9H19V8.5Z"
|
|
133
133
|
image="/demo-assets/landscape2.jpg"
|
|
134
134
|
loading="lazy"
|
|
135
135
|
size="m"
|
|
@@ -198,7 +198,7 @@ exports[`<Table> Snapshots and structure should render story 'Default' 1`] = `
|
|
|
198
198
|
alt="Eclair"
|
|
199
199
|
aspectRatio="square"
|
|
200
200
|
className="lumx-spacing-margin-right-big"
|
|
201
|
-
fallback="
|
|
201
|
+
fallback="M19,3A2,2 0 0,1 21,5V11H19V13H19L17,13V15H15V17H13V19H11V21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H19M21,15V19A2,2 0 0,1 19,21H19L15,21V19H17V17H19V15H21M19,8.5A0.5,0.5 0 0,0 18.5,8H5.5A0.5,0.5 0 0,0 5,8.5V15.5A0.5,0.5 0 0,0 5.5,16H11V15H13V13H15V11H17V9H19V8.5Z"
|
|
202
202
|
image="/demo-assets/landscape3.jpg"
|
|
203
203
|
loading="lazy"
|
|
204
204
|
size="m"
|
|
@@ -31,27 +31,28 @@ export const Default = ({ theme }: any) => {
|
|
|
31
31
|
undefined,
|
|
32
32
|
);
|
|
33
33
|
const aspectRatio = enumKnob('Aspect ratio', [undefined, ...Object.values(AspectRatio)], undefined);
|
|
34
|
-
const crossOrigin = enumKnob('CORS', [undefined, 'anonymous', 'use-credentials'] as const, undefined);
|
|
35
34
|
const fillHeight = boolean('Fill Height', false);
|
|
36
35
|
const focusPoint = { x: focusKnob('Focus X'), y: focusKnob('Focus Y') };
|
|
37
36
|
const image = imageKnob('Image', IMAGES.landscape1);
|
|
38
37
|
const variant = select('Variant', ThumbnailVariant, ThumbnailVariant.squared);
|
|
39
38
|
const size = sizeKnob('Size', undefined);
|
|
40
39
|
const onClick = boolean('clickable?', false) ? action('onClick') : undefined;
|
|
40
|
+
const isLoading = boolean('Force loading', false);
|
|
41
|
+
const forceError = boolean('Force error', false);
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
44
|
<Thumbnail
|
|
44
45
|
alt={alt}
|
|
45
46
|
align={align}
|
|
46
47
|
aspectRatio={aspectRatio}
|
|
47
|
-
crossOrigin={crossOrigin}
|
|
48
48
|
fillHeight={fillHeight}
|
|
49
49
|
focusPoint={focusPoint}
|
|
50
|
-
image={image}
|
|
50
|
+
image={forceError ? 'foo' : image}
|
|
51
51
|
size={size}
|
|
52
52
|
theme={theme}
|
|
53
53
|
variant={variant}
|
|
54
54
|
onClick={onClick}
|
|
55
|
+
isLoading={isLoading}
|
|
55
56
|
/>
|
|
56
57
|
);
|
|
57
58
|
};
|
|
@@ -207,6 +208,7 @@ export const Vertical = () => (
|
|
|
207
208
|
<>
|
|
208
209
|
<h1>Ratio: vertical</h1>
|
|
209
210
|
<h2>Default</h2>
|
|
211
|
+
<small>Unsupported use case (thumbnail size is undefined)</small>
|
|
210
212
|
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
211
213
|
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1} />
|
|
212
214
|
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1} />
|
|
@@ -260,6 +262,7 @@ export const Wide = () => (
|
|
|
260
262
|
<>
|
|
261
263
|
<h1>Ratio: wide</h1>
|
|
262
264
|
<h2>Default</h2>
|
|
265
|
+
<small>Unsupported use case (thumbnail size is undefined)</small>
|
|
263
266
|
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
264
267
|
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1} />
|
|
265
268
|
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1} />
|
|
@@ -313,6 +316,7 @@ export const Square = () => (
|
|
|
313
316
|
<>
|
|
314
317
|
<h1>Ratio: square</h1>
|
|
315
318
|
<h2>Default</h2>
|
|
319
|
+
<small>Unsupported use case (thumbnail size is undefined)</small>
|
|
316
320
|
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
317
321
|
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1} />
|
|
318
322
|
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1} />
|
|
@@ -362,27 +366,6 @@ export const Square = () => (
|
|
|
362
366
|
</>
|
|
363
367
|
);
|
|
364
368
|
|
|
365
|
-
export const ParentSizeConstraint = () => {
|
|
366
|
-
const fillHeight = boolean('Fill Height', true);
|
|
367
|
-
return Object.values(AspectRatio).map((aspectRatio) => (
|
|
368
|
-
<FlexBox key={aspectRatio} orientation="horizontal" gap="huge">
|
|
369
|
-
<h1>ratio: {aspectRatio}</h1>
|
|
370
|
-
|
|
371
|
-
<div style={{ border: '1px solid red', width: 220, height: 400, resize: 'both', overflow: 'auto' }}>
|
|
372
|
-
<Thumbnail alt="Grid" image="/demo-assets/grid.jpg" aspectRatio={aspectRatio} fillHeight={fillHeight} />
|
|
373
|
-
</div>
|
|
374
|
-
|
|
375
|
-
<div style={{ border: '1px solid red', width: 300, height: 300, resize: 'both', overflow: 'auto' }}>
|
|
376
|
-
<Thumbnail alt="Grid" image="/demo-assets/grid.jpg" aspectRatio={aspectRatio} fillHeight={fillHeight} />
|
|
377
|
-
</div>
|
|
378
|
-
|
|
379
|
-
<div style={{ border: '1px solid red', width: 400, height: 200, resize: 'both', overflow: 'auto' }}>
|
|
380
|
-
<Thumbnail alt="Grid" image="/demo-assets/grid.jpg" aspectRatio={aspectRatio} fillHeight={fillHeight} />
|
|
381
|
-
</div>
|
|
382
|
-
</FlexBox>
|
|
383
|
-
));
|
|
384
|
-
};
|
|
385
|
-
|
|
386
369
|
export const IsLoading = ({ theme }: any) => (
|
|
387
370
|
<FlexBox
|
|
388
371
|
orientation="horizontal"
|
|
@@ -394,31 +377,23 @@ export const IsLoading = ({ theme }: any) => (
|
|
|
394
377
|
theme={theme}
|
|
395
378
|
alt="Image alt text"
|
|
396
379
|
image={IMAGES.landscape2}
|
|
397
|
-
isLoading={boolean('
|
|
380
|
+
isLoading={boolean('Force loading', true)}
|
|
398
381
|
fillHeight={boolean('Fill Height', false)}
|
|
399
382
|
size={sizeKnob('Size', undefined)}
|
|
400
383
|
/>
|
|
401
384
|
</FlexBox>
|
|
402
385
|
);
|
|
403
386
|
|
|
404
|
-
export const
|
|
405
|
-
|
|
406
|
-
export const ErrorCustomIconFallback = () => <Thumbnail alt="foo" image="foo" fallback={mdiAbTesting} />;
|
|
407
|
-
|
|
408
|
-
export const ErrorCustomFallback = () => (
|
|
409
|
-
<Thumbnail alt="foo" image="foo" fallback={<Thumbnail alt="missing image" image="/logo.svg" />} />
|
|
410
|
-
);
|
|
411
|
-
|
|
412
|
-
export const ErrorFallbackVariants = () => {
|
|
413
|
-
const isLoading = boolean('is loading', false);
|
|
387
|
+
export const ErrorFallbackVariants = ({ theme }: any) => {
|
|
388
|
+
const isLoading = boolean('Force loading', false);
|
|
414
389
|
const variant = select('Variant', ThumbnailVariant, undefined);
|
|
415
|
-
const base = { alt: 'foo', image: 'foo', isLoading, variant } as const;
|
|
390
|
+
const base = { alt: 'foo', image: 'foo', isLoading, variant, theme } as const;
|
|
416
391
|
const imageFallback = <img src="/logo.svg" alt="logo" />;
|
|
417
392
|
const imgProps = { width: 50, height: 50 };
|
|
393
|
+
|
|
418
394
|
return (
|
|
419
395
|
<>
|
|
420
396
|
<h2>Default</h2>
|
|
421
|
-
Default fallback | Custom icon fallback | Custom react node fallback
|
|
422
397
|
<FlexBox orientation="horizontal" gap="big">
|
|
423
398
|
<Thumbnail {...base} />
|
|
424
399
|
<Thumbnail {...base} fallback={mdiAbTesting} />
|
|
@@ -436,7 +411,7 @@ export const ErrorFallbackVariants = () => {
|
|
|
436
411
|
<FlexBox orientation="horizontal" gap="big">
|
|
437
412
|
<Thumbnail {...base} size="xl" />
|
|
438
413
|
<Thumbnail {...base} size="xl" fallback={mdiAbTesting} />
|
|
439
|
-
<Thumbnail {...base} size="xl" fallback={imageFallback}
|
|
414
|
+
<Thumbnail {...base} size="xl" fallback={imageFallback} />
|
|
440
415
|
</FlexBox>
|
|
441
416
|
<h2>With size & ratio</h2>
|
|
442
417
|
<FlexBox orientation="horizontal" gap="big">
|
|
@@ -447,6 +422,7 @@ export const ErrorFallbackVariants = () => {
|
|
|
447
422
|
<h2>
|
|
448
423
|
With original size <small>(50x50)</small> & ratio
|
|
449
424
|
</h2>
|
|
425
|
+
<small>Unsupported use case (thumbnail size is undefined)</small>
|
|
450
426
|
<FlexBox orientation="horizontal" gap="big">
|
|
451
427
|
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" />
|
|
452
428
|
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" fallback={mdiAbTesting} />
|
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
Clickable,
|
|
10
10
|
ClickableCustomLink,
|
|
11
11
|
ClickableLink,
|
|
12
|
-
ErrorCustomFallback,
|
|
13
12
|
Default,
|
|
14
|
-
ErrorFallback,
|
|
15
|
-
ErrorCustomIconFallback,
|
|
16
13
|
WithBadge,
|
|
17
14
|
} from './Thumbnail.stories';
|
|
18
15
|
|
|
@@ -36,9 +33,6 @@ describe(`<${Thumbnail.displayName}>`, () => {
|
|
|
36
33
|
Clickable,
|
|
37
34
|
ClickableLink,
|
|
38
35
|
ClickableCustomLink,
|
|
39
|
-
ErrorFallback,
|
|
40
|
-
ErrorCustomFallback,
|
|
41
|
-
ErrorCustomIconFallback,
|
|
42
36
|
WithBadge,
|
|
43
37
|
},
|
|
44
38
|
Thumbnail,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, {
|
|
2
|
+
CSSProperties,
|
|
2
3
|
forwardRef,
|
|
3
4
|
ImgHTMLAttributes,
|
|
4
5
|
KeyboardEventHandler,
|
|
@@ -121,7 +122,6 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
121
122
|
variant,
|
|
122
123
|
linkProps,
|
|
123
124
|
linkAs,
|
|
124
|
-
showSkeletonLoading = true,
|
|
125
125
|
...forwardedProps
|
|
126
126
|
} = props;
|
|
127
127
|
const imgRef = useRef<HTMLImageElement>(null);
|
|
@@ -131,6 +131,17 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
131
131
|
const isLoading = isLoadingProp || loadingState === 'isLoading';
|
|
132
132
|
const hasError = loadingState === 'hasError';
|
|
133
133
|
|
|
134
|
+
const hasIconErrorFallback = hasError && typeof fallback === 'string';
|
|
135
|
+
const hasCustomErrorFallback = hasError && !hasIconErrorFallback;
|
|
136
|
+
const imageErrorStyle: CSSProperties = {};
|
|
137
|
+
if (hasIconErrorFallback) {
|
|
138
|
+
// Keep the image layout on icon fallback.
|
|
139
|
+
imageErrorStyle.visibility = 'hidden';
|
|
140
|
+
} else if (hasCustomErrorFallback) {
|
|
141
|
+
// Remove the image on custom fallback.
|
|
142
|
+
imageErrorStyle.display = 'none';
|
|
143
|
+
}
|
|
144
|
+
|
|
134
145
|
const isLink = Boolean(linkProps?.href || linkAs);
|
|
135
146
|
const isButton = !!forwardedProps.onClick;
|
|
136
147
|
const isClickable = isButton || isLink;
|
|
@@ -160,7 +171,9 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
160
171
|
variant,
|
|
161
172
|
isClickable,
|
|
162
173
|
hasError,
|
|
163
|
-
|
|
174
|
+
hasIconErrorFallback,
|
|
175
|
+
hasCustomErrorFallback,
|
|
176
|
+
isLoading,
|
|
164
177
|
hasBadge: !!badge,
|
|
165
178
|
}),
|
|
166
179
|
fillHeight && `${CLASSNAME}--fill-height`,
|
|
@@ -171,8 +184,7 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
171
184
|
{...imgProps}
|
|
172
185
|
style={{
|
|
173
186
|
...imgProps?.style,
|
|
174
|
-
|
|
175
|
-
visibility: hasError ? 'hidden' : undefined,
|
|
187
|
+
...imageErrorStyle,
|
|
176
188
|
// Focus point.
|
|
177
189
|
objectPosition: getObjectPosition(aspectRatio, focusPoint),
|
|
178
190
|
}}
|
|
@@ -185,8 +197,8 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
185
197
|
/>
|
|
186
198
|
{!isLoading && hasError && (
|
|
187
199
|
<div className={`${CLASSNAME}__fallback`}>
|
|
188
|
-
{
|
|
189
|
-
<Icon icon={fallback} size={Size.xxs} theme={theme} />
|
|
200
|
+
{hasIconErrorFallback ? (
|
|
201
|
+
<Icon icon={fallback as string} size={Size.xxs} theme={theme} />
|
|
190
202
|
) : (
|
|
191
203
|
fallback
|
|
192
204
|
)}
|
|
@@ -1,124 +1,91 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<Thumbnail> Snapshots and structure should render story 'Clickable' 1`] = `
|
|
4
|
-
<
|
|
5
|
-
className="lumx-thumbnail lumx-thumbnail--size-xxl lumx-thumbnail--theme-light"
|
|
4
|
+
<button
|
|
5
|
+
className="lumx-thumbnail lumx-thumbnail--aspect-ratio-original lumx-thumbnail--size-xxl lumx-thumbnail--theme-light lumx-thumbnail--is-clickable lumx-thumbnail--is-loading"
|
|
6
6
|
onClick={[Function]}
|
|
7
|
-
onKeyPress={[Function]}
|
|
8
|
-
role="button"
|
|
9
|
-
tabIndex={0}
|
|
10
7
|
>
|
|
11
8
|
<div
|
|
12
9
|
className="lumx-thumbnail__background"
|
|
13
|
-
style={
|
|
14
|
-
Object {
|
|
15
|
-
"display": undefined,
|
|
16
|
-
"visibility": "hidden",
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
10
|
>
|
|
20
11
|
<img
|
|
21
12
|
alt="Click me"
|
|
22
|
-
className="lumx-thumbnail__image"
|
|
13
|
+
className="lumx-thumbnail__image lumx-thumbnail__image--is-loading"
|
|
23
14
|
loading="lazy"
|
|
24
15
|
src="/demo-assets/landscape1.jpg"
|
|
25
|
-
style={
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
exports[`<Thumbnail> Snapshots and structure should render story 'CustomFallback' 1`] = `
|
|
32
|
-
<div
|
|
33
|
-
className="lumx-thumbnail lumx-thumbnail--theme-light"
|
|
34
|
-
>
|
|
35
|
-
<div
|
|
36
|
-
className="lumx-thumbnail__background"
|
|
37
|
-
style={
|
|
38
|
-
Object {
|
|
39
|
-
"display": undefined,
|
|
40
|
-
"visibility": "hidden",
|
|
16
|
+
style={
|
|
17
|
+
Object {
|
|
18
|
+
"objectPosition": undefined,
|
|
19
|
+
}
|
|
41
20
|
}
|
|
42
|
-
}
|
|
43
|
-
>
|
|
44
|
-
<img
|
|
45
|
-
alt="foo"
|
|
46
|
-
className="lumx-thumbnail__image"
|
|
47
|
-
loading="lazy"
|
|
48
|
-
src="foo"
|
|
49
|
-
style={Object {}}
|
|
50
21
|
/>
|
|
51
22
|
</div>
|
|
52
|
-
</
|
|
23
|
+
</button>
|
|
53
24
|
`;
|
|
54
25
|
|
|
55
|
-
exports[`<Thumbnail> Snapshots and structure should render story '
|
|
56
|
-
<
|
|
57
|
-
className="lumx-thumbnail lumx-thumbnail--size-xxl lumx-thumbnail--theme-light"
|
|
26
|
+
exports[`<Thumbnail> Snapshots and structure should render story 'ClickableCustomLink' 1`] = `
|
|
27
|
+
<CustomLinkComponent
|
|
28
|
+
className="custom-class-name lumx-thumbnail lumx-thumbnail--aspect-ratio-original lumx-thumbnail--size-xxl lumx-thumbnail--theme-light lumx-thumbnail--is-clickable lumx-thumbnail--is-loading"
|
|
29
|
+
href="https://google.fr"
|
|
58
30
|
>
|
|
59
31
|
<div
|
|
60
32
|
className="lumx-thumbnail__background"
|
|
61
|
-
style={
|
|
62
|
-
Object {
|
|
63
|
-
"display": undefined,
|
|
64
|
-
"visibility": "hidden",
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
33
|
>
|
|
68
34
|
<img
|
|
69
|
-
alt="
|
|
70
|
-
className="lumx-thumbnail__image"
|
|
35
|
+
alt="Click me"
|
|
36
|
+
className="lumx-thumbnail__image lumx-thumbnail__image--is-loading"
|
|
71
37
|
loading="lazy"
|
|
72
38
|
src="/demo-assets/landscape1.jpg"
|
|
73
|
-
style={
|
|
39
|
+
style={
|
|
40
|
+
Object {
|
|
41
|
+
"objectPosition": undefined,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
74
44
|
/>
|
|
75
45
|
</div>
|
|
76
|
-
</
|
|
46
|
+
</CustomLinkComponent>
|
|
77
47
|
`;
|
|
78
48
|
|
|
79
|
-
exports[`<Thumbnail> Snapshots and structure should render story '
|
|
80
|
-
<
|
|
81
|
-
className="lumx-thumbnail lumx-thumbnail--theme-light"
|
|
49
|
+
exports[`<Thumbnail> Snapshots and structure should render story 'ClickableLink' 1`] = `
|
|
50
|
+
<a
|
|
51
|
+
className="lumx-thumbnail lumx-thumbnail--aspect-ratio-original lumx-thumbnail--size-xxl lumx-thumbnail--theme-light lumx-thumbnail--is-clickable lumx-thumbnail--is-loading"
|
|
52
|
+
href="https://google.fr"
|
|
82
53
|
>
|
|
83
54
|
<div
|
|
84
55
|
className="lumx-thumbnail__background"
|
|
85
|
-
style={
|
|
86
|
-
Object {
|
|
87
|
-
"display": undefined,
|
|
88
|
-
"visibility": "hidden",
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
56
|
>
|
|
92
57
|
<img
|
|
93
|
-
alt="
|
|
94
|
-
className="lumx-thumbnail__image"
|
|
58
|
+
alt="Click me"
|
|
59
|
+
className="lumx-thumbnail__image lumx-thumbnail__image--is-loading"
|
|
95
60
|
loading="lazy"
|
|
96
|
-
src="
|
|
97
|
-
style={
|
|
61
|
+
src="/demo-assets/landscape1.jpg"
|
|
62
|
+
style={
|
|
63
|
+
Object {
|
|
64
|
+
"objectPosition": undefined,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
98
67
|
/>
|
|
99
68
|
</div>
|
|
100
|
-
</
|
|
69
|
+
</a>
|
|
101
70
|
`;
|
|
102
71
|
|
|
103
|
-
exports[`<Thumbnail> Snapshots and structure should render story '
|
|
72
|
+
exports[`<Thumbnail> Snapshots and structure should render story 'Default' 1`] = `
|
|
104
73
|
<div
|
|
105
|
-
className="lumx-thumbnail lumx-thumbnail--theme-light"
|
|
74
|
+
className="lumx-thumbnail lumx-thumbnail--aspect-ratio-original lumx-thumbnail--theme-light lumx-thumbnail--variant-squared lumx-thumbnail--is-loading"
|
|
106
75
|
>
|
|
107
76
|
<div
|
|
108
77
|
className="lumx-thumbnail__background"
|
|
109
|
-
style={
|
|
110
|
-
Object {
|
|
111
|
-
"display": undefined,
|
|
112
|
-
"visibility": "hidden",
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
78
|
>
|
|
116
79
|
<img
|
|
117
|
-
alt="
|
|
118
|
-
className="lumx-thumbnail__image"
|
|
80
|
+
alt="Image alt text"
|
|
81
|
+
className="lumx-thumbnail__image lumx-thumbnail__image--is-loading"
|
|
119
82
|
loading="lazy"
|
|
120
|
-
src="
|
|
121
|
-
style={
|
|
83
|
+
src="/demo-assets/landscape1.jpg"
|
|
84
|
+
style={
|
|
85
|
+
Object {
|
|
86
|
+
"objectPosition": undefined,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
122
89
|
/>
|
|
123
90
|
</div>
|
|
124
91
|
</div>
|
|
@@ -126,23 +93,21 @@ exports[`<Thumbnail> Snapshots and structure should render story 'IconFallback'
|
|
|
126
93
|
|
|
127
94
|
exports[`<Thumbnail> Snapshots and structure should render story 'WithBadge' 1`] = `
|
|
128
95
|
<div
|
|
129
|
-
className="lumx-thumbnail lumx-thumbnail--aspect-ratio-square lumx-thumbnail--size-l lumx-thumbnail--theme-light lumx-thumbnail--variant-rounded lumx-thumbnail--has-badge"
|
|
96
|
+
className="lumx-thumbnail lumx-thumbnail--aspect-ratio-square lumx-thumbnail--size-l lumx-thumbnail--theme-light lumx-thumbnail--variant-rounded lumx-thumbnail--is-loading lumx-thumbnail--has-badge"
|
|
130
97
|
>
|
|
131
98
|
<div
|
|
132
99
|
className="lumx-thumbnail__background"
|
|
133
|
-
style={
|
|
134
|
-
Object {
|
|
135
|
-
"display": undefined,
|
|
136
|
-
"visibility": "hidden",
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
100
|
>
|
|
140
101
|
<img
|
|
141
102
|
alt="Image alt text"
|
|
142
|
-
className="lumx-thumbnail__image"
|
|
103
|
+
className="lumx-thumbnail__image lumx-thumbnail__image--is-loading"
|
|
143
104
|
loading="lazy"
|
|
144
105
|
src="/demo-assets/landscape1.jpg"
|
|
145
|
-
style={
|
|
106
|
+
style={
|
|
107
|
+
Object {
|
|
108
|
+
"objectPosition": undefined,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
146
111
|
/>
|
|
147
112
|
</div>
|
|
148
113
|
<Badge
|
package/src/hooks/useOnResize.ts
CHANGED
|
@@ -23,12 +23,6 @@ export function useOnResize(element: HTMLElement | Falsy, update: RefObject<Call
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// Do not update on first resize.
|
|
27
|
-
if (previousSize.current && previousSize.current.height <= 1) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Do not update if size hasn't really changed.
|
|
32
26
|
const { width, height } = entry.contentRect;
|
|
33
27
|
if (previousSize.current?.width === width && previousSize.current?.height === height) {
|
|
34
28
|
return;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
export default { title: 'LumX components/list/List Demos' };
|
|
5
5
|
|
|
6
6
|
export { App as Big } from './big';
|
|
7
|
+
export { App as Clickable } from './clickable';
|
|
7
8
|
export { App as Huge } from './huge';
|
|
9
|
+
export { App as Paddings } from './paddings';
|
|
8
10
|
export { App as Regular } from './regular';
|
|
9
11
|
export { App as Tiny } from './tiny';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { KeyboardEventHandler, MouseEventHandler, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
role: 'button';
|
|
5
|
-
tabIndex: 0;
|
|
6
|
-
onClick: MouseEventHandler;
|
|
7
|
-
onKeyPress: KeyboardEventHandler;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const useClickable = ({ onClick, onKeyPress }: { onClick?: any; onKeyPress?: any }): Props | undefined => {
|
|
11
|
-
return useMemo(() => {
|
|
12
|
-
if (!onClick) return undefined;
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
role: 'button',
|
|
16
|
-
tabIndex: 0,
|
|
17
|
-
onClick,
|
|
18
|
-
onKeyPress(event) {
|
|
19
|
-
onKeyPress?.(event);
|
|
20
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
21
|
-
onClick?.();
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}, [onClick, onKeyPress]);
|
|
26
|
-
};
|