@xsolla/xui-progress-bar 0.149.1 → 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 +82 -37
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,79 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ProgressBar
|
|
2
2
|
|
|
3
|
-
A cross-platform React
|
|
3
|
+
A cross-platform React linear progress bar with optional label, status icon, helper text, and error state.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @xsolla/xui-progress-bar
|
|
9
|
-
# or
|
|
10
|
-
yarn add @xsolla/xui-progress-bar
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## Imports
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
```tsx
|
|
14
|
+
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
16
18
|
|
|
17
19
|
```tsx
|
|
18
20
|
import * as React from 'react';
|
|
19
21
|
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
20
22
|
|
|
21
|
-
export default function
|
|
22
|
-
return <ProgressBar
|
|
23
|
+
export default function QuickStart() {
|
|
24
|
+
return <ProgressBar percent={60} label="Uploading" />;
|
|
23
25
|
}
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
## API Reference
|
|
29
|
+
|
|
30
|
+
### `<ProgressBar>`
|
|
31
|
+
|
|
32
|
+
| Prop | Type | Default | Description |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `percent` | `number` | `0` | Progress value, clamped to `0..100`. |
|
|
35
|
+
| `size` | `"xl" \| "lg" \| "md" \| "sm" \| "xs" \| "l" \| "m" \| "s"` | `"m"` | Bar height and label/helper typography. Long-form (`xl`, `lg`, `md`, `sm`, `xs`) and short-form (`l`, `m`, `s`) values are both accepted. Default `"m"` is equivalent to long-form `"md"`. |
|
|
36
|
+
| `state` | `"default" \| "success" \| "error"` | `"default"` | Drives bar colour, status icon, and helper styling. |
|
|
37
|
+
| `label` | `string` | — | Label rendered above the bar. |
|
|
38
|
+
| `showLabel` | `boolean` | `true` | Toggles the entire label row (label, info icon, status icon). |
|
|
39
|
+
| `showInfoIcon` | `boolean` | `false` | Adds an info icon next to the label. |
|
|
40
|
+
| `showStatusIcon` | `boolean` | `true` | Renders the default status icon (`Check` for success, `AlertCircle` for error). |
|
|
41
|
+
| `helperText` | `string` | — | Helper text rendered below the bar. |
|
|
42
|
+
| `errorMessage` | `string` | — | Replaces `helperText` when `state === "error"`. |
|
|
43
|
+
| `labelIcon` | `ReactNode` | — | Icon rendered to the left of the label. |
|
|
44
|
+
| `statusIcon` | `ReactNode` | — | Override for the default status icon. |
|
|
45
|
+
|
|
46
|
+
Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### States
|
|
27
51
|
|
|
28
52
|
```tsx
|
|
29
53
|
import * as React from 'react';
|
|
30
54
|
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
31
55
|
|
|
32
|
-
export default function
|
|
56
|
+
export default function ProgressStates() {
|
|
33
57
|
return (
|
|
34
|
-
<div style={{ display: 'flex',
|
|
35
|
-
<ProgressBar
|
|
36
|
-
<ProgressBar
|
|
37
|
-
<ProgressBar
|
|
58
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
59
|
+
<ProgressBar percent={40} label="Default" />
|
|
60
|
+
<ProgressBar percent={100} state="success" label="Success" helperText="Done" />
|
|
61
|
+
<ProgressBar percent={70} state="error" label="Failed" errorMessage="Network error" />
|
|
38
62
|
</div>
|
|
39
63
|
);
|
|
40
64
|
}
|
|
41
65
|
```
|
|
42
66
|
|
|
43
|
-
###
|
|
67
|
+
### Sizes
|
|
44
68
|
|
|
45
69
|
```tsx
|
|
46
70
|
import * as React from 'react';
|
|
47
71
|
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
48
72
|
|
|
49
|
-
export default function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return <ProgressBar value={progress} />;
|
|
73
|
+
export default function ProgressSizes() {
|
|
74
|
+
return (
|
|
75
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
76
|
+
<ProgressBar percent={50} size="xs" />
|
|
77
|
+
<ProgressBar percent={50} size="sm" />
|
|
78
|
+
<ProgressBar percent={50} size="md" />
|
|
79
|
+
<ProgressBar percent={50} size="lg" />
|
|
80
|
+
<ProgressBar percent={50} size="xl" />
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
60
83
|
}
|
|
61
84
|
```
|
|
62
85
|
|
|
63
|
-
|
|
86
|
+
### With helper text and info icon
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
```tsx
|
|
89
|
+
import * as React from 'react';
|
|
90
|
+
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
export default function ProgressHelpers() {
|
|
93
|
+
return (
|
|
94
|
+
<ProgressBar
|
|
95
|
+
percent={35}
|
|
96
|
+
label="Uploading assets"
|
|
97
|
+
helperText="3 of 8 files complete"
|
|
98
|
+
showInfoIcon
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
68
103
|
|
|
69
|
-
|
|
70
|
-
| :--- | :--- | :------ | :---------- |
|
|
71
|
-
| value | `number` | `0` | Progress value (0-100). |
|
|
72
|
-
| size | `"sm" \| "md" \| "lg"` | `"md"` | Size of the progress bar. |
|
|
104
|
+
### Animated
|
|
73
105
|
|
|
74
|
-
|
|
106
|
+
```tsx
|
|
107
|
+
import * as React from 'react';
|
|
108
|
+
import { ProgressBar } from '@xsolla/xui-progress-bar';
|
|
75
109
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
110
|
+
export default function AnimatedProgress() {
|
|
111
|
+
const [percent, setPercent] = React.useState(0);
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
const id = setInterval(() => setPercent((p) => (p >= 100 ? 0 : p + 10)), 500);
|
|
114
|
+
return () => clearInterval(id);
|
|
115
|
+
}, []);
|
|
116
|
+
return <ProgressBar percent={percent} label={`${percent}%`} />;
|
|
117
|
+
}
|
|
79
118
|
```
|
|
119
|
+
|
|
120
|
+
## Accessibility
|
|
121
|
+
|
|
122
|
+
- The bar has `role="progressbar"` with `aria-valuenow`, `aria-valuemin`, and `aria-valuemax`.
|
|
123
|
+
- Helper text and error messages are linked via `aria-describedby`.
|
|
124
|
+
- Provide a `label` to give the bar an accessible name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-progress-bar",
|
|
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,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.151.0",
|
|
14
|
+
"@xsolla/xui-icons": "0.151.0",
|
|
15
|
+
"@xsolla/xui-primitives-core": "0.151.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": ">=16.8.0",
|