1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
use *;
use BaseImage;
use component_doc;
use inject_style;
use image_styles;
use ImageConfig;
/// Framed image with shape, fit, shadow, and dimension controls.
///
/// Always provide meaningful `config.alt` when the image conveys information. For circular profile photos use [`Avatar`](crate::Avatar); for card hero regions use [`CardMedia`](crate::CardMedia).
///
/// # When to use
///
/// - Thumbnails, hero images, and content illustrations - Profile or product photos with shape and fit presets - Block-width images inside cards and article layouts
///
/// # Usage
///
/// 1. Set `config.src` and `config.alt` for accessible images. 2. Use `config.shape` for circular, rounded, or square corners. 3. Set `config.fit` to control object-fit within a bounded frame. 4. Enable `config.shadow` for elevated card-style imagery.
///
/// # Best Practices
///
/// ## Do's
///
/// * Provide descriptive `config.alt` for informative images * Set explicit `config.width` and `config.height` to prevent layout shift * Use `config.fit=ImageFit::Cover` for uniform thumbnail grids
///
/// ## Don'ts
///
/// * Do not use decorative images with misleading alt text * Do not stretch images without an appropriate `config.fit` preset
///
/// # Examples
///
/// ## Default image
/// Square image with default fill fit — suitable for thumbnails and content blocks.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig};
/// view! {
/// <div data-testid="image-preview">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/200",
/// "Sample landscape",
/// "200px",
/// "120px",
/// ) />
/// </div>
/// }
/// ```
///
/// ## Rounded shape
/// Rounded corners suit cards and inline content thumbnails.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig, ImageShape};
/// view! {
/// <div data-testid="image-rounded">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/80",
/// "Rounded thumbnail",
/// "80px",
/// "80px",
/// ).with_shape(ImageShape::Rounded) />
/// </div>
/// }
/// ```
///
/// ## Shadow elevation
/// Shadow treatment adds depth for featured or card imagery.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig};
/// view! {
/// <div data-testid="image-shadow">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/120",
/// "Elevated photo",
/// "120px",
/// "80px",
/// ).with_shadow_flag() />
/// </div>
/// }
/// ```
///
/// ## Fit cover and contain
/// Object-fit presets control cropping within a fixed frame.
/// <!-- preview -->
/// ```rust
/// use crate::{Flex, FlexGap, Image, ImageConfig, ImageFit};
/// view! {
/// <div data-testid="image-fit">
/// <Flex gap=FlexGap::Medium>
/// <div data-testid="image-fit-cover">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/200",
/// "Cover fit",
/// "80px",
/// "80px",
/// ).with_fit(ImageFit::Cover) />
/// </div>
/// <div data-testid="image-fit-contain">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/200",
/// "Contain fit",
/// "80px",
/// "80px",
/// ).with_fit(ImageFit::Contain) />
/// </div>
/// </Flex>
/// </div>
/// }
/// ```
///
/// ## Block width
/// Block images span the full width of their container.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig};
/// view! {
/// <div data-testid="image-block" style="width: 240px;">
/// <Image config=ImageConfig::block(
/// "https://picsum.photos/400/120",
/// "Full-width banner",
/// ) />
/// </div>
/// }
/// ```
///
/// ## Theme border token
/// Image borders use stroke tokens from the Orbital theme provider.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig};
/// view! {
/// <div data-testid="image-theme">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/100",
/// "Themed frame",
/// "100px",
/// "100px",
/// ) />
/// </div>
/// }
/// ```
///
/// ## Bounded frame
/// Explicit width and height constrain layout while fit controls cropping.
/// <!-- preview -->
/// ```rust
/// use crate::{Image, ImageConfig, ImageFit};
/// view! {
/// <div data-testid="image-bounded">
/// <Image config=ImageConfig::framed(
/// "https://picsum.photos/300",
/// "Bounded frame",
/// "160px",
/// "100px",
/// ).with_fit(ImageFit::Cover) />
/// </div>
/// }
/// ```