@xsolla/xui-spinner 0.150.0 → 0.151.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 +52 -105
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
# Spinner
|
|
2
2
|
|
|
3
|
-
A cross-platform React
|
|
3
|
+
A cross-platform React loading indicator with five sizes and theme-aware default colour.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @xsolla/xui-spinner
|
|
9
|
-
# or
|
|
10
|
-
yarn add @xsolla/xui-spinner
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## Imports
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
```tsx
|
|
14
|
+
import { Spinner, type SpinnerProps } from '@xsolla/xui-spinner';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
16
18
|
|
|
17
19
|
```tsx
|
|
18
20
|
import * as React from 'react';
|
|
19
21
|
import { Spinner } from '@xsolla/xui-spinner';
|
|
20
22
|
|
|
21
|
-
export default function
|
|
23
|
+
export default function QuickStart() {
|
|
22
24
|
return <Spinner />;
|
|
23
25
|
}
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
## API Reference
|
|
29
|
+
|
|
30
|
+
### `<Spinner>`
|
|
31
|
+
|
|
32
|
+
| Prop | Type | Default | Description |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `size` | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Spinner size. |
|
|
35
|
+
| `color` | `string` | theme `content.primary` | Custom stroke colour. |
|
|
36
|
+
| `aria-label` | `string` | `"Loading"` | Accessible label. |
|
|
37
|
+
| `aria-describedby` | `string` | — | ID of an element describing what's loading. |
|
|
38
|
+
| `testID` | `string` | — | Test identifier. |
|
|
39
|
+
|
|
40
|
+
Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
|
|
41
|
+
|
|
42
|
+
### Sizes
|
|
43
|
+
|
|
44
|
+
| Size | Diameter |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `xs` | 8px |
|
|
47
|
+
| `sm` | 16px |
|
|
48
|
+
| `md` | 24px |
|
|
49
|
+
| `lg` | 48px |
|
|
50
|
+
| `xl` | 96px |
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
### Sizes
|
|
27
55
|
|
|
28
56
|
```tsx
|
|
29
57
|
import * as React from 'react';
|
|
@@ -42,13 +70,13 @@ export default function SpinnerSizes() {
|
|
|
42
70
|
}
|
|
43
71
|
```
|
|
44
72
|
|
|
45
|
-
### Custom
|
|
73
|
+
### Custom colour
|
|
46
74
|
|
|
47
75
|
```tsx
|
|
48
76
|
import * as React from 'react';
|
|
49
77
|
import { Spinner } from '@xsolla/xui-spinner';
|
|
50
78
|
|
|
51
|
-
export default function
|
|
79
|
+
export default function ColouredSpinners() {
|
|
52
80
|
return (
|
|
53
81
|
<div style={{ display: 'flex', gap: 24 }}>
|
|
54
82
|
<Spinner color="#3498db" />
|
|
@@ -59,122 +87,41 @@ export default function ColoredSpinner() {
|
|
|
59
87
|
}
|
|
60
88
|
```
|
|
61
89
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Import the component and use it directly:
|
|
65
|
-
|
|
66
|
-
```jsx
|
|
67
|
-
import { Spinner } from '@xsolla/xui-spinner';
|
|
68
|
-
|
|
69
|
-
<Spinner
|
|
70
|
-
size="md" // Size variant
|
|
71
|
-
color="#custom" // Custom color (optional)
|
|
72
|
-
aria-label="Loading" // Accessible label
|
|
73
|
-
/>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Examples
|
|
77
|
-
|
|
78
|
-
### Loading Button State
|
|
90
|
+
### Inline with text
|
|
79
91
|
|
|
80
92
|
```tsx
|
|
81
93
|
import * as React from 'react';
|
|
82
94
|
import { Spinner } from '@xsolla/xui-spinner';
|
|
83
|
-
import { Button } from '@xsolla/xui-button';
|
|
84
95
|
|
|
85
|
-
export default function
|
|
86
|
-
const [loading, setLoading] = React.useState(false);
|
|
87
|
-
|
|
88
|
-
const handleClick = () => {
|
|
89
|
-
setLoading(true);
|
|
90
|
-
setTimeout(() => setLoading(false), 2000);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Button onPress={handleClick} disabled={loading}>
|
|
95
|
-
{loading ? <Spinner size="sm" color="white" /> : 'Submit'}
|
|
96
|
-
</Button>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Full Page Loading
|
|
102
|
-
|
|
103
|
-
```tsx
|
|
104
|
-
import * as React from 'react';
|
|
105
|
-
import { Spinner } from '@xsolla/xui-spinner';
|
|
106
|
-
|
|
107
|
-
export default function FullPageLoading() {
|
|
96
|
+
export default function InlineLoading() {
|
|
108
97
|
return (
|
|
109
|
-
<div style={{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
alignItems: 'center',
|
|
113
|
-
height: '100vh',
|
|
114
|
-
flexDirection: 'column',
|
|
115
|
-
gap: 16
|
|
116
|
-
}}>
|
|
117
|
-
<Spinner size="xl" />
|
|
118
|
-
<span>Loading content...</span>
|
|
98
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
99
|
+
<Spinner size="sm" />
|
|
100
|
+
<span>Saving changes…</span>
|
|
119
101
|
</div>
|
|
120
102
|
);
|
|
121
103
|
}
|
|
122
104
|
```
|
|
123
105
|
|
|
124
|
-
###
|
|
106
|
+
### Loading button state
|
|
125
107
|
|
|
126
108
|
```tsx
|
|
127
109
|
import * as React from 'react';
|
|
128
110
|
import { Spinner } from '@xsolla/xui-spinner';
|
|
111
|
+
import { Button } from '@xsolla/xui-button';
|
|
129
112
|
|
|
130
|
-
export default function
|
|
113
|
+
export default function LoadingButton() {
|
|
114
|
+
const [loading, setLoading] = React.useState(false);
|
|
131
115
|
return (
|
|
132
|
-
<
|
|
133
|
-
<Spinner size="sm" />
|
|
134
|
-
|
|
135
|
-
</div>
|
|
116
|
+
<Button onPress={() => { setLoading(true); setTimeout(() => setLoading(false), 1200); }} disabled={loading}>
|
|
117
|
+
{loading ? <Spinner size="sm" color="white" /> : 'Submit'}
|
|
118
|
+
</Button>
|
|
136
119
|
);
|
|
137
120
|
}
|
|
138
121
|
```
|
|
139
122
|
|
|
140
|
-
## API Reference
|
|
141
|
-
|
|
142
|
-
### Spinner
|
|
143
|
-
|
|
144
|
-
A loading indicator component.
|
|
145
|
-
|
|
146
|
-
**Spinner Props:**
|
|
147
|
-
|
|
148
|
-
| Prop | Type | Default | Description |
|
|
149
|
-
| :--- | :--- | :------ | :---------- |
|
|
150
|
-
| size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Size of the spinner. |
|
|
151
|
-
| color | `string` | Theme default | Custom spinner color. |
|
|
152
|
-
| aria-label | `string` | `"Loading"` | Accessible label. |
|
|
153
|
-
| aria-describedby | `string` | - | ID of description element. |
|
|
154
|
-
| testID | `string` | - | Test identifier. |
|
|
155
|
-
|
|
156
|
-
**Size Reference:**
|
|
157
|
-
|
|
158
|
-
| Size | Dimensions |
|
|
159
|
-
| :--- | :--------- |
|
|
160
|
-
| xs | 8px |
|
|
161
|
-
| sm | 16px |
|
|
162
|
-
| md | 24px |
|
|
163
|
-
| lg | 48px |
|
|
164
|
-
| xl | 96px |
|
|
165
|
-
|
|
166
|
-
## Theming
|
|
167
|
-
|
|
168
|
-
Spinner uses the design system theme for default color:
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
// Default color from theme
|
|
172
|
-
theme.colors.content.brand // Default spinner color
|
|
173
|
-
```
|
|
174
|
-
|
|
175
123
|
## Accessibility
|
|
176
124
|
|
|
177
|
-
-
|
|
178
|
-
- `aria-
|
|
179
|
-
-
|
|
180
|
-
- Supports `aria-describedby` for additional context
|
|
125
|
+
- Renders with `role="status"` and `aria-live="polite"` so screen readers announce the loading state.
|
|
126
|
+
- Default `aria-label` is `"Loading"`; override for context-specific messages such as `"Loading orders"`.
|
|
127
|
+
- Pair with `aria-describedby` when describing what the spinner relates to.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-spinner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.0",
|
|
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.
|
|
14
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-core": "0.151.0",
|
|
14
|
+
"@xsolla/xui-primitives-core": "0.151.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=16.8.0",
|