@delightui/components 0.1.105 → 0.1.107
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/README.md +104 -1
- package/dist/cjs/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/cjs/components/molecules/Modal/index.d.ts +2 -0
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/library.css +19 -6
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/esm/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/esm/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/esm/components/molecules/Modal/index.d.ts +2 -0
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/library.css +19 -6
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +108 -2
- package/docs/README.md +264 -0
- package/docs/components/atoms/ActionImage.md +119 -0
- package/docs/components/atoms/Button.md +197 -0
- package/docs/components/atoms/Checkbox.md +299 -0
- package/docs/components/atoms/CheckboxItem.md +314 -0
- package/docs/components/atoms/Chip.md +380 -0
- package/docs/components/atoms/CustomToggle.md +270 -0
- package/docs/components/atoms/Icon.md +365 -0
- package/docs/components/atoms/IconButton.md +407 -0
- package/docs/components/atoms/Image.md +448 -0
- package/docs/components/atoms/Input.md +430 -0
- package/docs/components/atoms/ListItem.md +502 -0
- package/docs/components/atoms/Password.md +472 -0
- package/docs/components/atoms/RadioButton.md +614 -0
- package/docs/components/atoms/RadioButtonItem.md +588 -0
- package/docs/components/atoms/ResponsiveComponent.md +612 -0
- package/docs/components/atoms/SelectListItem.md +609 -0
- package/docs/components/atoms/Slider.md +605 -0
- package/docs/components/atoms/Spinner.md +605 -0
- package/docs/components/atoms/Text.md +463 -0
- package/docs/components/atoms/TextArea.md +670 -0
- package/docs/components/atoms/ToastNotification.md +668 -0
- package/docs/components/atoms/Toggle.md +737 -0
- package/docs/components/atoms/ToggleButton.md +751 -0
- package/docs/components/atoms/Tooltip.md +391 -0
- package/docs/components/molecules/Accordion.md +440 -0
- package/docs/components/molecules/AccordionGroup.md +547 -0
- package/docs/components/molecules/ActionCard.md +546 -0
- package/docs/components/molecules/Breadcrumb.md +403 -0
- package/docs/components/molecules/Breadcrumbs.md +485 -0
- package/docs/components/molecules/ButtonGroup.md +383 -0
- package/docs/components/molecules/Card.md +298 -0
- package/docs/components/molecules/ChipInput.md +646 -0
- package/docs/components/molecules/ContextMenu.md +768 -0
- package/docs/components/molecules/CustomTimeSelector.md +116 -0
- package/docs/components/molecules/DatePicker.md +516 -0
- package/docs/components/molecules/DateTimeSelector.md +166 -0
- package/docs/components/molecules/FormField.md +312 -0
- package/docs/components/molecules/Grid.md +577 -0
- package/docs/components/molecules/GridItem.md +834 -0
- package/docs/components/molecules/GridList.md +244 -0
- package/docs/components/molecules/List.md +485 -0
- package/docs/components/molecules/Modal.md +470 -0
- package/docs/components/molecules/ModalFooter.md +702 -0
- package/docs/components/molecules/ModalHeader.md +756 -0
- package/docs/components/molecules/ModalProvider.md +205 -0
- package/docs/components/molecules/Nav.md +530 -0
- package/docs/components/molecules/NavItem.md +572 -0
- package/docs/components/molecules/NavLink.md +499 -0
- package/docs/components/molecules/Option.md +521 -0
- package/docs/components/molecules/Pagination.md +592 -0
- package/docs/components/molecules/PaginationNumberField.md +722 -0
- package/docs/components/molecules/Popover.md +516 -0
- package/docs/components/molecules/ProgressBar.md +624 -0
- package/docs/components/molecules/RadioGroup.md +831 -0
- package/docs/components/molecules/RepeaterList.md +185 -0
- package/docs/components/molecules/Select.md +402 -0
- package/docs/components/molecules/SortableTrigger.md +82 -0
- package/docs/components/molecules/useModal.md +379 -0
- package/docs/components/organisms/Dropzone.md +346 -0
- package/docs/components/organisms/DropzoneClear.md +135 -0
- package/docs/components/organisms/DropzoneContent.md +216 -0
- package/docs/components/organisms/DropzoneFilename.md +191 -0
- package/docs/components/organisms/DropzoneSupportedFormats.md +184 -0
- package/docs/components/organisms/DropzoneTrigger.md +209 -0
- package/docs/components/organisms/Form.md +533 -0
- package/docs/components/organisms/SlideOutPanel.md +662 -0
- package/docs/components/organisms/TabContent.md +902 -0
- package/docs/components/organisms/TabItem.md +1091 -0
- package/docs/components/organisms/Table.md +611 -0
- package/docs/components/organisms/TableBody.md +679 -0
- package/docs/components/organisms/TableCell.md +482 -0
- package/docs/components/organisms/TableHeader.md +513 -0
- package/docs/components/organisms/TableHeaderCell.md +661 -0
- package/docs/components/organisms/TableRow.md +715 -0
- package/docs/components/organisms/Tabs.md +1330 -0
- package/docs/components/utils/ConditionalView.md +568 -0
- package/docs/components/utils/RenderStateView.md +726 -0
- package/docs/components/utils/WrapTextNodes.md +614 -0
- package/package.json +3 -2
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
|
|
3
|
+
A versatile image component that extends the standard HTML img element with enhanced features including fallback support, different fit options, loading states, and aspect ratio control. This component provides a robust solution for displaying images with proper error handling and responsive behavior.
|
|
4
|
+
|
|
5
|
+
## Aliases
|
|
6
|
+
|
|
7
|
+
- Image
|
|
8
|
+
- Img
|
|
9
|
+
- Picture
|
|
10
|
+
|
|
11
|
+
## Props Breakdown
|
|
12
|
+
|
|
13
|
+
**Extends:** `ImgHTMLAttributes<HTMLImageElement>`
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Required | Description |
|
|
16
|
+
|------|------|---------|----------|-------------|
|
|
17
|
+
| `src` | `string` | `undefined` | Yes | The URL of the image to display |
|
|
18
|
+
| `alt` | `string` | `undefined` | Yes | Alternative text for accessibility |
|
|
19
|
+
| `fallback` | `string` | `undefined` | No | The URL of the image to display if the image fails to load |
|
|
20
|
+
| `fit` | `'Fit' \| 'Fill' \| 'Crop'` | `'Fit'` | No | The fit option for the image |
|
|
21
|
+
| `onLoad` | `() => void` | `undefined` | No | Callback function when the image has loaded |
|
|
22
|
+
| `onError` | `(error: SyntheticEvent<HTMLImageElement>) => void` | `undefined` | No | Callback function when an error occurs while loading the image |
|
|
23
|
+
| `showLoading` | `boolean` | `false` | No | Flag to show a loading indicator for the image |
|
|
24
|
+
| `className` | `string` | `undefined` | No | Additional class for styling |
|
|
25
|
+
| `aspectRatio` | `string` | `natural aspect ratio` | No | The aspect ratio of the image |
|
|
26
|
+
| `width` | `string \| number` | `undefined` | No | Width of the image |
|
|
27
|
+
| `height` | `string \| number` | `undefined` | No | Height of the image |
|
|
28
|
+
| `loading` | `'eager' \| 'lazy'` | `undefined` | No | Loading behavior of the image |
|
|
29
|
+
| `decoding` | `'sync' \| 'async' \| 'auto'` | `undefined` | No | Decoding behavior of the image |
|
|
30
|
+
|
|
31
|
+
Plus all standard HTML img attributes (crossOrigin, referrerPolicy, sizes, srcSet, useMap, etc.).
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Basic Image
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { Image } from '@delightui/components';
|
|
39
|
+
|
|
40
|
+
function BasicImageExample() {
|
|
41
|
+
return (
|
|
42
|
+
<Image
|
|
43
|
+
src="https://via.placeholder.com/300x200"
|
|
44
|
+
alt="Placeholder image"
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Image with Fallback
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Image } from '@delightui/components';
|
|
54
|
+
|
|
55
|
+
function FallbackImageExample() {
|
|
56
|
+
return (
|
|
57
|
+
<Image
|
|
58
|
+
src="https://invalid-url.com/image.jpg"
|
|
59
|
+
alt="Failed image"
|
|
60
|
+
fallback="https://via.placeholder.com/300x200?text=Fallback"
|
|
61
|
+
onError={(error) => console.log('Image failed to load:', error)}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Different Fit Options
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { Image } from '@delightui/components';
|
|
71
|
+
|
|
72
|
+
function FitOptionsExample() {
|
|
73
|
+
const imageUrl = "https://via.placeholder.com/400x300";
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div style={{ display: 'flex', gap: '16px', flexWrap: 'wrap' }}>
|
|
77
|
+
<div>
|
|
78
|
+
<h4>Fit (Default)</h4>
|
|
79
|
+
<div style={{ width: '200px', height: '150px', border: '1px solid #ccc' }}>
|
|
80
|
+
<Image
|
|
81
|
+
src={imageUrl}
|
|
82
|
+
alt="Fit example"
|
|
83
|
+
fit="Fit"
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div>
|
|
89
|
+
<h4>Fill</h4>
|
|
90
|
+
<div style={{ width: '200px', height: '150px', border: '1px solid #ccc' }}>
|
|
91
|
+
<Image
|
|
92
|
+
src={imageUrl}
|
|
93
|
+
alt="Fill example"
|
|
94
|
+
fit="Fill"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div>
|
|
100
|
+
<h4>Crop</h4>
|
|
101
|
+
<div style={{ width: '200px', height: '150px', border: '1px solid #ccc' }}>
|
|
102
|
+
<Image
|
|
103
|
+
src={imageUrl}
|
|
104
|
+
alt="Crop example"
|
|
105
|
+
fit="Crop"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Aspect Ratio Control
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { Image } from '@delightui/components';
|
|
118
|
+
|
|
119
|
+
function AspectRatioExample() {
|
|
120
|
+
const imageUrl = "https://via.placeholder.com/400x300";
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div style={{ display: 'flex', gap: '16px', flexWrap: 'wrap' }}>
|
|
124
|
+
<div>
|
|
125
|
+
<h4>16:9 Aspect Ratio</h4>
|
|
126
|
+
<Image
|
|
127
|
+
src={imageUrl}
|
|
128
|
+
alt="16:9 aspect ratio"
|
|
129
|
+
aspectRatio="16/9"
|
|
130
|
+
style={{ width: '300px' }}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div>
|
|
135
|
+
<h4>1:1 Aspect Ratio</h4>
|
|
136
|
+
<Image
|
|
137
|
+
src={imageUrl}
|
|
138
|
+
alt="1:1 aspect ratio"
|
|
139
|
+
aspectRatio="1/1"
|
|
140
|
+
style={{ width: '200px' }}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div>
|
|
145
|
+
<h4>4:3 Aspect Ratio</h4>
|
|
146
|
+
<Image
|
|
147
|
+
src={imageUrl}
|
|
148
|
+
alt="4:3 aspect ratio"
|
|
149
|
+
aspectRatio="4/3"
|
|
150
|
+
style={{ width: '240px' }}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Loading States
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { Image, Spinner } from '@delightui/components';
|
|
162
|
+
|
|
163
|
+
function LoadingImageExample() {
|
|
164
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
165
|
+
|
|
166
|
+
const handleLoad = () => {
|
|
167
|
+
setIsLoading(false);
|
|
168
|
+
console.log('Image loaded successfully');
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const handleError = (error: any) => {
|
|
172
|
+
setIsLoading(false);
|
|
173
|
+
console.error('Image failed to load:', error);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div style={{ position: 'relative', width: '300px', height: '200px' }}>
|
|
178
|
+
{isLoading && (
|
|
179
|
+
<div style={{
|
|
180
|
+
position: 'absolute',
|
|
181
|
+
top: 0,
|
|
182
|
+
left: 0,
|
|
183
|
+
right: 0,
|
|
184
|
+
bottom: 0,
|
|
185
|
+
display: 'flex',
|
|
186
|
+
alignItems: 'center',
|
|
187
|
+
justifyContent: 'center',
|
|
188
|
+
backgroundColor: '#f5f5f5'
|
|
189
|
+
}}>
|
|
190
|
+
<Spinner size="Medium" />
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
<Image
|
|
195
|
+
src="https://via.placeholder.com/300x200"
|
|
196
|
+
alt="Loading example"
|
|
197
|
+
onLoad={handleLoad}
|
|
198
|
+
onError={handleError}
|
|
199
|
+
showLoading={true}
|
|
200
|
+
style={{ opacity: isLoading ? 0 : 1, transition: 'opacity 0.3s' }}
|
|
201
|
+
/>
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Lazy Loading
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import { Image } from '@delightui/components';
|
|
211
|
+
|
|
212
|
+
function LazyLoadingExample() {
|
|
213
|
+
const images = [
|
|
214
|
+
{ id: 1, url: 'https://via.placeholder.com/300x200/FF0000/FFFFFF?text=Image+1' },
|
|
215
|
+
{ id: 2, url: 'https://via.placeholder.com/300x200/00FF00/FFFFFF?text=Image+2' },
|
|
216
|
+
{ id: 3, url: 'https://via.placeholder.com/300x200/0000FF/FFFFFF?text=Image+3' },
|
|
217
|
+
{ id: 4, url: 'https://via.placeholder.com/300x200/FFFF00/000000?text=Image+4' },
|
|
218
|
+
{ id: 5, url: 'https://via.placeholder.com/300x200/FF00FF/FFFFFF?text=Image+5' }
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '100vh' }}>
|
|
223
|
+
{images.map((image) => (
|
|
224
|
+
<div key={image.id}>
|
|
225
|
+
<h3>Image {image.id}</h3>
|
|
226
|
+
<Image
|
|
227
|
+
src={image.url}
|
|
228
|
+
alt={`Lazy loaded image ${image.id}`}
|
|
229
|
+
loading="lazy"
|
|
230
|
+
onLoad={() => console.log(`Image ${image.id} loaded`)}
|
|
231
|
+
/>
|
|
232
|
+
</div>
|
|
233
|
+
))}
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Gallery Example
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
import { Image } from '@delightui/components';
|
|
243
|
+
|
|
244
|
+
function GalleryExample() {
|
|
245
|
+
const [selectedImage, setSelectedImage] = useState<string | null>(null);
|
|
246
|
+
|
|
247
|
+
const images = [
|
|
248
|
+
'https://via.placeholder.com/300x200/FF6B6B/FFFFFF?text=Photo+1',
|
|
249
|
+
'https://via.placeholder.com/300x200/4ECDC4/FFFFFF?text=Photo+2',
|
|
250
|
+
'https://via.placeholder.com/300x200/45B7D1/FFFFFF?text=Photo+3',
|
|
251
|
+
'https://via.placeholder.com/300x200/96CEB4/FFFFFF?text=Photo+4',
|
|
252
|
+
'https://via.placeholder.com/300x200/FFEAA7/000000?text=Photo+5',
|
|
253
|
+
'https://via.placeholder.com/300x200/DDA0DD/FFFFFF?text=Photo+6'
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div>
|
|
258
|
+
<div style={{
|
|
259
|
+
display: 'grid',
|
|
260
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(150px, 1fr))',
|
|
261
|
+
gap: '16px',
|
|
262
|
+
marginBottom: '24px'
|
|
263
|
+
}}>
|
|
264
|
+
{images.map((src, index) => (
|
|
265
|
+
<Image
|
|
266
|
+
key={index}
|
|
267
|
+
src={src}
|
|
268
|
+
alt={`Gallery image ${index + 1}`}
|
|
269
|
+
fit="Crop"
|
|
270
|
+
aspectRatio="1/1"
|
|
271
|
+
style={{ cursor: 'pointer' }}
|
|
272
|
+
onClick={() => setSelectedImage(src)}
|
|
273
|
+
/>
|
|
274
|
+
))}
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
{selectedImage && (
|
|
278
|
+
<div style={{
|
|
279
|
+
position: 'fixed',
|
|
280
|
+
top: 0,
|
|
281
|
+
left: 0,
|
|
282
|
+
right: 0,
|
|
283
|
+
bottom: 0,
|
|
284
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
285
|
+
display: 'flex',
|
|
286
|
+
alignItems: 'center',
|
|
287
|
+
justifyContent: 'center',
|
|
288
|
+
zIndex: 1000
|
|
289
|
+
}} onClick={() => setSelectedImage(null)}>
|
|
290
|
+
<Image
|
|
291
|
+
src={selectedImage}
|
|
292
|
+
alt="Selected image"
|
|
293
|
+
style={{ maxWidth: '90%', maxHeight: '90%' }}
|
|
294
|
+
/>
|
|
295
|
+
</div>
|
|
296
|
+
)}
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Responsive Images
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { Image } from '@delightui/components';
|
|
306
|
+
|
|
307
|
+
function ResponsiveImageExample() {
|
|
308
|
+
return (
|
|
309
|
+
<div style={{ maxWidth: '800px' }}>
|
|
310
|
+
<h3>Responsive Image</h3>
|
|
311
|
+
<Image
|
|
312
|
+
src="https://via.placeholder.com/800x400"
|
|
313
|
+
alt="Responsive image"
|
|
314
|
+
style={{
|
|
315
|
+
width: '100%',
|
|
316
|
+
height: 'auto',
|
|
317
|
+
maxWidth: '100%'
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
|
|
321
|
+
<h3>Fixed Aspect Ratio Responsive</h3>
|
|
322
|
+
<Image
|
|
323
|
+
src="https://via.placeholder.com/800x400"
|
|
324
|
+
alt="Fixed aspect ratio responsive"
|
|
325
|
+
aspectRatio="16/9"
|
|
326
|
+
fit="Crop"
|
|
327
|
+
style={{ width: '100%' }}
|
|
328
|
+
/>
|
|
329
|
+
</div>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Error Handling
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { Image, Text } from '@delightui/components';
|
|
338
|
+
|
|
339
|
+
function ErrorHandlingExample() {
|
|
340
|
+
const [imageError, setImageError] = useState<string | null>(null);
|
|
341
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
342
|
+
|
|
343
|
+
const handleError = (error: any) => {
|
|
344
|
+
setImageError('Failed to load image');
|
|
345
|
+
console.error('Image error:', error);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const handleLoad = () => {
|
|
349
|
+
setImageLoaded(true);
|
|
350
|
+
setImageError(null);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<div>
|
|
355
|
+
<Image
|
|
356
|
+
src="https://invalid-image-url.com/nonexistent.jpg"
|
|
357
|
+
alt="This will fail to load"
|
|
358
|
+
fallback="https://via.placeholder.com/300x200/FF0000/FFFFFF?text=Error+Fallback"
|
|
359
|
+
onError={handleError}
|
|
360
|
+
onLoad={handleLoad}
|
|
361
|
+
/>
|
|
362
|
+
|
|
363
|
+
{imageError && (
|
|
364
|
+
<Text color="error" style={{ marginTop: '8px' }}>
|
|
365
|
+
{imageError}
|
|
366
|
+
</Text>
|
|
367
|
+
)}
|
|
368
|
+
|
|
369
|
+
{imageLoaded && (
|
|
370
|
+
<Text color="success" style={{ marginTop: '8px' }}>
|
|
371
|
+
Image loaded successfully!
|
|
372
|
+
</Text>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Image with Custom Styling
|
|
380
|
+
|
|
381
|
+
```tsx
|
|
382
|
+
import { Image } from '@delightui/components';
|
|
383
|
+
|
|
384
|
+
function CustomStyledImageExample() {
|
|
385
|
+
return (
|
|
386
|
+
<div style={{ display: 'flex', gap: '16px', flexWrap: 'wrap' }}>
|
|
387
|
+
<Image
|
|
388
|
+
src="https://via.placeholder.com/200x200"
|
|
389
|
+
alt="Rounded image"
|
|
390
|
+
className="rounded-image"
|
|
391
|
+
style={{ borderRadius: '50%' }}
|
|
392
|
+
/>
|
|
393
|
+
|
|
394
|
+
<Image
|
|
395
|
+
src="https://via.placeholder.com/200x200"
|
|
396
|
+
alt="Border image"
|
|
397
|
+
style={{
|
|
398
|
+
border: '4px solid #007bff',
|
|
399
|
+
borderRadius: '8px',
|
|
400
|
+
boxShadow: '0 4px 8px rgba(0,0,0,0.1)'
|
|
401
|
+
}}
|
|
402
|
+
/>
|
|
403
|
+
|
|
404
|
+
<Image
|
|
405
|
+
src="https://via.placeholder.com/200x200"
|
|
406
|
+
alt="Grayscale image"
|
|
407
|
+
style={{
|
|
408
|
+
filter: 'grayscale(100%)',
|
|
409
|
+
transition: 'filter 0.3s ease'
|
|
410
|
+
}}
|
|
411
|
+
onMouseEnter={(e) => {
|
|
412
|
+
e.currentTarget.style.filter = 'grayscale(0%)';
|
|
413
|
+
}}
|
|
414
|
+
onMouseLeave={(e) => {
|
|
415
|
+
e.currentTarget.style.filter = 'grayscale(100%)';
|
|
416
|
+
}}
|
|
417
|
+
/>
|
|
418
|
+
</div>
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Performance Optimized
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
import { Image } from '@delightui/components';
|
|
427
|
+
|
|
428
|
+
function PerformanceOptimizedExample() {
|
|
429
|
+
return (
|
|
430
|
+
<div>
|
|
431
|
+
<h3>Optimized Image Loading</h3>
|
|
432
|
+
<Image
|
|
433
|
+
src="https://via.placeholder.com/800x600"
|
|
434
|
+
alt="High resolution image"
|
|
435
|
+
loading="lazy"
|
|
436
|
+
decoding="async"
|
|
437
|
+
width={400}
|
|
438
|
+
height={300}
|
|
439
|
+
style={{
|
|
440
|
+
objectFit: 'cover',
|
|
441
|
+
transition: 'transform 0.3s ease'
|
|
442
|
+
}}
|
|
443
|
+
onLoad={() => console.log('Image loaded and decoded')}
|
|
444
|
+
/>
|
|
445
|
+
</div>
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
```
|