@amedia/brick-mcp 0.0.2 → 0.1.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/data/components-metadata.json +28 -28
- package/data/tokens-documentation.json +1 -1
- package/data/tokens.json +4848 -128
- package/dist/data/components/brick-actions.md +59 -0
- package/dist/data/components/brick-alt-teaser.md +264 -0
- package/dist/data/components/brick-avatar.md +299 -0
- package/dist/data/components/brick-button.md +373 -0
- package/dist/data/components/brick-card.md +359 -0
- package/dist/data/components/brick-carousel.md +355 -0
- package/dist/data/components/brick-classnames.md +147 -0
- package/dist/data/components/brick-countdown.md +180 -0
- package/dist/data/components/brick-dialog.md +458 -0
- package/dist/data/components/brick-fonts.md +389 -0
- package/dist/data/components/brick-helloworld.md +228 -0
- package/dist/data/components/brick-icon.md +274 -0
- package/dist/data/components/brick-icons.md +570 -0
- package/dist/data/components/brick-illustrations.md +604 -0
- package/dist/data/components/brick-image.md +361 -0
- package/dist/data/components/brick-input.md +557 -0
- package/dist/data/components/brick-mcp.json +6 -0
- package/dist/data/components/brick-nifs.md +164 -0
- package/dist/data/components/brick-pill.json +6 -0
- package/dist/data/components/brick-player.json +7 -0
- package/dist/data/components/brick-published.json +7 -0
- package/dist/data/components/brick-share.json +7 -0
- package/dist/data/components/brick-stepper.json +7 -0
- package/dist/data/components/brick-tab.json +7 -0
- package/dist/data/components/brick-tabs.json +9 -0
- package/dist/data/components/brick-tag.json +7 -0
- package/dist/data/components/brick-teaser-player.json +9 -0
- package/dist/data/components/brick-teaser-reels.json +9 -0
- package/dist/data/components/brick-teaser.json +9 -0
- package/dist/data/components/brick-template.json +9 -0
- package/dist/data/components/brick-textarea.json +7 -0
- package/dist/data/components/brick-themes.json +6 -0
- package/dist/data/components/brick-toast.json +9 -0
- package/dist/data/components/brick-toggle.json +7 -0
- package/dist/data/components/brick-tokens.json +8 -0
- package/dist/data/components/brick-tooltip.json +7 -0
- package/dist/data/components-metadata.json +228 -0
- package/dist/data/tokens-documentation.json +7 -0
- package/dist/data/tokens.json +4976 -0
- package/dist/http.js +314 -0
- package/dist/http.js.map +7 -0
- package/dist/index.js +26 -37
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/scripts/generate-data.js +15 -47
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-image
|
|
3
|
+
version: 6.0.5
|
|
4
|
+
selector: brick-image-v6
|
|
5
|
+
category: Media
|
|
6
|
+
tags:
|
|
7
|
+
[image, responsive, lazy-loading, srcset, performance, media, picture, img]
|
|
8
|
+
use_cases:
|
|
9
|
+
[
|
|
10
|
+
hero-section,
|
|
11
|
+
article-images,
|
|
12
|
+
product-listing,
|
|
13
|
+
image-gallery,
|
|
14
|
+
thumbnail,
|
|
15
|
+
teaser,
|
|
16
|
+
card,
|
|
17
|
+
banner,
|
|
18
|
+
media-content,
|
|
19
|
+
responsive-images,
|
|
20
|
+
]
|
|
21
|
+
related: [brick-button, brick-link, brick-card]
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Brick Image
|
|
25
|
+
|
|
26
|
+
A responsive image component that wraps the native `<img>` element with support for modern image loading features including lazy loading, responsive images via srcset/sizes, and performance optimizations.
|
|
27
|
+
|
|
28
|
+
## Key Capabilities
|
|
29
|
+
|
|
30
|
+
- Native browser lazy loading with configurable `loading` attribute
|
|
31
|
+
- Responsive image support through `srcset` and `sizes` attributes
|
|
32
|
+
- Performance optimizations via `fetchpriority` and `decoding` attributes
|
|
33
|
+
- Aspect ratio preservation using CSS custom properties
|
|
34
|
+
- Server-side rendering support with `renderBrickImage()` function
|
|
35
|
+
- Customizable styling through CSS variables (object-fit, dimensions, positioning)
|
|
36
|
+
|
|
37
|
+
## Props/Attributes
|
|
38
|
+
|
|
39
|
+
| Attribute | Type | Default | Required | Description |
|
|
40
|
+
| --------------------- | ----------------------------- | -------- | -------- | ----------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `data-src` | string | - | yes | The image source URL |
|
|
42
|
+
| `data-srcset` | string | - | no | Responsive image source set (e.g., "image-400.jpg 400w, image-800.jpg 800w") |
|
|
43
|
+
| `data-srcsize` | string | - | no | Specific size for the src attribute (alternative to default sizing) |
|
|
44
|
+
| `data-sizes` | string | - | no | Media query conditions for responsive image selection (e.g., "(min-width: 800px) 800px, 100vw") |
|
|
45
|
+
| `data-width` | string | - | no | Intrinsic width of the image (sets width attribute on img) |
|
|
46
|
+
| `data-height` | string | - | no | Intrinsic height of the image (sets height attribute on img) |
|
|
47
|
+
| `data-alt-text` | string | `""` | no | Alternative text for accessibility |
|
|
48
|
+
| `data-loading` | `"eager" \| "lazy"` | `"lazy"` | no | Browser loading strategy |
|
|
49
|
+
| `data-fetch-priority` | `"high" \| "low" \| "auto"` | `"auto"` | no | Resource fetch priority hint |
|
|
50
|
+
| `data-decoding` | `"async" \| "sync" \| "auto"` | `"auto"` | no | Image decoding hint |
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
### Basic Image
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<brick-image-v6
|
|
58
|
+
data-src="https://example.com/image.jpg"
|
|
59
|
+
data-alt-text="A beautiful landscape"
|
|
60
|
+
>
|
|
61
|
+
</brick-image-v6>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Responsive Image with Srcset
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<brick-image-v6
|
|
68
|
+
data-src="https://example.com/image-800.jpg"
|
|
69
|
+
data-srcset="https://example.com/image-400.jpg 400w,
|
|
70
|
+
https://example.com/image-800.jpg 800w,
|
|
71
|
+
https://example.com/image-1200.jpg 1200w"
|
|
72
|
+
data-sizes="(min-width: 1200px) 1200px, (min-width: 800px) 800px, 100vw"
|
|
73
|
+
data-alt-text="Product photo"
|
|
74
|
+
>
|
|
75
|
+
</brick-image-v6>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Image with Aspect Ratio
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<brick-image-v6
|
|
82
|
+
data-src="https://example.com/image.jpg"
|
|
83
|
+
data-width="1600"
|
|
84
|
+
data-height="900"
|
|
85
|
+
data-alt-text="16:9 aspect ratio image"
|
|
86
|
+
>
|
|
87
|
+
</brick-image-v6>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Eager Loading for Above-the-Fold Images
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<brick-image-v6
|
|
94
|
+
data-src="https://example.com/hero.jpg"
|
|
95
|
+
data-srcset="https://example.com/hero-800.jpg 800w,
|
|
96
|
+
https://example.com/hero-1600.jpg 1600w"
|
|
97
|
+
data-sizes="100vw"
|
|
98
|
+
data-loading="eager"
|
|
99
|
+
data-fetch-priority="high"
|
|
100
|
+
data-alt-text="Hero image"
|
|
101
|
+
>
|
|
102
|
+
</brick-image-v6>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Lazy Loading for Below-the-Fold Images
|
|
106
|
+
|
|
107
|
+
```html
|
|
108
|
+
<brick-image-v6
|
|
109
|
+
data-src="https://example.com/thumbnail.jpg"
|
|
110
|
+
data-loading="lazy"
|
|
111
|
+
data-decoding="async"
|
|
112
|
+
data-alt-text="Thumbnail image"
|
|
113
|
+
>
|
|
114
|
+
</brick-image-v6>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Framework Integration
|
|
118
|
+
|
|
119
|
+
### Svelte
|
|
120
|
+
|
|
121
|
+
```svelte
|
|
122
|
+
<script>
|
|
123
|
+
let imageSrc = 'https://example.com/image.jpg';
|
|
124
|
+
let altText = 'Dynamic image';
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<brick-image-v6
|
|
128
|
+
data-src={imageSrc}
|
|
129
|
+
data-alt-text={altText}
|
|
130
|
+
data-loading="lazy"
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### React
|
|
135
|
+
|
|
136
|
+
```jsx
|
|
137
|
+
function MyComponent() {
|
|
138
|
+
return (
|
|
139
|
+
<brick-image-v6
|
|
140
|
+
data-src="https://example.com/image.jpg"
|
|
141
|
+
data-srcset="https://example.com/image-400.jpg 400w, https://example.com/image-800.jpg 800w"
|
|
142
|
+
data-sizes="(min-width: 800px) 800px, 100vw"
|
|
143
|
+
data-alt-text="Product image"
|
|
144
|
+
data-loading="lazy"
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Programmatic Usage
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
import { BrickImage } from '@amedia/brick-image';
|
|
154
|
+
|
|
155
|
+
const imageElement = document.createElement('brick-image-v6');
|
|
156
|
+
imageElement.dataSrc = 'https://example.com/image.jpg';
|
|
157
|
+
imageElement.dataAltText = 'Programmatically created image';
|
|
158
|
+
imageElement.dataLoading = 'lazy';
|
|
159
|
+
document.body.appendChild(imageElement);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Server-Side Rendering
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
import { renderBrickImage } from '@amedia/brick-image/template';
|
|
166
|
+
|
|
167
|
+
const html = renderBrickImage({
|
|
168
|
+
dataSrc: 'https://example.com/image.jpg',
|
|
169
|
+
dataSrcset:
|
|
170
|
+
'https://example.com/image-400.jpg 400w, https://example.com/image-800.jpg 800w',
|
|
171
|
+
dataSizes: '(min-width: 800px) 800px, 100vw',
|
|
172
|
+
dataWidth: '1600',
|
|
173
|
+
dataHeight: '900',
|
|
174
|
+
dataAltText: 'Server-rendered image',
|
|
175
|
+
dataLoading: 'lazy',
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Returns:
|
|
179
|
+
// <brick-image-v6 is-rendered brick-component="brick-image" class="..." data-src="..." ...>
|
|
180
|
+
// <img src="..." srcset="..." sizes="..." width="1600" height="900" alt="..." loading="lazy" class="..." style="--brick-image-ratio: 1600 / 900;">
|
|
181
|
+
// </brick-image-v6>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Styling with CSS Variables
|
|
185
|
+
|
|
186
|
+
The component exposes several CSS variables for customization:
|
|
187
|
+
|
|
188
|
+
```css
|
|
189
|
+
brick-image-v6 {
|
|
190
|
+
/* Dimensions */
|
|
191
|
+
--brick-image-width: 100%;
|
|
192
|
+
--brick-image-height: auto;
|
|
193
|
+
--brick-image-maxwidth: 100%;
|
|
194
|
+
--brick-image-maxheight: auto;
|
|
195
|
+
|
|
196
|
+
/* Object positioning and fit */
|
|
197
|
+
--brick-image-objectfit: cover;
|
|
198
|
+
--brick-image-objectposition: center;
|
|
199
|
+
|
|
200
|
+
/* Background (visible while loading) */
|
|
201
|
+
--brick-image-color-bg: transparent;
|
|
202
|
+
|
|
203
|
+
/* Sizes attribute (alternative to data-sizes) */
|
|
204
|
+
--brick-image-sizes: (min-width: 800px) 800px, 100vw;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Example: Custom Styling
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
<style>
|
|
212
|
+
.hero-image {
|
|
213
|
+
--brick-image-width: 100%;
|
|
214
|
+
--brick-image-height: 60vh;
|
|
215
|
+
--brick-image-objectfit: cover;
|
|
216
|
+
--brick-image-objectposition: center top;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.thumbnail {
|
|
220
|
+
--brick-image-width: 200px;
|
|
221
|
+
--brick-image-height: 200px;
|
|
222
|
+
--brick-image-objectfit: contain;
|
|
223
|
+
--brick-image-color-bg: #f0f0f0;
|
|
224
|
+
}
|
|
225
|
+
</style>
|
|
226
|
+
|
|
227
|
+
<brick-image-v6
|
|
228
|
+
class="hero-image"
|
|
229
|
+
data-src="https://example.com/hero.jpg"
|
|
230
|
+
data-alt-text="Hero image"
|
|
231
|
+
>
|
|
232
|
+
</brick-image-v6>
|
|
233
|
+
|
|
234
|
+
<brick-image-v6
|
|
235
|
+
class="thumbnail"
|
|
236
|
+
data-src="https://example.com/thumb.jpg"
|
|
237
|
+
data-alt-text="Thumbnail"
|
|
238
|
+
>
|
|
239
|
+
</brick-image-v6>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Accessibility
|
|
243
|
+
|
|
244
|
+
- Always provide meaningful `data-alt-text` for screen readers
|
|
245
|
+
- For decorative images, use empty alt text: `data-alt-text=""`
|
|
246
|
+
- Aspect ratio preservation prevents layout shift (CLS) when `data-width` and `data-height` are provided
|
|
247
|
+
- Native lazy loading reduces initial page load for better user experience
|
|
248
|
+
|
|
249
|
+
## Common Patterns
|
|
250
|
+
|
|
251
|
+
### Hero Section Image
|
|
252
|
+
|
|
253
|
+
Large, above-the-fold images should use eager loading with high priority:
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<brick-image-v6
|
|
257
|
+
data-src="https://example.com/hero-1600.jpg"
|
|
258
|
+
data-srcset="https://example.com/hero-800.jpg 800w,
|
|
259
|
+
https://example.com/hero-1600.jpg 1600w,
|
|
260
|
+
https://example.com/hero-2400.jpg 2400w"
|
|
261
|
+
data-sizes="100vw"
|
|
262
|
+
data-width="1600"
|
|
263
|
+
data-height="600"
|
|
264
|
+
data-loading="eager"
|
|
265
|
+
data-fetch-priority="high"
|
|
266
|
+
data-alt-text="Welcome to our store"
|
|
267
|
+
style="--brick-image-objectfit: cover; --brick-image-height: 60vh;"
|
|
268
|
+
>
|
|
269
|
+
</brick-image-v6>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Product Listing Thumbnails
|
|
273
|
+
|
|
274
|
+
Grid of images with consistent aspect ratios:
|
|
275
|
+
|
|
276
|
+
```html
|
|
277
|
+
<brick-image-v6
|
|
278
|
+
data-src="https://example.com/product.jpg"
|
|
279
|
+
data-srcset="https://example.com/product-400.jpg 400w,
|
|
280
|
+
https://example.com/product-800.jpg 800w"
|
|
281
|
+
data-sizes="(min-width: 768px) 33vw, 50vw"
|
|
282
|
+
data-width="800"
|
|
283
|
+
data-height="800"
|
|
284
|
+
data-loading="lazy"
|
|
285
|
+
data-decoding="async"
|
|
286
|
+
data-alt-text="Product name"
|
|
287
|
+
style="--brick-image-objectfit: cover;"
|
|
288
|
+
>
|
|
289
|
+
</brick-image-v6>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Article Images
|
|
293
|
+
|
|
294
|
+
Content images with natural aspect ratios:
|
|
295
|
+
|
|
296
|
+
```html
|
|
297
|
+
<brick-image-v6
|
|
298
|
+
data-src="https://example.com/article-image.jpg"
|
|
299
|
+
data-srcset="https://example.com/article-image-600.jpg 600w,
|
|
300
|
+
https://example.com/article-image-1200.jpg 1200w"
|
|
301
|
+
data-sizes="(min-width: 1200px) 800px, (min-width: 768px) 600px, 100vw"
|
|
302
|
+
data-width="1200"
|
|
303
|
+
data-height="800"
|
|
304
|
+
data-loading="lazy"
|
|
305
|
+
data-alt-text="Description of the image content"
|
|
306
|
+
>
|
|
307
|
+
</brick-image-v6>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Using CSS Variable for Sizes
|
|
311
|
+
|
|
312
|
+
Instead of `data-sizes`, you can use the CSS variable approach:
|
|
313
|
+
|
|
314
|
+
```html
|
|
315
|
+
<style>
|
|
316
|
+
.responsive-image {
|
|
317
|
+
--brick-image-sizes: (min-width: 1024px) 800px, (min-width: 768px) 600px,
|
|
318
|
+
100vw;
|
|
319
|
+
}
|
|
320
|
+
</style>
|
|
321
|
+
|
|
322
|
+
<brick-image-v6
|
|
323
|
+
class="responsive-image"
|
|
324
|
+
data-src="https://example.com/image.jpg"
|
|
325
|
+
data-srcset="https://example.com/image-600.jpg 600w,
|
|
326
|
+
https://example.com/image-800.jpg 800w,
|
|
327
|
+
https://example.com/image-1200.jpg 1200w"
|
|
328
|
+
data-alt-text="Responsive image"
|
|
329
|
+
>
|
|
330
|
+
</brick-image-v6>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Technical Details
|
|
334
|
+
|
|
335
|
+
- **Custom Element**: `brick-image-v6`
|
|
336
|
+
- **Base Class**: BrickElement (from @amedia/brick-template)
|
|
337
|
+
- **Dependencies**: @amedia/brick-tokens, @amedia/brick-template
|
|
338
|
+
- **Renders as**: Custom element wrapping an `<img>` tag
|
|
339
|
+
- **Browser Support**: Modern browsers with Web Components support
|
|
340
|
+
- **Package**: @amedia/brick-image
|
|
341
|
+
|
|
342
|
+
## Important Notes
|
|
343
|
+
|
|
344
|
+
- The component does NOT generate srcset automatically. You must provide the correct `data-srcset` value for responsive images.
|
|
345
|
+
- Image URLs are used as-is; no automatic resizing or transformation is applied by the component.
|
|
346
|
+
- When both `data-width` and `data-height` are provided, the component sets the `aspect-ratio` CSS property for browsers that support it.
|
|
347
|
+
- The `data-srcsize` attribute is for cases where you need to specify a different size variant for the `src` attribute.
|
|
348
|
+
- For server-side rendering, use the `renderBrickImage()` function from the `/template` export, which returns the full HTML string including the custom element wrapper.
|
|
349
|
+
- The component uses native browser lazy loading (`loading="lazy"`), which is well-supported in modern browsers.
|
|
350
|
+
- CSS variables prefixed with `--brick-image-` can be used to customize the component's appearance without modifying the component itself.
|
|
351
|
+
|
|
352
|
+
## Version
|
|
353
|
+
|
|
354
|
+
Current version: 6.0.5
|
|
355
|
+
|
|
356
|
+
### Recent Changes
|
|
357
|
+
|
|
358
|
+
- **6.0.4**: Improved types for `dataLoading`, `dataFetchPriority`, `dataDecoding`
|
|
359
|
+
- **6.0.0**: Removed legacy `<amedia-img>` custom element export
|
|
360
|
+
- **5.0.0**: Removed CommonJS support (ESM only)
|
|
361
|
+
- **4.0.11**: Added `data-decoding` attribute support
|