@lumx/react 2.1.9-alpha-thumbnail3 → 2.1.9-alpha.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/esm/_internal/AlertDialog.js +1 -2
- package/esm/_internal/AlertDialog.js.map +1 -1
- package/esm/_internal/AutocompleteMultiple.js +1 -2
- package/esm/_internal/AutocompleteMultiple.js.map +1 -1
- package/esm/_internal/Button2.js +1 -1
- package/esm/_internal/Checkbox2.js +1 -2
- package/esm/_internal/Checkbox2.js.map +1 -1
- package/esm/_internal/DatePickerField.js +1 -1
- package/esm/_internal/DragHandle.js +2 -3
- package/esm/_internal/DragHandle.js.map +1 -1
- package/esm/_internal/ExpansionPanel.js +1 -1
- package/esm/_internal/Flag2.js +1 -3
- package/esm/_internal/Flag2.js.map +1 -1
- package/esm/_internal/Icon2.js +32 -4
- package/esm/_internal/Icon2.js.map +1 -1
- package/esm/_internal/IconButton.js +1 -1
- package/esm/_internal/ImageBlock.js +1 -0
- package/esm/_internal/ImageBlock.js.map +1 -1
- package/esm/_internal/Lightbox2.js +1 -1
- package/esm/_internal/Link2.js +1 -1
- package/esm/_internal/LinkPreview.js +1 -1
- package/esm/_internal/LinkPreview.js.map +1 -1
- package/esm/_internal/Message2.js +5 -5
- package/esm/_internal/Message2.js.map +1 -1
- package/esm/_internal/Notification2.js +1 -2
- package/esm/_internal/Notification2.js.map +1 -1
- package/esm/_internal/ProgressTrackerStepPanel.js +1 -2
- package/esm/_internal/ProgressTrackerStepPanel.js.map +1 -1
- package/esm/_internal/SelectMultiple.js +1 -2
- package/esm/_internal/SelectMultiple.js.map +1 -1
- package/esm/_internal/SideNavigationItem.js +1 -2
- package/esm/_internal/SideNavigationItem.js.map +1 -1
- package/esm/_internal/Slider2.js +2 -21
- package/esm/_internal/Slider2.js.map +1 -1
- package/esm/_internal/SlideshowControls.js +1 -1
- package/esm/_internal/TabPanel.js +1 -1
- package/esm/_internal/TableRow.js +1 -2
- package/esm/_internal/TableRow.js.map +1 -1
- package/esm/_internal/TextField.js +1 -2
- package/esm/_internal/TextField.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +764 -62
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/alert-dialog.js +1 -2
- package/esm/_internal/alert-dialog.js.map +1 -1
- package/esm/_internal/autocomplete.js +1 -2
- package/esm/_internal/autocomplete.js.map +1 -1
- package/esm/_internal/avatar.js +4 -2
- package/esm/_internal/avatar.js.map +1 -1
- package/esm/_internal/button.js +1 -1
- package/esm/_internal/checkbox.js +1 -2
- package/esm/_internal/checkbox.js.map +1 -1
- package/esm/_internal/clamp.js +22 -0
- package/esm/_internal/clamp.js.map +1 -0
- package/esm/_internal/comment-block.js +4 -2
- package/esm/_internal/comment-block.js.map +1 -1
- package/esm/_internal/date-picker.js +1 -2
- package/esm/_internal/date-picker.js.map +1 -1
- package/esm/_internal/drag-handle.js +1 -2
- package/esm/_internal/drag-handle.js.map +1 -1
- package/esm/_internal/expansion-panel.js +1 -2
- package/esm/_internal/expansion-panel.js.map +1 -1
- package/esm/_internal/flag.js +1 -1
- package/esm/_internal/icon.js +1 -1
- package/esm/_internal/image-block.js +4 -2
- package/esm/_internal/image-block.js.map +1 -1
- package/esm/_internal/lightbox.js +1 -2
- package/esm/_internal/lightbox.js.map +1 -1
- package/esm/_internal/link-preview.js +4 -2
- package/esm/_internal/link-preview.js.map +1 -1
- package/esm/_internal/link.js +1 -1
- package/esm/_internal/message.js +1 -2
- package/esm/_internal/message.js.map +1 -1
- package/esm/_internal/mosaic.js +4 -2
- package/esm/_internal/mosaic.js.map +1 -1
- package/esm/_internal/notification.js +1 -2
- package/esm/_internal/notification.js.map +1 -1
- package/esm/_internal/post-block.js +4 -2
- package/esm/_internal/post-block.js.map +1 -1
- package/esm/_internal/progress-tracker.js +1 -2
- package/esm/_internal/progress-tracker.js.map +1 -1
- package/esm/_internal/select.js +1 -2
- package/esm/_internal/select.js.map +1 -1
- package/esm/_internal/side-navigation.js +1 -2
- package/esm/_internal/side-navigation.js.map +1 -1
- package/esm/_internal/slider.js +2 -1
- package/esm/_internal/slider.js.map +1 -1
- package/esm/_internal/slideshow.js +1 -2
- package/esm/_internal/slideshow.js.map +1 -1
- package/esm/_internal/table.js +1 -2
- package/esm/_internal/table.js.map +1 -1
- package/esm/_internal/tabs.js +1 -1
- package/esm/_internal/text-field.js +1 -2
- package/esm/_internal/text-field.js.map +1 -1
- package/esm/_internal/thumbnail.js +4 -2
- package/esm/_internal/thumbnail.js.map +1 -1
- package/esm/_internal/uploader.js +1 -1
- package/esm/_internal/user-block.js +3 -2
- package/esm/_internal/user-block.js.map +1 -1
- package/esm/index.js +4 -4
- package/package.json +4 -4
- package/src/components/drag-handle/DragHandle.tsx +5 -1
- package/src/components/flag/Flag.test.tsx +1 -2
- package/src/components/flag/Flag.tsx +2 -10
- package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -15
- package/src/components/icon/Icon.tsx +15 -1
- package/src/components/image-block/ImageBlock.tsx +1 -0
- package/src/components/link-preview/LinkPreview.tsx +1 -1
- package/src/components/link-preview/__snapshots__/LinkPreview.test.tsx.snap +2 -2
- package/src/components/message/Message.tsx +4 -2
- package/src/components/thumbnail/Thumbnail.stories.tsx +59 -399
- package/src/components/thumbnail/Thumbnail.test.tsx +6 -6
- package/src/components/thumbnail/Thumbnail.tsx +34 -35
- package/src/components/thumbnail/useFocusPoint.ts +10 -18
- package/src/components/thumbnail/useImageLoad.ts +22 -23
- package/src/hooks/useOnResize.ts +0 -6
- package/src/stories/knobs/image.ts +3 -35
- package/types.d.ts +0 -2
- package/esm/_internal/mdi.js +0 -22
- package/esm/_internal/mdi.js.map +0 -1
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
ReactNode,
|
|
8
8
|
Ref,
|
|
9
9
|
useRef,
|
|
10
|
+
useState,
|
|
10
11
|
} from 'react';
|
|
11
12
|
import classNames from 'classnames';
|
|
12
13
|
|
|
@@ -14,8 +15,10 @@ import { AspectRatio, HorizontalAlignment, Icon, Size, Theme } from '@lumx/react
|
|
|
14
15
|
|
|
15
16
|
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { mdiImageBrokenVariant } from '@lumx/icons';
|
|
19
|
+
import { isInternetExplorer } from '@lumx/react/utils/isInternetExplorer';
|
|
18
20
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
21
|
+
import { useFocusPoint } from '@lumx/react/components/thumbnail/useFocusPoint';
|
|
19
22
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
20
23
|
import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
|
|
21
24
|
|
|
@@ -47,8 +50,6 @@ export interface ThumbnailProps extends GenericProps {
|
|
|
47
50
|
imgProps?: ImgHTMLProps;
|
|
48
51
|
/** Reference to the native <img> element. */
|
|
49
52
|
imgRef?: Ref<HTMLImageElement>;
|
|
50
|
-
/** Set to true to force the display of the loading skeleton. */
|
|
51
|
-
isLoading?: boolean;
|
|
52
53
|
/** Size variant of the component. */
|
|
53
54
|
size?: ThumbnailSize;
|
|
54
55
|
/** Image loading mode. */
|
|
@@ -81,18 +82,11 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
81
82
|
* Component default props.
|
|
82
83
|
*/
|
|
83
84
|
const DEFAULT_PROPS: Partial<ThumbnailProps> = {
|
|
84
|
-
fallback:
|
|
85
|
+
fallback: mdiImageBrokenVariant,
|
|
85
86
|
loading: 'lazy',
|
|
86
87
|
theme: Theme.light,
|
|
87
88
|
};
|
|
88
89
|
|
|
89
|
-
function getObjectPosition(aspectRatio: AspectRatio, focusPoint?: FocusPoint) {
|
|
90
|
-
if (aspectRatio === AspectRatio.original || (!focusPoint?.y && !focusPoint?.x)) return undefined;
|
|
91
|
-
const x = Math.round(Math.abs(((focusPoint?.x || 0) + 1) / 2) * 100);
|
|
92
|
-
const y = Math.round(Math.abs(((focusPoint?.y || 0) - 1) / 2) * 100);
|
|
93
|
-
return `${x}% ${y}%`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
90
|
/**
|
|
97
91
|
* Thumbnail component.
|
|
98
92
|
*
|
|
@@ -104,7 +98,7 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
104
98
|
const {
|
|
105
99
|
align,
|
|
106
100
|
alt,
|
|
107
|
-
aspectRatio
|
|
101
|
+
aspectRatio,
|
|
108
102
|
badge,
|
|
109
103
|
className,
|
|
110
104
|
crossOrigin,
|
|
@@ -114,22 +108,22 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
114
108
|
image,
|
|
115
109
|
imgProps,
|
|
116
110
|
imgRef: propImgRef,
|
|
117
|
-
isLoading: isLoadingProp,
|
|
118
111
|
loading,
|
|
119
112
|
size,
|
|
120
113
|
theme,
|
|
121
114
|
variant,
|
|
122
115
|
linkProps,
|
|
123
116
|
linkAs,
|
|
124
|
-
showSkeletonLoading = true,
|
|
125
117
|
...forwardedProps
|
|
126
118
|
} = props;
|
|
127
119
|
const imgRef = useRef<HTMLImageElement>(null);
|
|
128
120
|
|
|
129
121
|
// Image loading state.
|
|
130
|
-
const loadingState = useImageLoad(
|
|
131
|
-
const isLoading = isLoadingProp || loadingState === 'isLoading';
|
|
122
|
+
const loadingState = useImageLoad(imgRef);
|
|
132
123
|
const hasError = loadingState === 'hasError';
|
|
124
|
+
const isLoading = loadingState === 'isLoading';
|
|
125
|
+
|
|
126
|
+
const [wrapper, setWrapper] = useState<HTMLElement>();
|
|
133
127
|
|
|
134
128
|
const isLink = Boolean(linkProps?.href || linkAs);
|
|
135
129
|
const isButton = !!forwardedProps.onClick;
|
|
@@ -144,10 +138,13 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
144
138
|
Wrapper = 'button';
|
|
145
139
|
}
|
|
146
140
|
|
|
141
|
+
// Update img style according to focus point and aspect ratio.
|
|
142
|
+
const style = useFocusPoint({ image, focusPoint, aspectRatio, imgRef, loadingState, wrapper });
|
|
143
|
+
|
|
147
144
|
return (
|
|
148
145
|
<Wrapper
|
|
149
146
|
{...wrapperProps}
|
|
150
|
-
ref={ref}
|
|
147
|
+
ref={mergeRefs(setWrapper, ref) as any}
|
|
151
148
|
className={classNames(
|
|
152
149
|
linkProps?.className,
|
|
153
150
|
className,
|
|
@@ -159,40 +156,42 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
159
156
|
theme,
|
|
160
157
|
variant,
|
|
161
158
|
isClickable,
|
|
162
|
-
hasError,
|
|
163
|
-
isLoading: showSkeletonLoading && isLoading,
|
|
164
159
|
hasBadge: !!badge,
|
|
165
160
|
}),
|
|
161
|
+
isLoading && wrapper?.getBoundingClientRect()?.height && 'lumx-color-background-dark-L6',
|
|
166
162
|
fillHeight && `${CLASSNAME}--fill-height`,
|
|
167
163
|
)}
|
|
168
164
|
>
|
|
169
|
-
<div
|
|
165
|
+
<div
|
|
166
|
+
className={`${CLASSNAME}__background`}
|
|
167
|
+
style={{
|
|
168
|
+
...style?.wrapper,
|
|
169
|
+
// Remove from layout if image not loaded correctly (use fallback)
|
|
170
|
+
display: hasError ? 'none' : undefined,
|
|
171
|
+
// Hide while loading.
|
|
172
|
+
visibility: isLoading ? 'hidden' : undefined,
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
170
175
|
<img
|
|
171
176
|
{...imgProps}
|
|
172
177
|
style={{
|
|
173
178
|
...imgProps?.style,
|
|
174
|
-
|
|
175
|
-
visibility: hasError ? 'hidden' : undefined,
|
|
176
|
-
// Focus point.
|
|
177
|
-
objectPosition: getObjectPosition(aspectRatio, focusPoint),
|
|
179
|
+
...style?.image,
|
|
178
180
|
}}
|
|
179
181
|
ref={mergeRefs(imgRef, propImgRef)}
|
|
180
|
-
className={
|
|
181
|
-
crossOrigin={crossOrigin}
|
|
182
|
+
className={style?.image ? `${CLASSNAME}__focused-image` : `${CLASSNAME}__image`}
|
|
183
|
+
crossOrigin={crossOrigin && !isInternetExplorer() ? crossOrigin : undefined}
|
|
182
184
|
src={image}
|
|
183
185
|
alt={alt}
|
|
184
186
|
loading={loading}
|
|
185
187
|
/>
|
|
186
|
-
{!isLoading && hasError && (
|
|
187
|
-
<div className={`${CLASSNAME}__fallback`}>
|
|
188
|
-
{typeof fallback === 'string' ? (
|
|
189
|
-
<Icon icon={fallback} size={Size.xxs} theme={theme} />
|
|
190
|
-
) : (
|
|
191
|
-
fallback
|
|
192
|
-
)}
|
|
193
|
-
</div>
|
|
194
|
-
)}
|
|
195
188
|
</div>
|
|
189
|
+
{hasError &&
|
|
190
|
+
(typeof fallback === 'string' ? (
|
|
191
|
+
<Icon className={`${CLASSNAME}__fallback`} icon={fallback} size={size || Size.m} theme={theme} />
|
|
192
|
+
) : (
|
|
193
|
+
<div className={`${CLASSNAME}__fallback`}>{fallback}</div>
|
|
194
|
+
))}
|
|
196
195
|
{badge &&
|
|
197
196
|
React.cloneElement(badge, { className: classNames(`${CLASSNAME}__badge`, badge.props.className) })}
|
|
198
197
|
</Wrapper>
|
|
@@ -32,19 +32,15 @@ type Sizes = {
|
|
|
32
32
|
|
|
33
33
|
function calculateSizes(
|
|
34
34
|
imageElement?: HTMLImageElement | null | undefined,
|
|
35
|
-
imageWidthProp?: number,
|
|
36
|
-
imageHeightProp?: number,
|
|
37
35
|
parentElement?: HTMLElement | null,
|
|
38
36
|
aspectRatio?: AspectRatio,
|
|
39
37
|
): Sizes | undefined {
|
|
40
|
-
|
|
41
|
-
const imgHeight = imageElement
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const containerWidth = Math.ceil(rect?.width || 0);
|
|
47
|
-
const containerHeight = Math.ceil(rect?.height || 0);
|
|
38
|
+
if (!imageElement || !parentElement || !aspectRatio || aspectRatio === AspectRatio.original) return undefined;
|
|
39
|
+
const { naturalWidth: imgWidth, naturalHeight: imgHeight } = imageElement || { naturalWidth: 0, naturalHeight: 0 };
|
|
40
|
+
const { width: containerWidth, height: containerHeight } = parentElement?.getBoundingClientRect() || {
|
|
41
|
+
width: 0,
|
|
42
|
+
height: 0,
|
|
43
|
+
};
|
|
48
44
|
return { imgWidth, imgHeight, containerWidth, containerHeight, aspectRatio };
|
|
49
45
|
}
|
|
50
46
|
|
|
@@ -94,7 +90,6 @@ function calculateImageStyle(sizes: Sizes, point: Required<FocusPoint>): Styles
|
|
|
94
90
|
// Minimize image while still filling space
|
|
95
91
|
if (sizes.imgWidth > sizes.containerWidth && sizes.imgHeight > sizes.containerHeight) {
|
|
96
92
|
image[widthRatio > heightRatio ? 'maxHeight' : 'maxWidth'] = '100%';
|
|
97
|
-
image[widthRatio > heightRatio ? 'maxWidth' : 'maxHeight'] = 'none';
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
if (widthRatio > heightRatio) {
|
|
@@ -114,15 +109,13 @@ function calculateImageStyle(sizes: Sizes, point: Required<FocusPoint>): Styles
|
|
|
114
109
|
*/
|
|
115
110
|
export const useFocusPoint = (options: {
|
|
116
111
|
image: string;
|
|
117
|
-
imageWidthProp?: number;
|
|
118
|
-
imageHeightProp?: number;
|
|
119
112
|
focusPoint?: FocusPoint;
|
|
120
113
|
aspectRatio?: AspectRatio;
|
|
121
114
|
imgRef: RefObject<HTMLImageElement>;
|
|
122
115
|
loadingState: LoadingState;
|
|
123
116
|
wrapper?: HTMLElement;
|
|
124
117
|
}): Styles | undefined => {
|
|
125
|
-
const { image,
|
|
118
|
+
const { image, aspectRatio, focusPoint, imgRef, loadingState, wrapper } = options;
|
|
126
119
|
|
|
127
120
|
const point = parseFocusPoint(focusPoint);
|
|
128
121
|
|
|
@@ -135,13 +128,12 @@ export const useFocusPoint = (options: {
|
|
|
135
128
|
const update = useMemo(
|
|
136
129
|
() => {
|
|
137
130
|
const updateFunction = () => {
|
|
138
|
-
const sizes = calculateSizes(imgRef?.current,
|
|
131
|
+
const sizes = calculateSizes(imgRef?.current, wrapper, aspectRatio);
|
|
139
132
|
if (!sizes || (isEqual(sizes, previousSizes.current) && isEqual(point, previousPoint.current))) {
|
|
140
133
|
// Nothing changed.
|
|
141
134
|
return;
|
|
142
135
|
}
|
|
143
|
-
|
|
144
|
-
setStyle(newStyle);
|
|
136
|
+
setStyle(calculateImageStyle(sizes, point));
|
|
145
137
|
previousPoint.current = point;
|
|
146
138
|
previousSizes.current = sizes;
|
|
147
139
|
};
|
|
@@ -149,7 +141,7 @@ export const useFocusPoint = (options: {
|
|
|
149
141
|
return updateFunction;
|
|
150
142
|
},
|
|
151
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
|
-
[...Object.values(point), wrapper, aspectRatio],
|
|
144
|
+
[...Object.values(point), imgRef, wrapper, aspectRatio],
|
|
153
145
|
);
|
|
154
146
|
|
|
155
147
|
// Update on image loaded.
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import { RefObject, useEffect, useState } from 'react';
|
|
1
|
+
import { RefObject, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export type LoadingState = 'isLoading' | 'isLoaded' | 'hasError';
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
if (event?.type === 'error' || (img?.complete && (img?.naturalWidth === 0 || img?.naturalHeight === 0))) {
|
|
8
|
-
return 'hasError';
|
|
9
|
-
}
|
|
10
|
-
// Image is undefined or incomplete.
|
|
11
|
-
if (!img || !img.complete) {
|
|
12
|
-
return 'isLoading';
|
|
13
|
-
}
|
|
14
|
-
// Else loaded.
|
|
15
|
-
return 'isLoaded';
|
|
16
|
-
}
|
|
5
|
+
export function useImageLoad(imgRef?: RefObject<HTMLImageElement>): LoadingState {
|
|
6
|
+
const [state, setState] = useState<LoadingState>('isLoading');
|
|
17
7
|
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const update = useCallback(
|
|
9
|
+
(event?: any) => {
|
|
10
|
+
const img = imgRef?.current;
|
|
11
|
+
if (!img || !img.complete) {
|
|
12
|
+
setState('isLoading');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if (event?.type === 'error' || (img.complete && img?.naturalWidth === 0)) {
|
|
17
|
+
setState('hasError');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setState('isLoaded');
|
|
22
|
+
},
|
|
23
|
+
[imgRef],
|
|
24
|
+
);
|
|
25
25
|
|
|
26
|
-
// Listen to `load` and `error` event on image
|
|
27
26
|
useEffect(() => {
|
|
28
27
|
const img = imgRef?.current;
|
|
29
28
|
if (!img) return undefined;
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
update();
|
|
31
31
|
img.addEventListener('load', update);
|
|
32
32
|
img.addEventListener('error', update);
|
|
33
33
|
return () => {
|
|
34
34
|
img.removeEventListener('load', update);
|
|
35
35
|
img.removeEventListener('error', update);
|
|
36
36
|
};
|
|
37
|
-
}, [imgRef, imgRef?.current?.src]);
|
|
38
|
-
|
|
37
|
+
}, [update, imgRef, imgRef?.current?.src]);
|
|
39
38
|
return state;
|
|
40
39
|
}
|
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;
|
|
@@ -6,19 +6,18 @@ const avatar3 = '/demo-assets/avatar3.jpg';
|
|
|
6
6
|
const avatar4 = '/demo-assets/avatar4.jpg';
|
|
7
7
|
const landscape1 = '/demo-assets/landscape1.jpg';
|
|
8
8
|
const landscape2 = '/demo-assets/landscape2.jpg';
|
|
9
|
-
const landscape1s200 = '/demo-assets/landscape1-s200.jpg';
|
|
10
9
|
const landscape3 = '/demo-assets/landscape3.jpg';
|
|
11
10
|
const portrait1 = '/demo-assets/portrait1.jpg';
|
|
12
|
-
const portrait1s200 = '/demo-assets/portrait1-s200.jpg';
|
|
13
11
|
const portrait2 = '/demo-assets/portrait2.jpg';
|
|
14
12
|
const portrait3 = '/demo-assets/portrait3.jpg';
|
|
15
13
|
const square1 = '/demo-assets/square1.jpg';
|
|
16
14
|
const square2 = '/demo-assets/square2.jpg';
|
|
17
15
|
|
|
18
16
|
export const AVATAR_IMAGES = { avatar1, avatar2, avatar3, avatar4 };
|
|
17
|
+
|
|
19
18
|
export const SQUARE_IMAGES = { square1, square2 };
|
|
20
|
-
export const LANDSCAPE_IMAGES = { landscape1,
|
|
21
|
-
export const PORTRAIT_IMAGES = { portrait1,
|
|
19
|
+
export const LANDSCAPE_IMAGES = { landscape1, landscape2, landscape3 };
|
|
20
|
+
export const PORTRAIT_IMAGES = { portrait1, portrait2, portrait3 };
|
|
22
21
|
|
|
23
22
|
export const IMAGES = { ...LANDSCAPE_IMAGES, ...PORTRAIT_IMAGES, ...SQUARE_IMAGES, ...AVATAR_IMAGES };
|
|
24
23
|
|
|
@@ -36,34 +35,3 @@ export const squareImageKnob = (name = 'Image', value = Object.values(SQUARE_IMA
|
|
|
36
35
|
|
|
37
36
|
export const imageKnob = (name = 'Image', value = Object.values(IMAGES)[0], groupId?: string) =>
|
|
38
37
|
select(name, IMAGES, value, groupId);
|
|
39
|
-
|
|
40
|
-
type Size = { width: number; height: number };
|
|
41
|
-
|
|
42
|
-
export const AVATAR_IMAGE_SIZES: Record<keyof typeof AVATAR_IMAGES, Size> = {
|
|
43
|
-
avatar1: { width: 128, height: 128 },
|
|
44
|
-
avatar2: { width: 150, height: 150 },
|
|
45
|
-
avatar3: { width: 128, height: 128 },
|
|
46
|
-
avatar4: { width: 128, height: 128 },
|
|
47
|
-
};
|
|
48
|
-
export const SQUARE_IMAGE_SIZES: Record<keyof typeof SQUARE_IMAGES, Size> = {
|
|
49
|
-
square1: { width: 72, height: 72 },
|
|
50
|
-
square2: { width: 300, height: 300 },
|
|
51
|
-
};
|
|
52
|
-
export const LANDSCAPE_IMAGE_SIZES: Record<keyof typeof LANDSCAPE_IMAGES, Size> = {
|
|
53
|
-
landscape1: { width: 800, height: 546 },
|
|
54
|
-
landscape1s200: { width: 200, height: 150 },
|
|
55
|
-
landscape2: { width: 800, height: 600 },
|
|
56
|
-
landscape3: { width: 640, height: 480 },
|
|
57
|
-
};
|
|
58
|
-
export const PORTRAIT_IMAGE_SIZES: Record<keyof typeof PORTRAIT_IMAGES, Size> = {
|
|
59
|
-
portrait1: { width: 275, height: 500 },
|
|
60
|
-
portrait1s200: { width: 200, height: 364 },
|
|
61
|
-
portrait2: { width: 350, height: 500 },
|
|
62
|
-
portrait3: { width: 300, height: 500 },
|
|
63
|
-
};
|
|
64
|
-
export const IMAGE_SIZES: Record<keyof typeof IMAGES, Size> = {
|
|
65
|
-
...LANDSCAPE_IMAGE_SIZES,
|
|
66
|
-
...PORTRAIT_IMAGE_SIZES,
|
|
67
|
-
...SQUARE_IMAGE_SIZES,
|
|
68
|
-
...AVATAR_IMAGE_SIZES,
|
|
69
|
-
};
|
package/types.d.ts
CHANGED
|
@@ -1237,8 +1237,6 @@ export interface ThumbnailProps extends GenericProps {
|
|
|
1237
1237
|
imgProps?: ImgHTMLProps;
|
|
1238
1238
|
/** Reference to the native <img> element. */
|
|
1239
1239
|
imgRef?: Ref<HTMLImageElement>;
|
|
1240
|
-
/** Set to true to force the display of the loading skeleton. */
|
|
1241
|
-
isLoading?: boolean;
|
|
1242
1240
|
/** Size variant of the component. */
|
|
1243
1241
|
size?: ThumbnailSize;
|
|
1244
1242
|
/** Image loading mode. */
|
package/esm/_internal/mdi.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Material Design Icons v5.8.55
|
|
2
|
-
var mdiAlert = "M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z";
|
|
3
|
-
var mdiAlertCircle = "M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z";
|
|
4
|
-
var mdiArrowDown = "M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z";
|
|
5
|
-
var mdiArrowUp = "M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z";
|
|
6
|
-
var mdiCheck = "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z";
|
|
7
|
-
var mdiCheckCircle = "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z";
|
|
8
|
-
var mdiChevronDown = "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z";
|
|
9
|
-
var mdiChevronLeft = "M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z";
|
|
10
|
-
var mdiChevronRight = "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";
|
|
11
|
-
var mdiChevronUp = "M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z";
|
|
12
|
-
var mdiClose = "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
|
|
13
|
-
var mdiCloseCircle = "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z";
|
|
14
|
-
var mdiDragVertical = "M9,3H11V5H9V3M13,3H15V5H13V3M9,7H11V9H9V7M13,7H15V9H13V7M9,11H11V13H9V11M13,11H15V13H13V11M9,15H11V17H9V15M13,15H15V17H13V15M9,19H11V21H9V19M13,19H15V21H13V19Z";
|
|
15
|
-
var mdiImageBroken = "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";
|
|
16
|
-
var mdiInformation = "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z";
|
|
17
|
-
var mdiMenuDown = "M7,10L12,15L17,10H7Z";
|
|
18
|
-
var mdiRadioboxBlank = "M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z";
|
|
19
|
-
var mdiRadioboxMarked = "M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7Z";
|
|
20
|
-
|
|
21
|
-
export { mdiInformation as a, mdiCheckCircle as b, mdiAlertCircle as c, mdiClose as d, mdiCheck as e, mdiChevronRight as f, mdiChevronLeft as g, mdiDragVertical as h, mdiChevronUp as i, mdiChevronDown as j, mdiRadioboxMarked as k, mdiRadioboxBlank as l, mdiAlert as m, mdiCloseCircle as n, mdiMenuDown as o, mdiArrowUp as p, mdiArrowDown as q, mdiImageBroken as r };
|
|
22
|
-
//# sourceMappingURL=mdi.js.map
|