@lumx/react 2.1.9-alpha-thumbnail4 → 2.1.9-prefer-css-color-variables2
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/ImageBlock.js +1 -0
- package/esm/_internal/ImageBlock.js.map +1 -1
- package/esm/_internal/List2.js.map +1 -1
- package/esm/_internal/Slider2.js +2 -21
- package/esm/_internal/Slider2.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +787 -79
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/avatar.js +3 -0
- package/esm/_internal/avatar.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 +3 -0
- package/esm/_internal/comment-block.js.map +1 -1
- package/esm/_internal/image-block.js +3 -0
- package/esm/_internal/image-block.js.map +1 -1
- package/esm/_internal/link-preview.js +3 -0
- package/esm/_internal/link-preview.js.map +1 -1
- package/esm/_internal/mdi.js +2 -2
- package/esm/_internal/mdi.js.map +1 -1
- package/esm/_internal/mosaic.js +3 -0
- package/esm/_internal/mosaic.js.map +1 -1
- package/esm/_internal/post-block.js +3 -0
- package/esm/_internal/post-block.js.map +1 -1
- package/esm/_internal/slider.js +2 -1
- package/esm/_internal/slider.js.map +1 -1
- package/esm/_internal/thumbnail.js +3 -0
- package/esm/_internal/thumbnail.js.map +1 -1
- package/esm/_internal/user-block.js +3 -0
- package/esm/_internal/user-block.js.map +1 -1
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/image-block/ImageBlock.tsx +1 -0
- package/src/components/thumbnail/Thumbnail.stories.tsx +42 -403
- package/src/components/thumbnail/Thumbnail.test.tsx +2 -20
- package/src/components/thumbnail/Thumbnail.tsx +45 -71
- 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/generated/List/Demos.stories.tsx +2 -0
- package/src/stories/knobs/image.ts +3 -35
- package/types.d.ts +0 -6
package/esm/_internal/mosaic.js
CHANGED
|
@@ -7,9 +7,12 @@ import 'lodash/isBoolean';
|
|
|
7
7
|
import 'lodash/isEmpty';
|
|
8
8
|
import 'lodash/kebabCase';
|
|
9
9
|
import 'lodash/noop';
|
|
10
|
+
import './constants.js';
|
|
10
11
|
import './mergeRefs.js';
|
|
11
12
|
import './Icon2.js';
|
|
12
13
|
import 'lodash/take';
|
|
13
14
|
export { M as Mosaic } from './Mosaic2.js';
|
|
15
|
+
import './clamp.js';
|
|
14
16
|
import './Thumbnail2.js';
|
|
17
|
+
import 'lodash';
|
|
15
18
|
//# sourceMappingURL=mosaic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mosaic.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mosaic.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -7,10 +7,13 @@ import 'lodash/isBoolean';
|
|
|
7
7
|
import 'lodash/isEmpty';
|
|
8
8
|
import 'lodash/kebabCase';
|
|
9
9
|
import 'lodash/noop';
|
|
10
|
+
import './constants.js';
|
|
10
11
|
import './mergeRefs.js';
|
|
11
12
|
import './Icon2.js';
|
|
12
13
|
import 'lodash/isObject';
|
|
13
14
|
export { P as PostBlock } from './PostBlock.js';
|
|
15
|
+
import './clamp.js';
|
|
14
16
|
import './Thumbnail2.js';
|
|
17
|
+
import 'lodash';
|
|
15
18
|
import './types.js';
|
|
16
19
|
//# sourceMappingURL=post-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"post-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/esm/_internal/slider.js
CHANGED
|
@@ -9,5 +9,6 @@ import 'lodash/kebabCase';
|
|
|
9
9
|
import 'lodash/noop';
|
|
10
10
|
import './InputHelper.js';
|
|
11
11
|
import './InputLabel.js';
|
|
12
|
-
export { S as Slider
|
|
12
|
+
export { S as Slider } from './Slider2.js';
|
|
13
|
+
export { c as clamp } from './clamp.js';
|
|
13
14
|
//# sourceMappingURL=slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -7,8 +7,11 @@ import 'lodash/isBoolean';
|
|
|
7
7
|
import 'lodash/isEmpty';
|
|
8
8
|
import 'lodash/kebabCase';
|
|
9
9
|
import 'lodash/noop';
|
|
10
|
+
import './constants.js';
|
|
10
11
|
import './mergeRefs.js';
|
|
11
12
|
import './Icon2.js';
|
|
13
|
+
import './clamp.js';
|
|
12
14
|
export { T as Thumbnail } from './Thumbnail2.js';
|
|
15
|
+
import 'lodash';
|
|
13
16
|
export { T as ThumbnailAspectRatio, a as ThumbnailVariant } from './types.js';
|
|
14
17
|
//# sourceMappingURL=thumbnail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumbnail.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thumbnail.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -7,9 +7,12 @@ import 'lodash/isBoolean';
|
|
|
7
7
|
import 'lodash/isEmpty';
|
|
8
8
|
import 'lodash/kebabCase';
|
|
9
9
|
import 'lodash/noop';
|
|
10
|
+
import './constants.js';
|
|
10
11
|
import './mergeRefs.js';
|
|
11
12
|
import './Avatar2.js';
|
|
12
13
|
import './Icon2.js';
|
|
14
|
+
import './clamp.js';
|
|
13
15
|
import './Thumbnail2.js';
|
|
16
|
+
import 'lodash';
|
|
14
17
|
export { U as UserBlock } from './UserBlock.js';
|
|
15
18
|
//# sourceMappingURL=user-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -74,13 +74,15 @@ export { R as RadioButton, a as RadioGroup } from './_internal/RadioGroup.js';
|
|
|
74
74
|
export { a as Select, c as SelectMultiple, b as SelectMultipleField, S as SelectVariant } from './_internal/SelectMultiple.js';
|
|
75
75
|
export { S as SideNavigation, a as SideNavigationItem } from './_internal/SideNavigationItem.js';
|
|
76
76
|
export { S as SkeletonCircle, b as SkeletonRectangle, a as SkeletonRectangleVariant, c as SkeletonTypography } from './_internal/SkeletonTypography.js';
|
|
77
|
-
export { S as Slider
|
|
77
|
+
export { S as Slider } from './_internal/Slider2.js';
|
|
78
|
+
export { c as clamp } from './_internal/clamp.js';
|
|
78
79
|
export { S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './_internal/SlideshowControls.js';
|
|
79
80
|
export { S as Switch } from './_internal/Switch2.js';
|
|
80
81
|
export { T as Table, a as TableBody, d as TableCell, c as TableCellVariant, e as TableHeader, f as TableRow, b as ThOrder } from './_internal/TableRow.js';
|
|
81
82
|
export { c as Tab, b as TabList, a as TabListLayout, d as TabPanel, T as TabProvider } from './_internal/TabPanel.js';
|
|
82
83
|
export { T as TextField } from './_internal/TextField.js';
|
|
83
84
|
export { T as Thumbnail } from './_internal/Thumbnail2.js';
|
|
85
|
+
import 'lodash';
|
|
84
86
|
export { T as ThumbnailAspectRatio, a as ThumbnailVariant } from './_internal/types.js';
|
|
85
87
|
export { T as Toolbar } from './_internal/Toolbar2.js';
|
|
86
88
|
export { T as Tooltip } from './_internal/Tooltip2.js';
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.1.9-
|
|
11
|
-
"@lumx/icons": "^2.1.9-
|
|
10
|
+
"@lumx/core": "^2.1.9-prefer-css-color-variables2",
|
|
11
|
+
"@lumx/icons": "^2.1.9-prefer-css-color-variables2",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"build:storybook": "cd storybook && ./build"
|
|
121
121
|
},
|
|
122
122
|
"sideEffects": false,
|
|
123
|
-
"version": "2.1.9-
|
|
124
|
-
"gitHead": "
|
|
123
|
+
"version": "2.1.9-prefer-css-color-variables2",
|
|
124
|
+
"gitHead": "62c4eb58224dd92429a040c9dbb9197e4a6d43ab"
|
|
125
125
|
}
|
|
@@ -118,6 +118,7 @@ export const ImageBlock: Comp<ImageBlockProps, HTMLDivElement> = forwardRef((pro
|
|
|
118
118
|
<Thumbnail
|
|
119
119
|
{...thumbnailProps}
|
|
120
120
|
className={classNames(`${CLASSNAME}__image`, thumbnailProps?.className)}
|
|
121
|
+
fillHeight={fillHeight}
|
|
121
122
|
align={align}
|
|
122
123
|
image={image}
|
|
123
124
|
size={size}
|
|
@@ -12,53 +12,30 @@ import {
|
|
|
12
12
|
Thumbnail,
|
|
13
13
|
ThumbnailVariant,
|
|
14
14
|
} from '@lumx/react';
|
|
15
|
-
import {
|
|
15
|
+
import { imageKnob, IMAGES } from '@lumx/react/stories/knobs/image';
|
|
16
|
+
import { htmlDecode } from '@lumx/react/utils/htmlDecode';
|
|
16
17
|
import { boolean, select, text } from '@storybook/addon-knobs';
|
|
17
18
|
import { enumKnob } from '@lumx/react/stories/knobs/enumKnob';
|
|
18
19
|
import { focusKnob } from '@lumx/react/stories/knobs/focusKnob';
|
|
19
20
|
import { sizeKnob } from '@lumx/react/stories/knobs/sizeKnob';
|
|
20
|
-
import { action } from '@storybook/addon-actions';
|
|
21
|
-
import classNames from 'classnames';
|
|
22
21
|
|
|
23
22
|
export default { title: 'LumX components/thumbnail/Thumbnail' };
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
export const Default = ({ theme }: any) => {
|
|
27
|
-
const alt = text('Alternative text', 'Image alt text');
|
|
28
|
-
const align = enumKnob(
|
|
29
|
-
'Alignment',
|
|
30
|
-
[undefined, Alignment.center, Alignment.left, Alignment.right] as const,
|
|
31
|
-
undefined,
|
|
32
|
-
);
|
|
33
|
-
const aspectRatio = enumKnob('Aspect ratio', [undefined, ...Object.values(AspectRatio)], undefined);
|
|
34
|
-
const crossOrigin = enumKnob('CORS', [undefined, 'anonymous', 'use-credentials'] as const, undefined);
|
|
35
|
-
const fillHeight = boolean('Fill Height', false);
|
|
36
|
-
const focusPoint = { x: focusKnob('Focus X'), y: focusKnob('Focus Y') };
|
|
37
|
-
const image = imageKnob('Image', IMAGES.landscape1);
|
|
38
|
-
const variant = select('Variant', ThumbnailVariant, ThumbnailVariant.squared);
|
|
39
|
-
const size = sizeKnob('Size', undefined);
|
|
40
|
-
const onClick = boolean('clickable?', false) ? action('onClick') : undefined;
|
|
24
|
+
export const Default = () => <Thumbnail alt="Image alt text" image={imageKnob()} size={Size.xxl} />;
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
size={size}
|
|
52
|
-
theme={theme}
|
|
53
|
-
variant={variant}
|
|
54
|
-
onClick={onClick}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
26
|
+
export const Clickable = () => <Thumbnail alt="Click me" image={imageKnob()} size={Size.xxl} onClick={console.log} />;
|
|
27
|
+
|
|
28
|
+
export const DefaultFallback = () => <Thumbnail alt="foo" image="foo" />;
|
|
29
|
+
|
|
30
|
+
export const IconFallback = () => <Thumbnail alt="foo" image="foo" fallback={mdiAbTesting} />;
|
|
31
|
+
|
|
32
|
+
export const CustomFallback = () => (
|
|
33
|
+
<Thumbnail alt="foo" image="foo" fallback={<Thumbnail alt="missing image" image="/logo.svg" />} />
|
|
34
|
+
);
|
|
58
35
|
|
|
59
36
|
export const WithBadge = () => {
|
|
60
|
-
const thumbnailSize = sizeKnob('
|
|
61
|
-
const variant = select('
|
|
37
|
+
const thumbnailSize = sizeKnob('Thumbnail size', Size.l);
|
|
38
|
+
const variant = select('Thumbnail variant', ThumbnailVariant, ThumbnailVariant.rounded);
|
|
62
39
|
const badgeColor = select('Badge color', ColorPalette, ColorPalette.primary);
|
|
63
40
|
const activateFallback = boolean('Activate fallback', false);
|
|
64
41
|
const image = imageKnob();
|
|
@@ -78,297 +55,13 @@ export const WithBadge = () => {
|
|
|
78
55
|
);
|
|
79
56
|
};
|
|
80
57
|
|
|
81
|
-
export const Clickable = () => (
|
|
82
|
-
<Thumbnail alt="Click me" image={imageKnob()} size={sizeKnob('Size', Size.xxl)} onClick={action('onClick')} />
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
export const ClickableLink = () => (
|
|
86
|
-
<Thumbnail
|
|
87
|
-
alt="Click me"
|
|
88
|
-
image={imageKnob()}
|
|
89
|
-
size={sizeKnob('Size', Size.xxl)}
|
|
90
|
-
linkProps={{ href: 'https://google.fr' }}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const CustomLinkComponent = (props: any) => (
|
|
95
|
-
<a {...props} className={classNames('custom-link-component', props.className)}>
|
|
96
|
-
{props.children}
|
|
97
|
-
</a>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
export const ClickableCustomLink = () => (
|
|
101
|
-
<Thumbnail
|
|
102
|
-
alt="Click me"
|
|
103
|
-
image={imageKnob()}
|
|
104
|
-
size={sizeKnob('Size', Size.xxl)}
|
|
105
|
-
linkAs={CustomLinkComponent}
|
|
106
|
-
linkProps={{ href: 'https://google.fr', className: 'custom-class-name' }}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
export const FillHeight = () => {
|
|
111
|
-
const parentStyle = {
|
|
112
|
-
width: 600,
|
|
113
|
-
height: 240,
|
|
114
|
-
border: '1px solid red',
|
|
115
|
-
overflow: 'hidden',
|
|
116
|
-
resize: 'both',
|
|
117
|
-
} as const;
|
|
118
|
-
return (
|
|
119
|
-
<>
|
|
120
|
-
<h2>Default</h2>
|
|
121
|
-
<div style={parentStyle}>
|
|
122
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} fillHeight />
|
|
123
|
-
</div>
|
|
124
|
-
<h2>Ratio wide</h2>
|
|
125
|
-
<div style={parentStyle}>
|
|
126
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} fillHeight aspectRatio="wide" />
|
|
127
|
-
</div>
|
|
128
|
-
<h2>Ratio vertical</h2>
|
|
129
|
-
<div style={parentStyle}>
|
|
130
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} fillHeight aspectRatio="vertical" />
|
|
131
|
-
</div>
|
|
132
|
-
<h2>Ratio free</h2>
|
|
133
|
-
<div style={parentStyle}>
|
|
134
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} fillHeight aspectRatio="free" />
|
|
135
|
-
</div>
|
|
136
|
-
</>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const Original = () => (
|
|
141
|
-
<>
|
|
142
|
-
<h1>Ratio: Original</h1>
|
|
143
|
-
<h2>Default</h2>
|
|
144
|
-
<table>
|
|
145
|
-
<tr>
|
|
146
|
-
<th>Landscape</th>
|
|
147
|
-
<th>
|
|
148
|
-
Landscape <small>(with original size)</small>
|
|
149
|
-
</th>
|
|
150
|
-
<th>Portrait</th>
|
|
151
|
-
<th>
|
|
152
|
-
Portrait <small>(with original size)</small>
|
|
153
|
-
</th>
|
|
154
|
-
</tr>
|
|
155
|
-
<tr>
|
|
156
|
-
<td>
|
|
157
|
-
<Thumbnail alt="" image={IMAGES.landscape1} />
|
|
158
|
-
</td>
|
|
159
|
-
<td>
|
|
160
|
-
<Thumbnail alt="" image={IMAGES.landscape1} imgProps={IMAGE_SIZES.landscape1} />
|
|
161
|
-
</td>
|
|
162
|
-
<td>
|
|
163
|
-
<Thumbnail alt="" image={IMAGES.portrait1} />
|
|
164
|
-
</td>
|
|
165
|
-
<td>
|
|
166
|
-
<Thumbnail alt="" image={IMAGES.portrait1} imgProps={IMAGE_SIZES.portrait1} />
|
|
167
|
-
</td>
|
|
168
|
-
</tr>
|
|
169
|
-
</table>
|
|
170
|
-
<h2>Constrained parent size</h2>
|
|
171
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
172
|
-
<div className="parent" style={{ width: 220 }}>
|
|
173
|
-
<Thumbnail alt="" image={IMAGES.landscape1} />
|
|
174
|
-
</div>
|
|
175
|
-
<div className="parent" style={{ width: 220 }}>
|
|
176
|
-
<Thumbnail alt="" image={IMAGES.portrait1} />
|
|
177
|
-
</div>
|
|
178
|
-
</FlexBox>
|
|
179
|
-
<h2>With size</h2>
|
|
180
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
181
|
-
<Thumbnail alt="" image={IMAGES.landscape1} size="xxl" />
|
|
182
|
-
<Thumbnail alt="" image={IMAGES.portrait1} size="xxl" />
|
|
183
|
-
</FlexBox>
|
|
184
|
-
<h2>With size & smaller image</h2>
|
|
185
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
186
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} size="xxl" />
|
|
187
|
-
<Thumbnail alt="" image={IMAGES.portrait1s200} size="xxl" />
|
|
188
|
-
</FlexBox>
|
|
189
|
-
<h2>With size & smaller image & fill height</h2>
|
|
190
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
191
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} size="xxl" fillHeight />
|
|
192
|
-
<Thumbnail alt="" image={IMAGES.portrait1s200} size="xxl" fillHeight />
|
|
193
|
-
</FlexBox>
|
|
194
|
-
<h2>Constrained parent size & smaller image & fill height</h2>
|
|
195
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
196
|
-
<div className="parent" style={{ width: 220 }}>
|
|
197
|
-
<Thumbnail alt="" image={IMAGES.landscape1s200} fillHeight />
|
|
198
|
-
</div>
|
|
199
|
-
<div className="parent" style={{ width: 220 }}>
|
|
200
|
-
<Thumbnail alt="" image={IMAGES.portrait1s200} fillHeight />
|
|
201
|
-
</div>
|
|
202
|
-
</FlexBox>
|
|
203
|
-
</>
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
export const Vertical = () => (
|
|
207
|
-
<>
|
|
208
|
-
<h1>Ratio: vertical</h1>
|
|
209
|
-
<h2>Default</h2>
|
|
210
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
211
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1} />
|
|
212
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1} />
|
|
213
|
-
</FlexBox>
|
|
214
|
-
<h2>Constraint parent size</h2>
|
|
215
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
216
|
-
<div className="parent" style={{ width: 220 }}>
|
|
217
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1} />
|
|
218
|
-
</div>
|
|
219
|
-
<div className="parent" style={{ width: 220 }}>
|
|
220
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1} />
|
|
221
|
-
</div>
|
|
222
|
-
</FlexBox>
|
|
223
|
-
<h2>Constraint parent size & smaller image</h2>
|
|
224
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
225
|
-
<div className="parent" style={{ width: 220 }}>
|
|
226
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1s200} />
|
|
227
|
-
</div>
|
|
228
|
-
<div className="parent" style={{ width: 220 }}>
|
|
229
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1s200} />
|
|
230
|
-
</div>
|
|
231
|
-
</FlexBox>
|
|
232
|
-
<h2>With size</h2>
|
|
233
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
234
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1} size="xxl" />
|
|
235
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1} size="xxl" />
|
|
236
|
-
</FlexBox>
|
|
237
|
-
<h2>With size & smaller image</h2>
|
|
238
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
239
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1s200} size="xxl" />
|
|
240
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1s200} size="xxl" />
|
|
241
|
-
</FlexBox>
|
|
242
|
-
<h2>With size & smaller image & fill height</h2>
|
|
243
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
244
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1s200} size="xxl" fillHeight />
|
|
245
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1s200} size="xxl" fillHeight />
|
|
246
|
-
</FlexBox>
|
|
247
|
-
<h2>Constrained parent size & smaller image & fill height</h2>
|
|
248
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
249
|
-
<div className="parent" style={{ width: 220 }}>
|
|
250
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.landscape1s200} fillHeight />
|
|
251
|
-
</div>
|
|
252
|
-
<div className="parent" style={{ width: 220 }}>
|
|
253
|
-
<Thumbnail alt="" aspectRatio="vertical" image={IMAGES.portrait1s200} fillHeight />
|
|
254
|
-
</div>
|
|
255
|
-
</FlexBox>
|
|
256
|
-
</>
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
export const Wide = () => (
|
|
260
|
-
<>
|
|
261
|
-
<h1>Ratio: wide</h1>
|
|
262
|
-
<h2>Default</h2>
|
|
263
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
264
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1} />
|
|
265
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1} />
|
|
266
|
-
</FlexBox>
|
|
267
|
-
<h2>Constrained parent size</h2>
|
|
268
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
269
|
-
<div className="parent" style={{ width: 220 }}>
|
|
270
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1} />
|
|
271
|
-
</div>
|
|
272
|
-
<div className="parent" style={{ width: 220 }}>
|
|
273
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1} />
|
|
274
|
-
</div>
|
|
275
|
-
</FlexBox>
|
|
276
|
-
<h2>Constrained parent size & smaller image</h2>
|
|
277
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
278
|
-
<div className="parent" style={{ width: 220 }}>
|
|
279
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1s200} />
|
|
280
|
-
</div>
|
|
281
|
-
<div className="parent" style={{ width: 220 }}>
|
|
282
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1s200} />
|
|
283
|
-
</div>
|
|
284
|
-
</FlexBox>
|
|
285
|
-
<h2>With size</h2>
|
|
286
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
287
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1} size="xxl" />
|
|
288
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1} size="xxl" />
|
|
289
|
-
</FlexBox>
|
|
290
|
-
<h2>With size & smaller image</h2>
|
|
291
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
292
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1s200} size="xxl" />
|
|
293
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1s200} size="xxl" />
|
|
294
|
-
</FlexBox>
|
|
295
|
-
<h2>With size & smaller image & fill height</h2>
|
|
296
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
297
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1s200} size="xxl" fillHeight />
|
|
298
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1s200} size="xxl" fillHeight />
|
|
299
|
-
</FlexBox>
|
|
300
|
-
<h2>Constrained parent size & smaller image & fill height</h2>
|
|
301
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
302
|
-
<div className="parent" style={{ width: 220 }}>
|
|
303
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.landscape1s200} fillHeight />
|
|
304
|
-
</div>
|
|
305
|
-
<div className="parent" style={{ width: 220 }}>
|
|
306
|
-
<Thumbnail alt="" aspectRatio="wide" image={IMAGES.portrait1s200} fillHeight />
|
|
307
|
-
</div>
|
|
308
|
-
</FlexBox>
|
|
309
|
-
</>
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
export const Square = () => (
|
|
313
|
-
<>
|
|
314
|
-
<h1>Ratio: square</h1>
|
|
315
|
-
<h2>Default</h2>
|
|
316
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
317
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1} />
|
|
318
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1} />
|
|
319
|
-
</FlexBox>
|
|
320
|
-
<h2>Constrained parent size</h2>
|
|
321
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
322
|
-
<div className="parent" style={{ width: 220 }}>
|
|
323
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1} />
|
|
324
|
-
</div>
|
|
325
|
-
<div className="parent" style={{ width: 220 }}>
|
|
326
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1} />
|
|
327
|
-
</div>
|
|
328
|
-
</FlexBox>
|
|
329
|
-
<h2>Constrained parent size & smaller image</h2>
|
|
330
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
331
|
-
<div className="parent" style={{ width: 220 }}>
|
|
332
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1s200} />
|
|
333
|
-
</div>
|
|
334
|
-
<div className="parent" style={{ width: 220 }}>
|
|
335
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1s200} />
|
|
336
|
-
</div>
|
|
337
|
-
</FlexBox>
|
|
338
|
-
<h2>With size</h2>
|
|
339
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
340
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1} size="xxl" />
|
|
341
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1} size="xxl" />
|
|
342
|
-
</FlexBox>
|
|
343
|
-
<h2>With size & smaller image</h2>
|
|
344
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
345
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1s200} size="xxl" />
|
|
346
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1s200} size="xxl" />
|
|
347
|
-
</FlexBox>
|
|
348
|
-
<h2>With size & smaller image & fill height</h2>
|
|
349
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
350
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1s200} size="xxl" fillHeight />
|
|
351
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1s200} size="xxl" fillHeight />
|
|
352
|
-
</FlexBox>
|
|
353
|
-
<h2>Constrained parent size & smaller image & fill height</h2>
|
|
354
|
-
<FlexBox orientation="horizontal" vAlign="center" gap="huge">
|
|
355
|
-
<div className="parent" style={{ width: 220 }}>
|
|
356
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.landscape1s200} fillHeight />
|
|
357
|
-
</div>
|
|
358
|
-
<div className="parent" style={{ width: 220 }}>
|
|
359
|
-
<Thumbnail alt="" aspectRatio="square" image={IMAGES.portrait1s200} fillHeight />
|
|
360
|
-
</div>
|
|
361
|
-
</FlexBox>
|
|
362
|
-
</>
|
|
363
|
-
);
|
|
364
|
-
|
|
365
58
|
export const ParentSizeConstraint = () => {
|
|
366
59
|
const fillHeight = boolean('Fill Height', true);
|
|
367
60
|
return Object.values(AspectRatio).map((aspectRatio) => (
|
|
368
61
|
<FlexBox key={aspectRatio} orientation="horizontal" gap="huge">
|
|
369
62
|
<h1>ratio: {aspectRatio}</h1>
|
|
370
63
|
|
|
371
|
-
<div style={{ border: '1px solid red', width:
|
|
64
|
+
<div style={{ border: '1px solid red', width: 200, height: 400, resize: 'both', overflow: 'auto' }}>
|
|
372
65
|
<Thumbnail alt="Grid" image="/demo-assets/grid.jpg" aspectRatio={aspectRatio} fillHeight={fillHeight} />
|
|
373
66
|
</div>
|
|
374
67
|
|
|
@@ -383,89 +76,35 @@ export const ParentSizeConstraint = () => {
|
|
|
383
76
|
));
|
|
384
77
|
};
|
|
385
78
|
|
|
386
|
-
export const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
79
|
+
export const Knobs = ({ theme }: any) => {
|
|
80
|
+
const alt = text('Alternative text', 'Image alt text');
|
|
81
|
+
const align = enumKnob(
|
|
82
|
+
'Alignment',
|
|
83
|
+
[undefined, Alignment.center, Alignment.left, Alignment.right] as const,
|
|
84
|
+
undefined,
|
|
85
|
+
);
|
|
86
|
+
const aspectRatio = enumKnob('Aspect ratio', [undefined, ...Object.values(AspectRatio)], undefined);
|
|
87
|
+
const crossOrigin = enumKnob('CORS', [undefined, 'anonymous', 'use-credentials'] as const, undefined);
|
|
88
|
+
const fillHeight = boolean('Fill Height', false);
|
|
89
|
+
const focusPoint = { x: focusKnob('Focus X'), y: focusKnob('Focus Y') };
|
|
90
|
+
const image = imageKnob('Image', IMAGES.landscape1);
|
|
91
|
+
const variant = select('Variant', ThumbnailVariant, ThumbnailVariant.squared);
|
|
92
|
+
const size = sizeKnob('Size', Size.xxl);
|
|
93
|
+
const onClick = boolean('clickable?', false) ? () => console.log('ok') : undefined;
|
|
94
|
+
|
|
95
|
+
return (
|
|
393
96
|
<Thumbnail
|
|
97
|
+
alt={alt}
|
|
98
|
+
align={align}
|
|
99
|
+
aspectRatio={aspectRatio}
|
|
100
|
+
crossOrigin={crossOrigin}
|
|
101
|
+
fillHeight={fillHeight}
|
|
102
|
+
focusPoint={focusPoint}
|
|
103
|
+
image={htmlDecode(image)}
|
|
104
|
+
size={size}
|
|
394
105
|
theme={theme}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
isLoading={boolean('Is loading', true)}
|
|
398
|
-
fillHeight={boolean('Fill Height', false)}
|
|
399
|
-
size={sizeKnob('Size', undefined)}
|
|
106
|
+
variant={variant}
|
|
107
|
+
onClick={onClick}
|
|
400
108
|
/>
|
|
401
|
-
</FlexBox>
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
export const ErrorFallback = () => <Thumbnail alt="foo" image="foo" />;
|
|
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);
|
|
414
|
-
const variant = select('Variant', ThumbnailVariant, undefined);
|
|
415
|
-
const base = { alt: 'foo', image: 'foo', isLoading, variant } as const;
|
|
416
|
-
const imageFallback = <img src="/logo.svg" alt="logo" />;
|
|
417
|
-
const imgProps = { width: 50, height: 50 };
|
|
418
|
-
return (
|
|
419
|
-
<>
|
|
420
|
-
<h2>Default</h2>
|
|
421
|
-
Default fallback | Custom icon fallback | Custom react node fallback
|
|
422
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
423
|
-
<Thumbnail {...base} />
|
|
424
|
-
<Thumbnail {...base} fallback={mdiAbTesting} />
|
|
425
|
-
<Thumbnail {...base} fallback={imageFallback} />
|
|
426
|
-
</FlexBox>
|
|
427
|
-
<h2>
|
|
428
|
-
With original image size <small>(50x50)</small>
|
|
429
|
-
</h2>
|
|
430
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
431
|
-
<Thumbnail {...base} imgProps={imgProps} />
|
|
432
|
-
<Thumbnail {...base} fallback={mdiAbTesting} imgProps={imgProps} />
|
|
433
|
-
<Thumbnail {...base} fallback={imageFallback} imgProps={imgProps} />
|
|
434
|
-
</FlexBox>
|
|
435
|
-
<h2>With size</h2>
|
|
436
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
437
|
-
<Thumbnail {...base} size="xl" />
|
|
438
|
-
<Thumbnail {...base} size="xl" fallback={mdiAbTesting} />
|
|
439
|
-
<Thumbnail {...base} size="xl" fallback={imageFallback} imgProps={imgProps} />
|
|
440
|
-
</FlexBox>
|
|
441
|
-
<h2>With size & ratio</h2>
|
|
442
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
443
|
-
<Thumbnail {...base} size="xl" aspectRatio="wide" />
|
|
444
|
-
<Thumbnail {...base} size="xl" aspectRatio="wide" fallback={mdiAbTesting} />
|
|
445
|
-
<Thumbnail {...base} size="xl" aspectRatio="wide" fallback={imageFallback} />
|
|
446
|
-
</FlexBox>
|
|
447
|
-
<h2>
|
|
448
|
-
With original size <small>(50x50)</small> & ratio
|
|
449
|
-
</h2>
|
|
450
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
451
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" />
|
|
452
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" fallback={mdiAbTesting} />
|
|
453
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" fallback={imageFallback} />
|
|
454
|
-
</FlexBox>
|
|
455
|
-
<h2>
|
|
456
|
-
With original size <small>(50x50)</small> & ratio & constrained parent size
|
|
457
|
-
</h2>
|
|
458
|
-
<FlexBox orientation="horizontal" gap="big">
|
|
459
|
-
<div className="parent" style={{ width: 220 }}>
|
|
460
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" />
|
|
461
|
-
</div>
|
|
462
|
-
<div className="parent" style={{ width: 220 }}>
|
|
463
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" fallback={mdiAbTesting} />
|
|
464
|
-
</div>
|
|
465
|
-
<div className="parent" style={{ width: 220 }}>
|
|
466
|
-
<Thumbnail {...base} imgProps={imgProps} aspectRatio="wide" fallback={imageFallback} />
|
|
467
|
-
</div>
|
|
468
|
-
</FlexBox>
|
|
469
|
-
</>
|
|
470
109
|
);
|
|
471
110
|
};
|