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