@xsolla/xui-status 0.148.0 → 0.148.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 +267 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# Status
|
|
2
|
+
|
|
3
|
+
A cross-platform React status indicator component that displays a colored dot with an optional text label to indicate state or condition.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @xsolla/xui-status
|
|
9
|
+
# or
|
|
10
|
+
yarn add @xsolla/xui-status
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Status
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { Status } from '@xsolla/xui-status';
|
|
20
|
+
|
|
21
|
+
export default function BasicStatus() {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{ display: 'flex', gap: 24 }}>
|
|
24
|
+
<Status palette="success">Active</Status>
|
|
25
|
+
<Status palette="warning">Pending</Status>
|
|
26
|
+
<Status palette="alert">Error</Status>
|
|
27
|
+
<Status palette="neutral">Inactive</Status>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Dot Only
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import * as React from 'react';
|
|
37
|
+
import { Status } from '@xsolla/xui-status';
|
|
38
|
+
|
|
39
|
+
export default function DotOnly() {
|
|
40
|
+
return (
|
|
41
|
+
<div style={{ display: 'flex', gap: 16 }}>
|
|
42
|
+
<Status palette="success" />
|
|
43
|
+
<Status palette="warning" />
|
|
44
|
+
<Status palette="alert" />
|
|
45
|
+
<Status palette="neutral" />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Different Sizes
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import * as React from 'react';
|
|
55
|
+
import { Status } from '@xsolla/xui-status';
|
|
56
|
+
|
|
57
|
+
export default function Sizes() {
|
|
58
|
+
return (
|
|
59
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 24 }}>
|
|
60
|
+
<Status size="sm" palette="success">Small</Status>
|
|
61
|
+
<Status size="md" palette="success">Medium</Status>
|
|
62
|
+
<Status size="lg" palette="success">Large</Status>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Anatomy
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
import { Status } from '@xsolla/xui-status';
|
|
72
|
+
|
|
73
|
+
<Status
|
|
74
|
+
palette="success" // success, warning, alert, neutral, default
|
|
75
|
+
size="md" // s, m, l
|
|
76
|
+
labelType="primary" // primary or dot-color
|
|
77
|
+
uppercase={true} // Uppercase text
|
|
78
|
+
>
|
|
79
|
+
Label text
|
|
80
|
+
</Status>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Examples
|
|
84
|
+
|
|
85
|
+
### Order Status
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import * as React from 'react';
|
|
89
|
+
import { Status } from '@xsolla/xui-status';
|
|
90
|
+
|
|
91
|
+
export default function OrderStatus() {
|
|
92
|
+
const orders = [
|
|
93
|
+
{ id: '001', status: 'Completed', palette: 'success' as const },
|
|
94
|
+
{ id: '002', status: 'Processing', palette: 'warning' as const },
|
|
95
|
+
{ id: '003', status: 'Failed', palette: 'alert' as const },
|
|
96
|
+
{ id: '004', status: 'Cancelled', palette: 'neutral' as const },
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
|
101
|
+
<thead>
|
|
102
|
+
<tr>
|
|
103
|
+
<th style={{ textAlign: 'left', padding: 8 }}>Order ID</th>
|
|
104
|
+
<th style={{ textAlign: 'left', padding: 8 }}>Status</th>
|
|
105
|
+
</tr>
|
|
106
|
+
</thead>
|
|
107
|
+
<tbody>
|
|
108
|
+
{orders.map(({ id, status, palette }) => (
|
|
109
|
+
<tr key={id}>
|
|
110
|
+
<td style={{ padding: 8 }}>{id}</td>
|
|
111
|
+
<td style={{ padding: 8 }}>
|
|
112
|
+
<Status palette={palette}>{status}</Status>
|
|
113
|
+
</td>
|
|
114
|
+
</tr>
|
|
115
|
+
))}
|
|
116
|
+
</tbody>
|
|
117
|
+
</table>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Service Health
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import * as React from 'react';
|
|
126
|
+
import { Status } from '@xsolla/xui-status';
|
|
127
|
+
|
|
128
|
+
export default function ServiceHealth() {
|
|
129
|
+
const services = [
|
|
130
|
+
{ name: 'API', status: 'operational', palette: 'success' as const },
|
|
131
|
+
{ name: 'Database', status: 'degraded', palette: 'warning' as const },
|
|
132
|
+
{ name: 'CDN', status: 'operational', palette: 'success' as const },
|
|
133
|
+
{ name: 'Auth', status: 'outage', palette: 'alert' as const },
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
138
|
+
{services.map(({ name, status, palette }) => (
|
|
139
|
+
<div
|
|
140
|
+
key={name}
|
|
141
|
+
style={{
|
|
142
|
+
display: 'flex',
|
|
143
|
+
justifyContent: 'space-between',
|
|
144
|
+
padding: 12,
|
|
145
|
+
border: '1px solid #e0e0e0',
|
|
146
|
+
borderRadius: 8,
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<span>{name}</span>
|
|
150
|
+
<Status palette={palette}>{status}</Status>
|
|
151
|
+
</div>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### User Online Status
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import * as React from 'react';
|
|
162
|
+
import { Status } from '@xsolla/xui-status';
|
|
163
|
+
import { Avatar } from '@xsolla/xui-avatar';
|
|
164
|
+
|
|
165
|
+
export default function UserOnlineStatus() {
|
|
166
|
+
const users = [
|
|
167
|
+
{ name: 'John Doe', online: true },
|
|
168
|
+
{ name: 'Jane Smith', online: true },
|
|
169
|
+
{ name: 'Bob Wilson', online: false },
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
174
|
+
{users.map(({ name, online }) => (
|
|
175
|
+
<div key={name} style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
|
176
|
+
<Avatar size="md" text={name.split(' ').map(n => n[0]).join('')} />
|
|
177
|
+
<span style={{ flex: 1 }}>{name}</span>
|
|
178
|
+
<Status
|
|
179
|
+
palette={online ? 'success' : 'neutral'}
|
|
180
|
+
size="sm"
|
|
181
|
+
>
|
|
182
|
+
{online ? 'Online' : 'Offline'}
|
|
183
|
+
</Status>
|
|
184
|
+
</div>
|
|
185
|
+
))}
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Colored Label
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import * as React from 'react';
|
|
195
|
+
import { Status } from '@xsolla/xui-status';
|
|
196
|
+
|
|
197
|
+
export default function ColoredLabel() {
|
|
198
|
+
return (
|
|
199
|
+
<div style={{ display: 'flex', gap: 24 }}>
|
|
200
|
+
<Status palette="success" labelType="primary">Primary Label</Status>
|
|
201
|
+
<Status palette="success" labelType="dot-color">Colored Label</Status>
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Lowercase Status
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import * as React from 'react';
|
|
211
|
+
import { Status } from '@xsolla/xui-status';
|
|
212
|
+
|
|
213
|
+
export default function LowercaseStatus() {
|
|
214
|
+
return (
|
|
215
|
+
<div style={{ display: 'flex', gap: 24 }}>
|
|
216
|
+
<Status palette="success" uppercase>UPPERCASE</Status>
|
|
217
|
+
<Status palette="success" uppercase={false}>Sentence case</Status>
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## API Reference
|
|
224
|
+
|
|
225
|
+
### Status
|
|
226
|
+
|
|
227
|
+
**StatusProps:**
|
|
228
|
+
|
|
229
|
+
| Prop | Type | Default | Description |
|
|
230
|
+
| :--- | :--- | :------ | :---------- |
|
|
231
|
+
| children | `ReactNode` | - | Label text (optional). |
|
|
232
|
+
| palette | `"success" \| "warning" \| "alert" \| "neutral" \| "default"` | `"default"` | Status color palette. |
|
|
233
|
+
| size | `"sm" \| "md" \| "lg"` | `"md"` | Component size. |
|
|
234
|
+
| labelType | `"primary" \| "dot-color"` | `"primary"` | Label color mode. |
|
|
235
|
+
| uppercase | `boolean` | `true` | Transform text to uppercase. |
|
|
236
|
+
|
|
237
|
+
## Size Specifications
|
|
238
|
+
|
|
239
|
+
| Size | Dot Size | Gap | Font Size | Line Height |
|
|
240
|
+
| :--- | :------- | :-- | :-------- | :---------- |
|
|
241
|
+
| `sm` | 4px | 4px | 12px | 16px |
|
|
242
|
+
| `md` | 6px | 6px | 14px | 20px |
|
|
243
|
+
| `lg` | 8px | 8px | 16px | 24px |
|
|
244
|
+
|
|
245
|
+
## Color Palettes
|
|
246
|
+
|
|
247
|
+
| Palette | Use Case |
|
|
248
|
+
| :------ | :------- |
|
|
249
|
+
| `success` | Active, completed, operational |
|
|
250
|
+
| `warning` | Pending, degraded, attention needed |
|
|
251
|
+
| `alert` | Error, failed, critical |
|
|
252
|
+
| `neutral` | Inactive, offline, cancelled |
|
|
253
|
+
| `default` | Generic/disabled state |
|
|
254
|
+
|
|
255
|
+
## Label Types
|
|
256
|
+
|
|
257
|
+
| Type | Description |
|
|
258
|
+
| :--- | :---------- |
|
|
259
|
+
| `primary` | Uses theme's primary text color |
|
|
260
|
+
| `dot-color` | Uses the same color as the dot |
|
|
261
|
+
|
|
262
|
+
## Accessibility
|
|
263
|
+
|
|
264
|
+
- Status information should not rely solely on color
|
|
265
|
+
- Text labels provide context for screen readers
|
|
266
|
+
- Consider using `aria-live` for dynamic status updates
|
|
267
|
+
- Ensure sufficient color contrast for all palettes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-status",
|
|
3
|
-
"version": "0.148.
|
|
3
|
+
"version": "0.148.1",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-core": "0.148.
|
|
14
|
-
"@xsolla/xui-primitives-core": "0.148.
|
|
13
|
+
"@xsolla/xui-core": "0.148.1",
|
|
14
|
+
"@xsolla/xui-primitives-core": "0.148.1"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=16.8.0",
|