@fibrae/semi-ui-svelte 0.9.1 → 0.10.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 +8 -4
- package/README.zh-CN.md +8 -4
- package/dist/components/anchor/interface.d.ts +14 -0
- package/dist/components/audio-player/interface.d.ts +5 -0
- package/dist/components/auto-complete/interface.d.ts +29 -0
- package/dist/components/avatar/interface.d.ts +24 -0
- package/dist/components/backtop/interface.d.ts +2 -0
- package/dist/components/badge/interface.d.ts +7 -0
- package/dist/components/banner/interface.d.ts +7 -0
- package/dist/components/breadcrumb/interface.d.ts +10 -0
- package/dist/components/button/interface.d.ts +18 -0
- package/dist/components/calendar/interface.d.ts +16 -0
- package/dist/components/card/interface.d.ts +18 -0
- package/dist/components/carousel/interface.d.ts +16 -0
- package/dist/components/cascader/interface.d.ts +57 -0
- package/dist/components/checkbox/interface.d.ts +19 -0
- package/dist/components/code-highlight/interface.d.ts +3 -0
- package/dist/components/collapse/interface.d.ts +16 -0
- package/dist/components/collapsible/interface.d.ts +10 -0
- package/dist/components/color-picker/interface.d.ts +10 -0
- package/dist/components/config-provider/interface.d.ts +7 -0
- package/dist/components/cropper/interface.d.ts +11 -0
- package/dist/components/date-picker/interface.d.ts +47 -0
- package/dist/components/descriptions/interface.d.ts +6 -0
- package/dist/components/divider/interface.d.ts +4 -0
- package/dist/components/dropdown/interface.d.ts +8 -0
- package/dist/components/empty/interface.d.ts +7 -0
- package/dist/components/feedback/interface.d.ts +16 -0
- package/dist/components/float-button/interface.d.ts +14 -0
- package/dist/components/form/interface.d.ts +47 -0
- package/dist/components/grid/interface.d.ts +13 -0
- package/dist/components/highlight/interface.d.ts +7 -0
- package/dist/components/hot-keys/interface.d.ts +3 -0
- package/dist/components/image/interface.d.ts +59 -0
- package/dist/components/input/interface.d.ts +67 -0
- package/dist/components/input-number/interface.d.ts +24 -0
- package/dist/components/json-viewer/interface.d.ts +7 -0
- package/dist/components/layout/interface.d.ts +3 -0
- package/dist/components/list/interface.d.ts +18 -0
- package/dist/components/locale/interface.d.ts +4 -0
- package/dist/components/lottie/interface.d.ts +2 -0
- package/dist/components/markdown-render/interface.d.ts +5 -0
- package/dist/components/modal/interface.d.ts +29 -0
- package/dist/components/navigation/interface.d.ts +47 -0
- package/dist/components/overflow-list/interface.d.ts +11 -0
- package/dist/components/pagination/interface.d.ts +12 -0
- package/dist/components/pincode/interface.d.ts +8 -0
- package/dist/components/popconfirm/interface.d.ts +12 -0
- package/dist/components/popover/interface.d.ts +30 -0
- package/dist/components/progress/interface.d.ts +13 -0
- package/dist/components/radio/interface.d.ts +22 -0
- package/dist/components/rating/interface.d.ts +12 -0
- package/dist/components/resizable/interface.d.ts +30 -0
- package/dist/components/scroll-list/interface.d.ts +6 -0
- package/dist/components/select/interface.d.ts +63 -0
- package/dist/components/side-sheet/interface.d.ts +19 -0
- package/dist/components/skeleton/interface.d.ts +7 -0
- package/dist/components/slider/interface.d.ts +23 -0
- package/dist/components/space/interface.d.ts +4 -0
- package/dist/components/spin/interface.d.ts +7 -0
- package/dist/components/steps/interface.d.ts +9 -0
- package/dist/components/switch/interface.d.ts +7 -0
- package/dist/components/table/interface.d.ts +48 -0
- package/dist/components/tabs/interface.d.ts +29 -0
- package/dist/components/tag/interface.d.ts +22 -0
- package/dist/components/tag-input/interface.d.ts +29 -0
- package/dist/components/time-picker/interface.d.ts +31 -0
- package/dist/components/timeline/interface.d.ts +5 -0
- package/dist/components/tooltip/interface.d.ts +20 -0
- package/dist/components/transfer/interface.d.ts +18 -0
- package/dist/components/tree/interface.d.ts +45 -0
- package/dist/components/tree-select/interface.d.ts +55 -0
- package/dist/components/typography/interface.d.ts +33 -0
- package/dist/components/upload/interface.d.ts +64 -0
- package/dist/components/user-guide/interface.d.ts +15 -0
- package/dist/components/video-player/interface.d.ts +22 -0
- package/docs/advanced/dark-mode.md +288 -0
- package/docs/basic/button.md +605 -0
- package/docs/basic/divider.md +103 -0
- package/docs/basic/float-button.md +246 -0
- package/docs/basic/grid.md +427 -0
- package/docs/basic/layout.md +459 -0
- package/docs/basic/resizable.md +584 -0
- package/docs/basic/space.md +163 -0
- package/docs/basic/tokens.md +425 -0
- package/docs/basic/typography.md +615 -0
- package/docs/changes-from-semi.md +105 -0
- package/docs/ecosystem/tailwind.md +210 -0
- package/docs/experience/accessibility.md +82 -0
- package/docs/experience/content-guidelines.md +819 -0
- package/docs/experience/internationalization.md +7 -0
- package/docs/feedback/banner.md +198 -0
- package/docs/feedback/feedback.md +294 -0
- package/docs/feedback/notification.md +401 -0
- package/docs/feedback/popconfirm.md +243 -0
- package/docs/feedback/progress.md +389 -0
- package/docs/feedback/skeleton.md +388 -0
- package/docs/feedback/spin.md +172 -0
- package/docs/feedback/toast.md +393 -0
- package/docs/input/auto-complete.md +399 -0
- package/docs/input/cascader.md +1558 -0
- package/docs/input/checkbox.md +408 -0
- package/docs/input/color-picker.md +175 -0
- package/docs/input/date-picker.md +942 -0
- package/docs/input/form.md +2550 -0
- package/docs/input/input-number.md +451 -0
- package/docs/input/input.md +640 -0
- package/docs/input/pincode.md +191 -0
- package/docs/input/radio.md +337 -0
- package/docs/input/rating.md +214 -0
- package/docs/input/select.md +1230 -0
- package/docs/input/slider.md +347 -0
- package/docs/input/switch.md +206 -0
- package/docs/input/tag-input.md +465 -0
- package/docs/input/time-picker.md +358 -0
- package/docs/input/transfer.md +1061 -0
- package/docs/input/tree-select.md +1300 -0
- package/docs/input/upload.md +1811 -0
- package/docs/llms.txt +147 -0
- package/docs/navigation/anchor.md +377 -0
- package/docs/navigation/backtop.md +100 -0
- package/docs/navigation/breadcrumb.md +284 -0
- package/docs/navigation/navigation.md +851 -0
- package/docs/navigation/pagination.md +217 -0
- package/docs/navigation/steps.md +315 -0
- package/docs/navigation/tabs.md +754 -0
- package/docs/navigation/tree.md +1956 -0
- package/docs/other/config-provider.md +599 -0
- package/docs/other/locale.md +353 -0
- package/docs/plus/audio-player.md +155 -0
- package/docs/plus/code-highlight.md +150 -0
- package/docs/plus/drag-move.md +214 -0
- package/docs/plus/hot-keys.md +174 -0
- package/docs/plus/json-viewer.md +392 -0
- package/docs/plus/lottie.md +176 -0
- package/docs/plus/markdown-render.md +240 -0
- package/docs/plus/video-player.md +325 -0
- package/docs/show/avatar.md +475 -0
- package/docs/show/badge.md +276 -0
- package/docs/show/calendar.md +352 -0
- package/docs/show/card.md +485 -0
- package/docs/show/carousel.md +592 -0
- package/docs/show/collapse.md +289 -0
- package/docs/show/collapsible.md +216 -0
- package/docs/show/cropper.md +285 -0
- package/docs/show/descriptions.md +325 -0
- package/docs/show/dropdown.md +466 -0
- package/docs/show/empty.md +225 -0
- package/docs/show/highlight.md +144 -0
- package/docs/show/image.md +433 -0
- package/docs/show/list.md +927 -0
- package/docs/show/modal.md +517 -0
- package/docs/show/overflow-list.md +272 -0
- package/docs/show/popover.md +534 -0
- package/docs/show/scroll-list.md +156 -0
- package/docs/show/side-sheet.md +274 -0
- package/docs/show/table.md +5437 -0
- package/docs/show/tag.md +428 -0
- package/docs/show/timeline.md +277 -0
- package/docs/show/tooltip.md +442 -0
- package/docs/show/user-guide.md +419 -0
- package/docs/start/getting-started.md +234 -0
- package/docs/start/introduction.md +57 -0
- package/docs/start/overview.md +21 -0
- package/package.json +5 -4
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
> Used to display the current progress and status of the user operation, and is generally used when the operation takes a long time. Can also be used to indicate the degree of completion of a task/object
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/feedback/progress/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Standard progress bar
|
|
18
|
+
|
|
19
|
+
Use `stroke` Property to control the filling color of the progress bar\
|
|
20
|
+
Use `Percent` Property to control completed progress\
|
|
21
|
+
Use `size` Property control progress bar size\
|
|
22
|
+
Use `aria-label` Property to explain the specific role\
|
|
23
|
+
If the preset size is not satisfied, You can pass height to customize the height of the progress bar through `style` property.
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<div style="width: 200px">
|
|
31
|
+
<Progress aria-label="disk usage" percent={10} stroke="var(--semi-color-warning)" />
|
|
32
|
+
<br />
|
|
33
|
+
<Progress aria-label="disk usage" percent={25} stroke="var(--semi-color-danger)" />
|
|
34
|
+
<br />
|
|
35
|
+
<Progress aria-label="disk usage" percent={50} />
|
|
36
|
+
<br />
|
|
37
|
+
<Progress aria-label="download progress" percent={80} />
|
|
38
|
+
<br />
|
|
39
|
+
<Progress aria-label="disk usage" percent={80} size="large" />
|
|
40
|
+
<br />
|
|
41
|
+
<Progress aria-label="disk usage" percent={80} style="height: 8px" />
|
|
42
|
+
</div>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Indeterminate progress bar
|
|
46
|
+
|
|
47
|
+
Set `indeterminate` when progress cannot be calculated. It supports both line and circle progress bars. When enabled, `percent` no longer controls the progress length and `showInfo` text is hidden.
|
|
48
|
+
|
|
49
|
+
```svelte
|
|
50
|
+
<script lang="ts">
|
|
51
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div style="width: 240px">
|
|
55
|
+
<Progress aria-label="正在加载" indeterminate />
|
|
56
|
+
<br />
|
|
57
|
+
<Progress aria-label="正在加载" indeterminate size="large" />
|
|
58
|
+
<div style="display: flex; align-items: center; gap: 16px; margin-block-start: 20px">
|
|
59
|
+
<Progress aria-label="正在加载" indeterminate type="circle" />
|
|
60
|
+
<Progress aria-label="正在加载" indeterminate size="small" type="circle" />
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Show percentage text
|
|
66
|
+
|
|
67
|
+
You can control whether to show percentage number through the `showInfo` property, and format the percentage text through the `format` snippet.
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<script lang="ts">
|
|
71
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<div style="width: 200px">
|
|
75
|
+
<Progress aria-label="disk usage" percent={10} showInfo stroke="var(--semi-color-warning)" />
|
|
76
|
+
<br />
|
|
77
|
+
<Progress aria-label="disk usage" percent={25} showInfo stroke="var(--semi-color-danger)" />
|
|
78
|
+
<br />
|
|
79
|
+
<Progress aria-label="disk usage" percent={50} showInfo />
|
|
80
|
+
<br />
|
|
81
|
+
<Progress aria-label="disk usage" percent={50} showInfo>
|
|
82
|
+
{#snippet format({ percent })}{percent * 10}‰{/snippet}
|
|
83
|
+
</Progress>
|
|
84
|
+
</div>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Vertical progress bar
|
|
88
|
+
|
|
89
|
+
You can use vertical progress bar by setting `direction='vertical'` If preset width is not satisfied, you can pass width to customize the width of the vertical progress bar through `style` property.
|
|
90
|
+
|
|
91
|
+
```svelte
|
|
92
|
+
<script lang="ts">
|
|
93
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<div style="height: 100px; display: flex">
|
|
97
|
+
<Progress aria-label="disk usage" direction="vertical" percent={10} />
|
|
98
|
+
<Progress aria-label="disk usage" direction="vertical" percent={25} />
|
|
99
|
+
<Progress aria-label="disk usage" direction="vertical" percent={50} />
|
|
100
|
+
<Progress aria-label="disk usage" direction="vertical" percent={80} size="large" />
|
|
101
|
+
<Progress aria-label="disk usage" direction="vertical" percent={80} style="width: 8px" />
|
|
102
|
+
</div>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Circular progress bar
|
|
106
|
+
|
|
107
|
+
Set type to`circle`, the progress bar will be displayed in a ring shape. The default size of the progress bar is 72 x 72
|
|
108
|
+
|
|
109
|
+
```svelte
|
|
110
|
+
<script lang="ts">
|
|
111
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<div>
|
|
115
|
+
<Progress aria-label="disk usage" percent={10} style="margin: 5px" type="circle" />
|
|
116
|
+
<Progress aria-label="disk usage" percent={25} style="margin: 5px" type="circle" />
|
|
117
|
+
<Progress aria-label="disk usage" percent={50} style="margin: 5px" type="circle" />
|
|
118
|
+
<Progress aria-label="disk usage" percent={80} style="margin: 5px" type="circle" />
|
|
119
|
+
</div>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You can modify it's `width` to control the size of the circular progress bar.
|
|
123
|
+
|
|
124
|
+
```svelte
|
|
125
|
+
<script lang="ts">
|
|
126
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<div>
|
|
130
|
+
<Progress aria-label="disk usage" percent={100} style="margin: 5px" type="circle" width={100} />
|
|
131
|
+
</div>
|
|
132
|
+
<div>
|
|
133
|
+
<Progress aria-label="disk usage" percent={100} stroke="var(--semi-color-danger)" style="margin: 5px" type="circle" width={100} />
|
|
134
|
+
</div>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Small circular progress bar
|
|
138
|
+
|
|
139
|
+
Small progress bar default size is 24 x 24.
|
|
140
|
+
|
|
141
|
+
```svelte
|
|
142
|
+
<script lang="ts">
|
|
143
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<Progress aria-label="disk usage" percent={10} size="small" style="margin: 5px" type="circle" />
|
|
147
|
+
<Progress aria-label="disk usage" percent={25} size="small" style="margin: 5px" type="circle" />
|
|
148
|
+
<Progress aria-label="disk usage" percent={50} size="small" style="margin: 5px" type="circle" />
|
|
149
|
+
<Progress aria-label="disk usage" percent={80} size="small" style="margin: 5px" type="circle" />
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Dynamic change percent
|
|
153
|
+
|
|
154
|
+
The number in the text animates to the new `percent`. When `percent` changes again while the animation is running, the new animation starts from the number currently shown.
|
|
155
|
+
|
|
156
|
+
```svelte
|
|
157
|
+
<script lang="ts">
|
|
158
|
+
import { IconChevronLeft, IconChevronRight } from '@fibrae/semi-icons-svelte';
|
|
159
|
+
import { Button, Progress } from '@fibrae/semi-ui-svelte';
|
|
160
|
+
|
|
161
|
+
let percent = $state(40);
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<div>
|
|
165
|
+
<Progress aria-label="disk usage" {percent} showInfo />
|
|
166
|
+
<Button aria-label="减少" disabled={percent === 0} theme="light" onclick={() => (percent -= 10)}>
|
|
167
|
+
{#snippet icon()}
|
|
168
|
+
<IconChevronLeft />
|
|
169
|
+
{/snippet}
|
|
170
|
+
</Button>
|
|
171
|
+
<Button aria-label="增加" disabled={percent >= 100} theme="light" onclick={() => (percent += 10)}>
|
|
172
|
+
{#snippet icon()}
|
|
173
|
+
<IconChevronRight />
|
|
174
|
+
{/snippet}
|
|
175
|
+
</Button>
|
|
176
|
+
</div>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```svelte
|
|
180
|
+
<script lang="ts">
|
|
181
|
+
import { IconChevronLeft, IconChevronRight } from '@fibrae/semi-icons-svelte';
|
|
182
|
+
import { Button, Progress } from '@fibrae/semi-ui-svelte';
|
|
183
|
+
|
|
184
|
+
let cirPerc = $state(40);
|
|
185
|
+
</script>
|
|
186
|
+
|
|
187
|
+
<div>
|
|
188
|
+
<div>
|
|
189
|
+
<Progress aria-label="disk usage" percent={cirPerc} type="circle" />
|
|
190
|
+
</div>
|
|
191
|
+
<Button aria-label="减少" disabled={cirPerc === 0} theme="light" onclick={() => (cirPerc -= 10)}>
|
|
192
|
+
{#snippet icon()}
|
|
193
|
+
<IconChevronLeft />
|
|
194
|
+
{/snippet}
|
|
195
|
+
</Button>
|
|
196
|
+
<Button aria-label="增加" disabled={cirPerc >= 100} theme="light" onclick={() => (cirPerc += 10)}>
|
|
197
|
+
{#snippet icon()}
|
|
198
|
+
<IconChevronRight />
|
|
199
|
+
{/snippet}
|
|
200
|
+
</Button>
|
|
201
|
+
</div>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Custom central text content
|
|
205
|
+
|
|
206
|
+
You can customize the central text with the `format` snippet. Its argument is `{ percent }`, where `percent` is the percentage currently shown. The snippet renders only when the text is shown\
|
|
207
|
+
If you don't need central text content, you can set `showInfo` to false or render nothing in the snippet
|
|
208
|
+
|
|
209
|
+
```svelte
|
|
210
|
+
<script lang="ts">
|
|
211
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
212
|
+
</script>
|
|
213
|
+
|
|
214
|
+
<Progress aria-label="disk usage" percent={75} showInfo style="margin: 10px" type="circle">
|
|
215
|
+
{#snippet format({ percent })}{percent}Days{/snippet}
|
|
216
|
+
</Progress>
|
|
217
|
+
<Progress aria-label="disk usage" percent={100} showInfo style="margin: 10px" type="circle">
|
|
218
|
+
{#snippet format()}Done{/snippet}
|
|
219
|
+
</Progress>
|
|
220
|
+
<Progress aria-label="disk usage" percent={50} showInfo={false} style="margin: 10px" type="circle" />
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Round / square edges
|
|
224
|
+
|
|
225
|
+
With the `strokeLinecap` property, you can control the edge shape of the ring progress bar.
|
|
226
|
+
|
|
227
|
+
```svelte
|
|
228
|
+
<script lang="ts">
|
|
229
|
+
import { Progress } from '@fibrae/semi-ui-svelte';
|
|
230
|
+
</script>
|
|
231
|
+
|
|
232
|
+
<Progress aria-label="disk usage" percent={50} strokeLinecap="round" style="margin: 10px" type="circle" />
|
|
233
|
+
<Progress aria-label="disk usage" percent={50} strokeLinecap="square" style="margin: 10px" type="circle" />
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Customise the progress bar color
|
|
237
|
+
|
|
238
|
+
The color of a specific `percent` can be customised by setting the `stroke` property
|
|
239
|
+
|
|
240
|
+
```svelte
|
|
241
|
+
<script lang="ts">
|
|
242
|
+
import { IconChevronLeft, IconChevronRight } from '@fibrae/semi-icons-svelte';
|
|
243
|
+
import { Button, Progress } from '@fibrae/semi-ui-svelte';
|
|
244
|
+
|
|
245
|
+
let percent = $state(10);
|
|
246
|
+
const strokeArr = [
|
|
247
|
+
{ percent: 20, color: 'red' },
|
|
248
|
+
{ percent: 40, color: 'orange-9' },
|
|
249
|
+
{ percent: 60, color: 'light-green-8' },
|
|
250
|
+
{ percent: 80, color: 'hsla(125, 50%, 46%, 1)' },
|
|
251
|
+
];
|
|
252
|
+
</script>
|
|
253
|
+
|
|
254
|
+
<div>
|
|
255
|
+
<Progress aria-label="disk usage" {percent} showInfo stroke={strokeArr} type="circle" width={100} />
|
|
256
|
+
<Progress aria-label="disk usage" {percent} showInfo stroke={strokeArr} style="margin: 20px 0 10px" />
|
|
257
|
+
</div>
|
|
258
|
+
<Button aria-label="Decrease" disabled={percent === 0} theme="light" onclick={() => (percent -= 10)}>
|
|
259
|
+
{#snippet icon()}
|
|
260
|
+
<IconChevronLeft />
|
|
261
|
+
{/snippet}
|
|
262
|
+
</Button>
|
|
263
|
+
<Button aria-label="Increase" disabled={percent === 100} theme="light" onclick={() => (percent += 10)}>
|
|
264
|
+
{#snippet icon()}
|
|
265
|
+
<IconChevronRight />
|
|
266
|
+
{/snippet}
|
|
267
|
+
</Button>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Auto-completion of colour intervals
|
|
271
|
+
|
|
272
|
+
The gradient can be generated by setting the `strokeGradient` property to `true`, automatically fill the colour interval.
|
|
273
|
+
|
|
274
|
+
```svelte
|
|
275
|
+
<script lang="ts">
|
|
276
|
+
import { IconChevronLeft, IconChevronRight } from '@fibrae/semi-icons-svelte';
|
|
277
|
+
import { Button, Progress, Space } from '@fibrae/semi-ui-svelte';
|
|
278
|
+
|
|
279
|
+
let percent = $state(65);
|
|
280
|
+
let percentInterval = $state(0);
|
|
281
|
+
const strokeArr = [
|
|
282
|
+
{ percent: 0, color: 'rgb(249, 57, 32)' },
|
|
283
|
+
{ percent: 50, color: '#46259E' },
|
|
284
|
+
{ percent: 100, color: 'hsla(125, 50%, 46%, 1)' },
|
|
285
|
+
];
|
|
286
|
+
const strokeArrReverse = [
|
|
287
|
+
{ percent: 0, color: 'hsla(125, 50%, 46%, 1)' },
|
|
288
|
+
{ percent: 50, color: '#46259E' },
|
|
289
|
+
{ percent: 100, color: 'rgb(249, 57, 32)' },
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
// Each value schedules the next one; restarting after 100 pauses longer.
|
|
293
|
+
$effect(() => {
|
|
294
|
+
const current = percentInterval;
|
|
295
|
+
const timer = setTimeout(
|
|
296
|
+
() => {
|
|
297
|
+
percentInterval = current > 100 ? 0 : current + 3;
|
|
298
|
+
},
|
|
299
|
+
current === 0 || current > 100 ? 1200 : 290 - (current % 50) * 3
|
|
300
|
+
);
|
|
301
|
+
return () => clearTimeout(timer);
|
|
302
|
+
});
|
|
303
|
+
</script>
|
|
304
|
+
|
|
305
|
+
<Space spacing={20}>
|
|
306
|
+
<div>
|
|
307
|
+
<Progress aria-label="file download speed" percent={percentInterval} showInfo stroke={strokeArr} strokeGradient type="circle" width={100} />
|
|
308
|
+
</div>
|
|
309
|
+
<div>
|
|
310
|
+
<Progress aria-label="file download speed" percent={percentInterval} showInfo stroke={strokeArrReverse} strokeGradient type="circle" width={100} />
|
|
311
|
+
</div>
|
|
312
|
+
</Space>
|
|
313
|
+
<div style="width: 100%; margin: 20px 0 10px">
|
|
314
|
+
<Progress aria-label="file download speed" {percent} showInfo size="large" stroke={strokeArr} strokeGradient />
|
|
315
|
+
</div>
|
|
316
|
+
<Button aria-label="Decrease" disabled={percent === 0} theme="light" onclick={() => (percent -= 5)}>
|
|
317
|
+
{#snippet icon()}
|
|
318
|
+
<IconChevronLeft />
|
|
319
|
+
{/snippet}
|
|
320
|
+
</Button>
|
|
321
|
+
<Button aria-label="Increase" disabled={percent === 100} theme="light" onclick={() => (percent += 5)}>
|
|
322
|
+
{#snippet icon()}
|
|
323
|
+
<IconChevronRight />
|
|
324
|
+
{/snippet}
|
|
325
|
+
</Button>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## API Reference
|
|
329
|
+
|
|
330
|
+
**Props**
|
|
331
|
+
|
|
332
|
+
| Property | Description | Type | Default |
|
|
333
|
+
| - | - | - | - |
|
|
334
|
+
| direction | Direction of the line progress bar: horizontal or vertical. | `ProgressDirection` | `"horizontal"` |
|
|
335
|
+
| format | Snippet for custom text. Its argument `{ percent }` is the shown number clamped to 0-100. It renders only when the text is shown. | `Snippet<[{ percent: number }]>` | - |
|
|
336
|
+
| indeterminate | Whether the progress is indeterminate. When on, percent no longer controls the length, the text is hidden and aria-valuenow is omitted. | `boolean` | `false` |
|
|
337
|
+
| motion | Whether the shown number animates to the new percent. When off it jumps to the target. | `boolean` | `true` |
|
|
338
|
+
| orbitStroke | Fill color of the track. | `string` | - |
|
|
339
|
+
| percent | Progress percentage. Passing NaN throws an error. | `number` | `0` |
|
|
340
|
+
| showInfo | Whether to show the text: in the center of a circle, or on the right of a bar. | `boolean` | `false` |
|
|
341
|
+
| size | Size: default, small (circle only) or large (line only). | `ProgressSize` | `"default"` |
|
|
342
|
+
| stroke | Fill color. An array is a list of `{ percent, color }` intervals, where color is any CSS color or a Semi palette name. | `string \| StrokeArr` | - |
|
|
343
|
+
| strokeGradient | Whether to generate gradient colors between intervals. Requires at least one interval in stroke. | `boolean` | `false` |
|
|
344
|
+
| strokeLinecap | Line cap of the circle progress bar: round or square. | `'round' \| 'square'` | `"round"` |
|
|
345
|
+
| strokeWidth | Stroke width of the circle progress bar. | `number` | `4` |
|
|
346
|
+
| type | Type: line or circle. | `ProgressType` | `"line"` |
|
|
347
|
+
| width | Diameter of the circle progress bar. Defaults to 24 when size is small and 72 otherwise. | `number` | - |
|
|
348
|
+
|
|
349
|
+
`class`, `style` (a string) and native attributes (`id`, `aria-label`, `aria-labelledby`, `aria-valuetext` and so on) land on the root element (`role="progressbar"`).
|
|
350
|
+
|
|
351
|
+
## Accessibility
|
|
352
|
+
|
|
353
|
+
### ARIA
|
|
354
|
+
|
|
355
|
+
- Progress has a `progressbar` role to indicate that it is a progress bar component.
|
|
356
|
+
- Progress will automatically set `aria-valuenow` as the progress percentage (`percent`) passed to the component to ensure that the screen reader can get the correct percentage value. When `indeterminate=true`, `aria-valuenow` is omitted because the current progress value is unknown. In addition, Progress supports incoming `aria-valuetext`. When you pass in, according to W3C specifications, `aria-valuetext` will be used and consumed by screen readers instead of `aria-valuenow`
|
|
357
|
+
- Progress support `aria-label`, `aria-labelledby`
|
|
358
|
+
- When there is a description element about the role of Progress outside of Progress, you can explicitly specify that the id of certain elements is the label of Progress through `aria-labelledby`
|
|
359
|
+
- Otherwise, you should use aria-label to explain the specific meaning of the value represented by Progress
|
|
360
|
+
|
|
361
|
+
```svelte
|
|
362
|
+
<!-- good case -->
|
|
363
|
+
<p id="progressbar-label">Disk Usage</p>
|
|
364
|
+
<Progress aria-labelledby="progressbar-label" percent={80} />
|
|
365
|
+
|
|
366
|
+
<!-- good case -->
|
|
367
|
+
<Progress aria-label="Percent of disk usage" percent={80} />
|
|
368
|
+
<Progress aria-label="Percent of file downloaded" percent={80} />
|
|
369
|
+
|
|
370
|
+
<!-- usage of aria-valuetext -->
|
|
371
|
+
<Progress aria-label="Percent of disk usage" percent={80} aria-valuetext="Step 2: Copying files... " />
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Content Guidelines
|
|
375
|
+
|
|
376
|
+
- If the progress bar process is complicated, or there is a long waiting time, you can use the help text to explain. This lets the user know what progress is happening.
|
|
377
|
+
|
|
378
|
+
## Design Tokens
|
|
379
|
+
|
|
380
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/feedback/progress/>
|
|
381
|
+
|
|
382
|
+
## Changes from Semi Design
|
|
383
|
+
|
|
384
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
385
|
+
|
|
386
|
+
- 破坏性:`stroke` 与 `strokeGradient` 颜色改由浏览器解析,色板名输出 `var(--semi-blue-5)` 形式,渐变中间色用 `color-mix`;逗号与斜杠混写的颜色(如 `hsla(125, 50%, 46% / 1)`)不再被接受,改为合法 CSS;`@fibrae/semi-foundation/progress/generates` 的 `generateColor` 改为输出 CSS 表达式;删除 `ProgressState` 子路径导出。
|
|
387
|
+
- 破坏性(类型):`ProgressProps` 不再接受 `children`,`motion` 收为 `boolean`;`type="circle"` 且 `size="large"` 按 default 渲染为 72px。Vue:`format` 改为 `#format="{ percent }"` 插槽;`percent` 为 NaN 时抛 `[Semi Progress]:percent can not be NaN`。
|
|
388
|
+
- Svelte:`format` 是 snippet,参数 `{ percent }`;`percent` 为 NaN 时同样抛错。
|
|
389
|
+
- 线形进度条的文字不收缩、不换行,`format` 返回长文字时进度轨随之变短。
|