@xsolla/xui-icon-wrapper 0.99.0 → 0.101.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/README.md +226 -11
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,26 +1,241 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Icon Wrapper
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A cross-platform React container component that provides consistent sizing, alignment, and shapes for small visual elements like icons, labels, images, and avatars.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
+
npm install @xsolla/xui-icon-wrapper
|
|
9
|
+
# or
|
|
8
10
|
yarn add @xsolla/xui-icon-wrapper
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Icon Wrapper
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
20
|
+
import { Star } from '@xsolla/xui-icons-base';
|
|
21
|
+
|
|
22
|
+
export default function BasicWrapper() {
|
|
23
|
+
return (
|
|
24
|
+
<IconWrapper>
|
|
25
|
+
<Star size={16} />
|
|
26
|
+
</IconWrapper>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Different Sizes
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import * as React from 'react';
|
|
35
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
36
|
+
import { Heart } from '@xsolla/xui-icons-base';
|
|
37
|
+
|
|
38
|
+
export default function Sizes() {
|
|
39
|
+
return (
|
|
40
|
+
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
41
|
+
<IconWrapper size="xxs"><Heart size={12} /></IconWrapper>
|
|
42
|
+
<IconWrapper size="xs"><Heart size={14} /></IconWrapper>
|
|
43
|
+
<IconWrapper size="sm"><Heart size={16} /></IconWrapper>
|
|
44
|
+
<IconWrapper size="md"><Heart size={20} /></IconWrapper>
|
|
45
|
+
<IconWrapper size="lg"><Heart size={24} /></IconWrapper>
|
|
46
|
+
<IconWrapper size="xl"><Heart size={32} /></IconWrapper>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Different Shapes
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import * as React from 'react';
|
|
56
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
57
|
+
import { User } from '@xsolla/xui-icons-base';
|
|
58
|
+
|
|
59
|
+
export default function Shapes() {
|
|
60
|
+
return (
|
|
61
|
+
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
|
|
62
|
+
<IconWrapper shape="none" size="lg">
|
|
63
|
+
<User size={24} />
|
|
64
|
+
</IconWrapper>
|
|
65
|
+
<IconWrapper shape="smooth" size="lg">
|
|
66
|
+
<User size={24} />
|
|
67
|
+
</IconWrapper>
|
|
68
|
+
<IconWrapper shape="full" size="lg">
|
|
69
|
+
<User size={24} />
|
|
70
|
+
</IconWrapper>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Anatomy
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
80
|
+
|
|
81
|
+
<IconWrapper
|
|
82
|
+
size="md" // Wrapper size
|
|
83
|
+
shape="none" // Border radius shape
|
|
84
|
+
type="icon" // Content type hint
|
|
85
|
+
backgroundColor={color} // Custom background
|
|
86
|
+
borderColor={color} // Custom border
|
|
87
|
+
>
|
|
88
|
+
<Icon />
|
|
89
|
+
</IconWrapper>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Examples
|
|
93
|
+
|
|
94
|
+
### With Avatar
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import * as React from 'react';
|
|
98
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
99
|
+
import { Avatar } from '@xsolla/xui-avatar';
|
|
100
|
+
|
|
101
|
+
export default function AvatarWrapper() {
|
|
102
|
+
return (
|
|
103
|
+
<IconWrapper size="lg" shape="full" type="avatar">
|
|
104
|
+
<Avatar src="https://example.com/avatar.jpg" size="md" />
|
|
105
|
+
</IconWrapper>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### With Custom Colors
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import * as React from 'react';
|
|
114
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
115
|
+
import { Check } from '@xsolla/xui-icons-base';
|
|
116
|
+
|
|
117
|
+
export default function CustomColors() {
|
|
118
|
+
return (
|
|
119
|
+
<div style={{ display: 'flex', gap: 16 }}>
|
|
120
|
+
<IconWrapper
|
|
121
|
+
shape="full"
|
|
122
|
+
size="lg"
|
|
123
|
+
backgroundColor="#E8F5E9"
|
|
124
|
+
borderColor="#4CAF50"
|
|
125
|
+
>
|
|
126
|
+
<Check size={20} color="#4CAF50" />
|
|
127
|
+
</IconWrapper>
|
|
128
|
+
<IconWrapper
|
|
129
|
+
shape="smooth"
|
|
130
|
+
size="lg"
|
|
131
|
+
backgroundColor="#FFF3E0"
|
|
132
|
+
>
|
|
133
|
+
<Star size={20} color="#FF9800" />
|
|
134
|
+
</IconWrapper>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Icon Status Indicators
|
|
12
141
|
|
|
13
142
|
```tsx
|
|
143
|
+
import * as React from 'react';
|
|
14
144
|
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
145
|
+
import { Check, Close, AlertTriangle } from '@xsolla/xui-icons-base';
|
|
146
|
+
|
|
147
|
+
export default function StatusIndicators() {
|
|
148
|
+
const statuses = [
|
|
149
|
+
{ icon: <Check size={16} color="#fff" />, bg: '#4CAF50', label: 'Success' },
|
|
150
|
+
{ icon: <Close size={16} color="#fff" />, bg: '#F44336', label: 'Error' },
|
|
151
|
+
{ icon: <AlertTriangle size={16} color="#fff" />, bg: '#FF9800', label: 'Warning' },
|
|
152
|
+
];
|
|
15
153
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
154
|
+
return (
|
|
155
|
+
<div style={{ display: 'flex', gap: 16 }}>
|
|
156
|
+
{statuses.map(({ icon, bg, label }) => (
|
|
157
|
+
<IconWrapper
|
|
158
|
+
key={label}
|
|
159
|
+
shape="full"
|
|
160
|
+
size="md"
|
|
161
|
+
backgroundColor={bg}
|
|
162
|
+
>
|
|
163
|
+
{icon}
|
|
164
|
+
</IconWrapper>
|
|
165
|
+
))}
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
21
169
|
```
|
|
22
170
|
|
|
23
|
-
|
|
171
|
+
### With Brand Icons
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
import * as React from 'react';
|
|
175
|
+
import { IconWrapper } from '@xsolla/xui-icon-wrapper';
|
|
176
|
+
import { Github, Discord, Twitch } from '@xsolla/xui-icons-brand';
|
|
177
|
+
|
|
178
|
+
export default function BrandIcons() {
|
|
179
|
+
return (
|
|
180
|
+
<div style={{ display: 'flex', gap: 12 }}>
|
|
181
|
+
<IconWrapper size="lg" shape="smooth" type="brand">
|
|
182
|
+
<Github size={24} />
|
|
183
|
+
</IconWrapper>
|
|
184
|
+
<IconWrapper size="lg" shape="smooth" type="brand">
|
|
185
|
+
<Discord size={24} />
|
|
186
|
+
</IconWrapper>
|
|
187
|
+
<IconWrapper size="lg" shape="smooth" type="brand">
|
|
188
|
+
<Twitch size={24} />
|
|
189
|
+
</IconWrapper>
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## API Reference
|
|
196
|
+
|
|
197
|
+
### IconWrapper
|
|
198
|
+
|
|
199
|
+
**IconWrapperProps:**
|
|
200
|
+
|
|
201
|
+
| Prop | Type | Default | Description |
|
|
202
|
+
| :--- | :--- | :------ | :---------- |
|
|
203
|
+
| children | `ReactNode` | - | Content to display inside wrapper. |
|
|
204
|
+
| size | `"xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Wrapper size. |
|
|
205
|
+
| shape | `"none" \| "smooth" \| "full"` | `"none"` | Border radius style. |
|
|
206
|
+
| type | `"icon" \| "label" \| "image" \| "avatar" \| "brand" \| "custom"` | `"icon"` | Content type hint for styling. |
|
|
207
|
+
| backgroundColor | `string` | - | Custom background color. |
|
|
208
|
+
| borderColor | `string` | - | Custom border color. |
|
|
209
|
+
|
|
210
|
+
## Size Specifications
|
|
211
|
+
|
|
212
|
+
| Size | Dimensions |
|
|
213
|
+
| :--- | :--------- |
|
|
214
|
+
| xxs | 16x16 |
|
|
215
|
+
| xs | 20x20 |
|
|
216
|
+
| sm | 24x24 |
|
|
217
|
+
| md | 32x32 |
|
|
218
|
+
| lg | 40x40 |
|
|
219
|
+
| xl | 56x56 |
|
|
220
|
+
|
|
221
|
+
## Shape Behavior
|
|
222
|
+
|
|
223
|
+
| Shape | Description |
|
|
224
|
+
| :---- | :---------- |
|
|
225
|
+
| `none` | No border radius, transparent background |
|
|
226
|
+
| `smooth` | Slightly rounded corners (proportional to size) |
|
|
227
|
+
| `full` | Fully circular (border-radius: 999px) |
|
|
228
|
+
|
|
229
|
+
## Use Cases
|
|
230
|
+
|
|
231
|
+
- **Icon containers**: Wrap icons with consistent sizing and backgrounds
|
|
232
|
+
- **Avatar frames**: Provide circular or rounded frames for avatars
|
|
233
|
+
- **Status indicators**: Create colored badge-like indicators
|
|
234
|
+
- **Brand icon containers**: Display brand logos with consistent sizing
|
|
235
|
+
- **Feature icons**: Highlight feature icons with backgrounds
|
|
236
|
+
|
|
237
|
+
## Accessibility
|
|
24
238
|
|
|
25
|
-
-
|
|
26
|
-
- `
|
|
239
|
+
- Content inside the wrapper maintains its own accessibility attributes
|
|
240
|
+
- Use `aria-label` on the child element when the icon conveys meaning
|
|
241
|
+
- Decorative icons should have `aria-hidden="true"`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-icon-wrapper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-core": "0.
|
|
14
|
-
"@xsolla/xui-icons": "0.
|
|
15
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-core": "0.101.0",
|
|
14
|
+
"@xsolla/xui-icons": "0.101.0",
|
|
15
|
+
"@xsolla/xui-primitives-core": "0.101.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": ">=16.8.0",
|