@xsolla/xui-image-thumbnail 0.141.0 → 0.141.1

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 DELETED
@@ -1,272 +0,0 @@
1
- # ImageThumbnail
2
-
3
- A cross-platform React component for displaying image thumbnails with overlays, tags at all four corners, and center content (like play buttons). Perfect for video thumbnails, screenshot galleries, and media previews.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @xsolla/xui-image-thumbnail
9
- # or
10
- yarn add @xsolla/xui-image-thumbnail
11
- ```
12
-
13
- ## Demo
14
-
15
- ### Basic ImageThumbnail
16
-
17
- ```tsx
18
- import * as React from 'react';
19
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
20
-
21
- export default function BasicThumbnail() {
22
- return (
23
- <ImageThumbnail
24
- src="https://example.com/screenshot.jpg"
25
- alt="Game screenshot"
26
- ratio="16:9"
27
- width={320}
28
- />
29
- );
30
- }
31
- ```
32
-
33
- ### Video Thumbnail with Play Button
34
-
35
- ```tsx
36
- import * as React from 'react';
37
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
38
-
39
- const PlayButton = () => (
40
- <div style={{
41
- width: 48,
42
- height: 48,
43
- borderRadius: 24,
44
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
45
- display: 'flex',
46
- alignItems: 'center',
47
- justifyContent: 'center',
48
- }}>
49
- <svg width="24" height="24" viewBox="0 0 24 24" fill="white">
50
- <path d="M8 5v14l11-7z" />
51
- </svg>
52
- </div>
53
- );
54
-
55
- export default function VideoThumbnail() {
56
- return (
57
- <ImageThumbnail
58
- src="https://example.com/video-preview.jpg"
59
- alt="Video preview"
60
- ratio="16:9"
61
- width={320}
62
- overlay="fade"
63
- centerContent={<PlayButton />}
64
- />
65
- );
66
- }
67
- ```
68
-
69
- ### Thumbnail with Tags
70
-
71
- ```tsx
72
- import * as React from 'react';
73
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
74
- import { Tag } from '@xsolla/xui-tag';
75
- import { XsollaTicket } from '@xsolla/xui-icons-currency';
76
-
77
- export default function ThumbnailWithTags() {
78
- return (
79
- <ImageThumbnail
80
- src="https://example.com/screenshot.jpg"
81
- alt="Screenshot with reward"
82
- ratio="16:9"
83
- width={320}
84
- overlay="fade"
85
- tagsBottomLeft={
86
- <Tag size="sm" tone="secondary" icon={<XsollaTicket />}>
87
- 5x
88
- </Tag>
89
- }
90
- />
91
- );
92
- }
93
- ```
94
-
95
- ### All Corner Tags
96
-
97
- ```tsx
98
- import * as React from 'react';
99
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
100
- import { Tag } from '@xsolla/xui-tag';
101
- import { Badge } from '@xsolla/xui-badge';
102
-
103
- export default function AllCornerTags() {
104
- return (
105
- <ImageThumbnail
106
- src="https://example.com/screenshot.jpg"
107
- alt="Screenshot with all tags"
108
- ratio="16:9"
109
- width={400}
110
- overlay="fade"
111
- tagsTopLeft={<Tag size="sm" tone="brand">NEW</Tag>}
112
- tagsTopRight={<Tag size="sm" tone="secondary">2:30</Tag>}
113
- tagsBottomLeft={<Tag size="sm" tone="secondary">5x Tickets</Tag>}
114
- tagsBottomRight={<Badge size="lg" tone="success">HD</Badge>}
115
- />
116
- );
117
- }
118
- ```
119
-
120
- ### Overlay Types
121
-
122
- ```tsx
123
- import * as React from 'react';
124
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
125
-
126
- export default function OverlayTypes() {
127
- return (
128
- <div style={{ display: 'flex', gap: 16 }}>
129
- <div>
130
- <p>No Overlay</p>
131
- <ImageThumbnail
132
- src="https://example.com/image.jpg"
133
- ratio="16:9"
134
- width={200}
135
- overlay="none"
136
- />
137
- </div>
138
- <div>
139
- <p>Fade Overlay</p>
140
- <ImageThumbnail
141
- src="https://example.com/image.jpg"
142
- ratio="16:9"
143
- width={200}
144
- overlay="fade"
145
- />
146
- </div>
147
- <div>
148
- <p>Dark Overlay</p>
149
- <ImageThumbnail
150
- src="https://example.com/image.jpg"
151
- ratio="16:9"
152
- width={200}
153
- overlay="dark"
154
- />
155
- </div>
156
- </div>
157
- );
158
- }
159
- ```
160
-
161
- ### Aspect Ratios
162
-
163
- ```tsx
164
- import * as React from 'react';
165
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
166
-
167
- export default function AspectRatios() {
168
- const ratios = ['1:1', '16:9', '4:3', '3:2', '9:16'] as const;
169
-
170
- return (
171
- <div style={{ display: 'flex', gap: 16, flexWrap: 'wrap' }}>
172
- {ratios.map((ratio) => (
173
- <div key={ratio}>
174
- <p>{ratio}</p>
175
- <ImageThumbnail
176
- src="https://example.com/image.jpg"
177
- ratio={ratio}
178
- width={150}
179
- overlay="fade"
180
- />
181
- </div>
182
- ))}
183
- </div>
184
- );
185
- }
186
- ```
187
-
188
- ## Anatomy
189
-
190
- Import the component and use it directly:
191
-
192
- ```jsx
193
- import { ImageThumbnail } from '@xsolla/xui-image-thumbnail';
194
-
195
- <ImageThumbnail
196
- src="..." // Required: Image URL
197
- alt="Description" // Alt text
198
- ratio="16:9" // Aspect ratio
199
- width={320} // Width
200
- overlay="fade" // Overlay type
201
- centerContent={<PlayBtn />} // Center content
202
- tagsTopLeft={<Tag />} // Top-left tags
203
- tagsTopRight={<Tag />} // Top-right tags
204
- tagsBottomLeft={<Tag />} // Bottom-left tags
205
- tagsBottomRight={<Tag />} // Bottom-right tags
206
- onPress={() => {}} // Click handler
207
- />
208
- ```
209
-
210
- ## API Reference
211
-
212
- ### ImageThumbnail
213
-
214
- A media thumbnail component with tag support.
215
-
216
- **ImageThumbnail Props:**
217
-
218
- | Prop | Type | Default | Description |
219
- | :--- | :--- | :------ | :---------- |
220
- | src | `string` | required | Image source URL. |
221
- | alt | `string` | `""` | Alt text for the image. |
222
- | ratio | `"1:1" \| "16:9" \| "4:3" \| "3:2" \| "2:3" \| "9:16" \| "custom"` | `"16:9"` | Aspect ratio. |
223
- | customRatio | `number` | - | Custom aspect ratio (when ratio is 'custom'). |
224
- | width | `number \| string` | `"100%"` | Width of the thumbnail. |
225
- | height | `number \| string` | - | Fixed height (overrides ratio). |
226
- | borderRadius | `number` | `4` | Border radius in pixels. |
227
- | overlay | `"none" \| "fade" \| "dark"` | `"fade"` | Overlay type. |
228
- | centerContent | `ReactNode` | - | Content in the center (e.g., play button). |
229
- | tagsTopLeft | `ReactNode` | - | Tags in top-left corner. |
230
- | tagsTopRight | `ReactNode` | - | Tags in top-right corner. |
231
- | tagsBottomLeft | `ReactNode` | - | Tags in bottom-left corner. |
232
- | tagsBottomRight | `ReactNode` | - | Tags in bottom-right corner. |
233
- | onPress | `() => void` | - | Click handler. |
234
- | tagPadding | `number` | `8` | Padding for tag positions. |
235
- | tagGap | `number` | `4` | Gap between stacked tags. |
236
- | className | `string` | - | Custom className for the container. |
237
-
238
- **Overlay Types:**
239
-
240
- | Type | Description |
241
- | :--- | :---------- |
242
- | none | No overlay |
243
- | fade | Gradient fade from bottom (semi-transparent) |
244
- | dark | Solid dark overlay |
245
-
246
- **Aspect Ratio Values:**
247
-
248
- | Ratio | Numeric Value | Common Use |
249
- | :---- | :------------ | :--------- |
250
- | 1:1 | 1 | Square thumbnails |
251
- | 16:9 | 1.78 | Video, widescreen |
252
- | 4:3 | 1.33 | Standard photos |
253
- | 3:2 | 1.5 | DSLR photos |
254
- | 2:3 | 0.67 | Portrait |
255
- | 9:16 | 0.56 | Vertical video |
256
-
257
- ## Theming
258
-
259
- ImageThumbnail uses minimal theming, primarily relying on the passed props:
260
-
261
- ```typescript
262
- // Overlay styles
263
- overlay="fade" // linear-gradient(to top, rgba(0,0,0,0.48), transparent)
264
- overlay="dark" // rgba(0,0,0,0.48)
265
- ```
266
-
267
- ## Accessibility
268
-
269
- - Uses semantic `img` element with alt text
270
- - Interactive when `onPress` is provided
271
- - Tags and center content can include accessible labels
272
- - Supports keyboard navigation when interactive