@fibrae/semi-ui-svelte 0.9.0 → 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/cascader.svelte +1 -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/form/label.svelte +2 -2
- 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/tooltip/tooltip.svelte +3 -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/dist/styles.css +1 -1
- 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,388 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
> A placeholder preview of content before the data loaded.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/feedback/skeleton/
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
- `Avatar`: Avatar placeholder, by default uses Avatar medium sizing: `width: 48px`, `height: 48px`. Supports the `size` and `shape` properties; see the API reference for their values.
|
|
10
|
+
- `Image`: Image placeholder, default size: `width: 100%`, `height: 100%`.
|
|
11
|
+
- `Title`: Title placeholder, default size: `width: 100%`, `height: 24px`.
|
|
12
|
+
- `Paragraph`: Content part placeholder, default size: `width: 100%`, `height: 16px`, `margin-bottom: 10px`.
|
|
13
|
+
- `Button`: Button placeholder, default size: `width: 115px`, `height: 32px`.
|
|
14
|
+
|
|
15
|
+
> Note: Default styles can be overridden through `class` or `style` (a string). In the Svelte package the placeholder blocks are both static members such as `Skeleton.Avatar` and the same components as named exports: `SkeletonAvatar`, `SkeletonImage`, `SkeletonTitle`, `SkeletonParagraph` and `SkeletonButton`.
|
|
16
|
+
|
|
17
|
+
## Demos
|
|
18
|
+
|
|
19
|
+
### How to import
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { Skeleton, SkeletonAvatar, SkeletonButton, SkeletonImage, SkeletonParagraph, SkeletonTitle } from '@fibrae/semi-ui-svelte';
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Skeleton loading>
|
|
27
|
+
{#snippet placeholder()}
|
|
28
|
+
<SkeletonAvatar />
|
|
29
|
+
{/snippet}
|
|
30
|
+
<p>Content</p>
|
|
31
|
+
</Skeleton>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The `placeholder` snippet is shown while loading, and `children` is shown once loading ends.
|
|
35
|
+
|
|
36
|
+
### Basic Usage
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
import { Avatar, Button, Skeleton, Switch } from '@fibrae/semi-ui-svelte';
|
|
41
|
+
|
|
42
|
+
let loading = $state(true);
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<span style="display: flex; align-items: center">
|
|
46
|
+
<Switch aria-labelledby="skeleton-basic-toggle" onChange={() => (loading = !loading)} />
|
|
47
|
+
<span id="skeleton-basic-toggle" style="margin-inline-start: 10px">显示加载内容</span>
|
|
48
|
+
</span>
|
|
49
|
+
<br />
|
|
50
|
+
<Skeleton {loading}>
|
|
51
|
+
{#snippet placeholder()}
|
|
52
|
+
<Skeleton.Avatar />
|
|
53
|
+
{/snippet}
|
|
54
|
+
<Avatar color="blue" style="margin-block-end: 10px">U</Avatar>
|
|
55
|
+
</Skeleton>
|
|
56
|
+
<br />
|
|
57
|
+
<Skeleton {loading} style="width: 200px; height: 150px">
|
|
58
|
+
{#snippet placeholder()}
|
|
59
|
+
<Skeleton.Image />
|
|
60
|
+
{/snippet}
|
|
61
|
+
<img alt="avatar" height="150" src="/assets/placeholder/avatar-a.svg" />
|
|
62
|
+
</Skeleton>
|
|
63
|
+
<br />
|
|
64
|
+
<Skeleton {loading} style="width: 80px">
|
|
65
|
+
{#snippet placeholder()}
|
|
66
|
+
<Skeleton.Title style="margin-block-end: 10px" />
|
|
67
|
+
{/snippet}
|
|
68
|
+
<h4 style="margin-block-end: 0">Semi UI</h4>
|
|
69
|
+
</Skeleton>
|
|
70
|
+
<Skeleton {loading} style="width: 240px">
|
|
71
|
+
{#snippet placeholder()}
|
|
72
|
+
<Skeleton.Paragraph rows={2} />
|
|
73
|
+
{/snippet}
|
|
74
|
+
<p style="width: 240px">精心打磨每一个组件的用户体验,从用户的角度考虑每个组件的使用场景。</p>
|
|
75
|
+
</Skeleton>
|
|
76
|
+
<br />
|
|
77
|
+
<Skeleton {loading}>
|
|
78
|
+
{#snippet placeholder()}
|
|
79
|
+
<Skeleton.Button />
|
|
80
|
+
{/snippet}
|
|
81
|
+
<Button>Button</Button>
|
|
82
|
+
</Skeleton>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Combinations
|
|
86
|
+
|
|
87
|
+
Image and caption.
|
|
88
|
+
|
|
89
|
+
```svelte
|
|
90
|
+
<script lang="ts">
|
|
91
|
+
import { Skeleton } from '@fibrae/semi-ui-svelte';
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<Skeleton loading>
|
|
95
|
+
{#snippet placeholder()}
|
|
96
|
+
<div>
|
|
97
|
+
<Skeleton.Image style="width: 200px; height: 150px" />
|
|
98
|
+
<Skeleton.Title style="width: 120px; margin-block-start: 10px" />
|
|
99
|
+
</div>
|
|
100
|
+
{/snippet}
|
|
101
|
+
<img alt="avatar" height="150" src="/assets/placeholder/avatar-a.svg" />
|
|
102
|
+
<h4>Semi UI</h4>
|
|
103
|
+
</Skeleton>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Statistics.
|
|
107
|
+
|
|
108
|
+
```svelte
|
|
109
|
+
<script lang="ts">
|
|
110
|
+
import { Descriptions, Skeleton } from '@fibrae/semi-ui-svelte';
|
|
111
|
+
|
|
112
|
+
const data = [{ key: '实际用户数量', value: '1,480,000' }];
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<Skeleton loading>
|
|
116
|
+
{#snippet placeholder()}
|
|
117
|
+
<div>
|
|
118
|
+
<Skeleton.Paragraph rows={1} style="width: 80px; margin-block-end: 10px" />
|
|
119
|
+
<Skeleton.Title style="width: 120px" />
|
|
120
|
+
</div>
|
|
121
|
+
{/snippet}
|
|
122
|
+
<Descriptions {data} row />
|
|
123
|
+
</Skeleton>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Avatar and title.
|
|
127
|
+
|
|
128
|
+
```svelte
|
|
129
|
+
<script lang="ts">
|
|
130
|
+
import { Avatar, Skeleton } from '@fibrae/semi-ui-svelte';
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<Skeleton loading>
|
|
134
|
+
{#snippet placeholder()}
|
|
135
|
+
<div style="display: flex; align-items: center">
|
|
136
|
+
<Skeleton.Avatar style="margin-inline-end: 12px" />
|
|
137
|
+
<Skeleton.Title style="width: 120px" />
|
|
138
|
+
</div>
|
|
139
|
+
{/snippet}
|
|
140
|
+
<Avatar color="blue" style="margin-inline-end: 12px">UI</Avatar>
|
|
141
|
+
<span>Semi UI</span>
|
|
142
|
+
</Skeleton>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Centered paragraphs and button.
|
|
146
|
+
|
|
147
|
+
```svelte
|
|
148
|
+
<script lang="ts">
|
|
149
|
+
import { Button, Skeleton } from '@fibrae/semi-ui-svelte';
|
|
150
|
+
|
|
151
|
+
const style = 'display: flex; flex-direction: column; align-items: center; width: 300px; margin-block-end: 10px';
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<Skeleton loading style="text-align: center">
|
|
155
|
+
{#snippet placeholder()}
|
|
156
|
+
<div {style}>
|
|
157
|
+
<Skeleton.Paragraph rows={3} {style} />
|
|
158
|
+
<Skeleton.Button />
|
|
159
|
+
</div>
|
|
160
|
+
{/snippet}
|
|
161
|
+
<div style="text-align: center">
|
|
162
|
+
<p>Hi, Semi dance dance.</p>
|
|
163
|
+
<p>Hi, Semi dance dance.</p>
|
|
164
|
+
<Button>Button</Button>
|
|
165
|
+
</div>
|
|
166
|
+
</Skeleton>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Avatar, headline and paragraph.
|
|
170
|
+
|
|
171
|
+
```svelte
|
|
172
|
+
<script lang="ts">
|
|
173
|
+
import { Avatar, Skeleton } from '@fibrae/semi-ui-svelte';
|
|
174
|
+
|
|
175
|
+
const style = 'display: flex; align-items: flex-start';
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<Skeleton loading>
|
|
179
|
+
{#snippet placeholder()}
|
|
180
|
+
<div {style}>
|
|
181
|
+
<Skeleton.Avatar style="margin-inline-end: 12px" />
|
|
182
|
+
<div>
|
|
183
|
+
<Skeleton.Title style="width: 120px; margin-block-end: 12px; margin-block-start: 12px" />
|
|
184
|
+
<Skeleton.Paragraph rows={3} style="width: 240px" />
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
{/snippet}
|
|
188
|
+
<div {style}>
|
|
189
|
+
<Avatar color="blue" style="margin-inline-end: 12px">UI</Avatar>
|
|
190
|
+
<div>
|
|
191
|
+
<h3>Semi UI</h3>
|
|
192
|
+
<p>Hi, Semi dance dance.</p>
|
|
193
|
+
<p>Hi, Semi dance dance.</p>
|
|
194
|
+
<p>Hi, Semi dance dance.</p>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
</Skeleton>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Table.
|
|
201
|
+
|
|
202
|
+
```svelte
|
|
203
|
+
<script lang="ts">
|
|
204
|
+
import { Skeleton, Table, type ColumnProps } from '@fibrae/semi-ui-svelte';
|
|
205
|
+
|
|
206
|
+
const columns: ColumnProps[] = [
|
|
207
|
+
{
|
|
208
|
+
title: 'Name',
|
|
209
|
+
dataIndex: 'name',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
title: 'Age',
|
|
213
|
+
dataIndex: 'age',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
title: 'Address',
|
|
217
|
+
dataIndex: 'address',
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
const dataSource = [
|
|
222
|
+
{
|
|
223
|
+
key: '1',
|
|
224
|
+
name: 'John Brown',
|
|
225
|
+
age: 32,
|
|
226
|
+
address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: '2',
|
|
230
|
+
name: 'Jim Green',
|
|
231
|
+
age: 42,
|
|
232
|
+
address: 'London No. 1 Lake Park',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
key: '3',
|
|
236
|
+
name: 'Joe Black',
|
|
237
|
+
age: 32,
|
|
238
|
+
address: 'Sidney No. 1 Lake Park',
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
key: '4',
|
|
242
|
+
name: 'Disabled User',
|
|
243
|
+
age: 99,
|
|
244
|
+
address: 'Sidney No. 1 Lake Park',
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
const placeholderColumns: ColumnProps[] = [1, 2, 3].map((key) => ({ dataIndex: `${key}` }));
|
|
249
|
+
const placeholderDataSource = [1, 2, 3, 4].map((key) => ({ key }));
|
|
250
|
+
</script>
|
|
251
|
+
|
|
252
|
+
<Skeleton loading>
|
|
253
|
+
{#snippet placeholder()}
|
|
254
|
+
<div style="position: relative">
|
|
255
|
+
<Table columns={placeholderColumns} dataSource={placeholderDataSource} pagination={false} style="background-color: var(--semi-color-bg-1)">
|
|
256
|
+
{#snippet headerCell()}
|
|
257
|
+
<Skeleton.Title style="width: 0" />
|
|
258
|
+
{/snippet}
|
|
259
|
+
{#snippet cell({ column })}
|
|
260
|
+
<Skeleton.Paragraph rows={1} style="width: {50 * Number(column.dataIndex)}px" />
|
|
261
|
+
{/snippet}
|
|
262
|
+
</Table>
|
|
263
|
+
<div style="position: absolute; inset: 0"></div>
|
|
264
|
+
</div>
|
|
265
|
+
{/snippet}
|
|
266
|
+
<div>
|
|
267
|
+
<Table {columns} {dataSource} pagination={false} />
|
|
268
|
+
</div>
|
|
269
|
+
</Skeleton>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Animated Loading
|
|
273
|
+
|
|
274
|
+
Use `active` property to display animated loading effects.
|
|
275
|
+
|
|
276
|
+
```svelte
|
|
277
|
+
<script lang="ts">
|
|
278
|
+
import { Avatar, Skeleton } from '@fibrae/semi-ui-svelte';
|
|
279
|
+
|
|
280
|
+
const style = 'display: flex; align-items: flex-start';
|
|
281
|
+
</script>
|
|
282
|
+
|
|
283
|
+
<Skeleton active loading>
|
|
284
|
+
{#snippet placeholder()}
|
|
285
|
+
<div {style}>
|
|
286
|
+
<Skeleton.Avatar style="margin-inline-end: 12px" />
|
|
287
|
+
<div>
|
|
288
|
+
<Skeleton.Title style="width: 120px; margin-block-end: 12px; margin-block-start: 12px" />
|
|
289
|
+
<Skeleton.Paragraph rows={3} style="width: 240px" />
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
{/snippet}
|
|
293
|
+
<div {style}>
|
|
294
|
+
<Avatar color="blue" style="margin-inline-end: 12px">UI</Avatar>
|
|
295
|
+
<div>
|
|
296
|
+
<h3>Semi UI</h3>
|
|
297
|
+
<p>Hi, Semi dance dance.</p>
|
|
298
|
+
<p>Hi, Semi dance dance.</p>
|
|
299
|
+
<p>Hi, Semi dance dance.</p>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</Skeleton>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## API reference
|
|
306
|
+
|
|
307
|
+
### Skeleton
|
|
308
|
+
|
|
309
|
+
**Props**
|
|
310
|
+
|
|
311
|
+
| Property | Description | Type | Default |
|
|
312
|
+
| - | - | - | - |
|
|
313
|
+
| active | Whether to show the animated loading effect. | `boolean` | - |
|
|
314
|
+
| children | Content shown once loading ends. | `Snippet` | - |
|
|
315
|
+
| loading | When true, the placeholder is shown. Otherwise the children are shown. | `boolean` | `true` |
|
|
316
|
+
| placeholder | Elements shown while loading. | `Snippet` | - |
|
|
317
|
+
|
|
318
|
+
`class`, `style` (a string) and native attributes and events fall through onto the placeholder root element. When `loading` is `false` the component renders only the children and has no root element, so these are dropped together with the placeholder. The root's `aria-busy="true"` cannot be switched off.
|
|
319
|
+
|
|
320
|
+
### Skeleton.Avatar
|
|
321
|
+
|
|
322
|
+
In Svelte, `Skeleton.Avatar` below can also be written as the named export `SkeletonAvatar`, and so on.
|
|
323
|
+
|
|
324
|
+
**Props**
|
|
325
|
+
|
|
326
|
+
| Property | Description | Type | Default |
|
|
327
|
+
| - | - | - | - |
|
|
328
|
+
| shape | Shape of the avatar placeholder: circle or square. | `'circle' \| 'square'` | - |
|
|
329
|
+
| size | Size of the avatar placeholder. | `'extra-extra-small' \| 'extra-large' \| 'extra-small' \| 'large' \| 'medium' \| 'small'` | - |
|
|
330
|
+
| type | Replaces the type of the block, which also names its class. Unless it is avatar, size and shape have no effect. | `string` | `"avatar"` |
|
|
331
|
+
|
|
332
|
+
`class`, `style` (a string) and native attributes and events fall through onto the placeholder block.
|
|
333
|
+
|
|
334
|
+
### Skeleton.Image
|
|
335
|
+
|
|
336
|
+
**Props**
|
|
337
|
+
|
|
338
|
+
| Property | Description | Type | Default |
|
|
339
|
+
| - | - | - | - |
|
|
340
|
+
| type | Replaces the type of the block, which also names its class. | `string` | `"image"` |
|
|
341
|
+
|
|
342
|
+
### Skeleton.Title
|
|
343
|
+
|
|
344
|
+
**Props**
|
|
345
|
+
|
|
346
|
+
| Property | Description | Type | Default |
|
|
347
|
+
| - | - | - | - |
|
|
348
|
+
| type | Replaces the type of the block, which also names its class. | `string` | `"title"` |
|
|
349
|
+
|
|
350
|
+
### Skeleton.Button
|
|
351
|
+
|
|
352
|
+
**Props**
|
|
353
|
+
|
|
354
|
+
| Property | Description | Type | Default |
|
|
355
|
+
| - | - | - | - |
|
|
356
|
+
| type | Replaces the type of the block, which also names its class. | `string` | `"button"` |
|
|
357
|
+
|
|
358
|
+
`SkeletonImage`, `SkeletonTitle` and `SkeletonButton` have no `size` or `shape`; `class`, `style` and native attributes and events fall through onto the placeholder block.
|
|
359
|
+
|
|
360
|
+
### Skeleton.Paragraph
|
|
361
|
+
|
|
362
|
+
**Props**
|
|
363
|
+
|
|
364
|
+
| Property | Description | Type | Default |
|
|
365
|
+
| - | - | - | - |
|
|
366
|
+
| rows | Number of rows in the placeholder paragraph. | `number` | `4` |
|
|
367
|
+
|
|
368
|
+
`class`, `style` (a string) and native attributes and events fall through onto the root `ul` element.
|
|
369
|
+
|
|
370
|
+
## Accessibility
|
|
371
|
+
|
|
372
|
+
- While loading, the outer element of Skeleton carries `aria-busy="true"`, and the placeholder blocks and paragraph carry `aria-hidden="true"`, so screen readers only know that content is loading. An `aria-hidden` passed by the caller takes precedence on a placeholder block; `aria-busy` cannot be switched off.
|
|
373
|
+
- Once loading ends, the children are rendered directly and Skeleton adds no outer element.
|
|
374
|
+
|
|
375
|
+
## Content Guidelines
|
|
376
|
+
|
|
377
|
+
- Unchanged fixed content directly displays fixed content, and variable content is displayed using skeleton screen
|
|
378
|
+
|
|
379
|
+
## Design Tokens
|
|
380
|
+
|
|
381
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/feedback/skeleton/>
|
|
382
|
+
|
|
383
|
+
## Changes from Semi Design
|
|
384
|
+
|
|
385
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
386
|
+
|
|
387
|
+
- Spin 的加载指示器由 `div` 改为 `<output>`;加载中被包裹内容带 `inert`(List、Table 的 `loading` 同样),不可聚焦;破坏性:删除 `wrapperClassName`(与根元素的 `className` 重复)和 `childStyle`,改用 `classNames.child`、`styles.child`,落在内容包裹元素上;破坏性(类型):Skeleton 占位的 `size` 只接受 `extra-extra-small` 到 `extra-large`,`shape` 只接受 `circle`、`square`,`Skeleton.Paragraph` 不再声明 `type`,`GenericProps` 即 `AvatarProps`。Vue:Spin 的 `indicator`、`tip`、Skeleton 的 `placeholder` 改为同名插槽;`Skeleton.Image`、`Title`、`Button` 不接受 `size`、`shape`;类型改名为 `SkeletonBasicProps`、`SkeletonAvatarProps`、`SkeletonParagraphProps`,`GenericProps` 删除。
|
|
388
|
+
- Svelte:Skeleton 的 `placeholder` 是 snippet,内容用 `children`;`Skeleton.Avatar`、`Title`、`Button`、`Image`、`Paragraph` 另有同一引用的具名导出 `SkeletonAvatar` 等。
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Spin
|
|
2
|
+
|
|
3
|
+
> Spin is used to inform the user that the content is loading and may take an uncertain period of time.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/feedback/spin/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Spin } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { Spin } from '@fibrae/semi-ui-svelte';
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div style="margin-inline-start: 30px">
|
|
25
|
+
<div style="margin-block-end: 10px">基本的加载器</div>
|
|
26
|
+
<Spin />
|
|
27
|
+
</div>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Size
|
|
31
|
+
|
|
32
|
+
Supports three sizes: `large`, `medium` (default), and `small`.
|
|
33
|
+
|
|
34
|
+
```svelte
|
|
35
|
+
<script lang="ts">
|
|
36
|
+
import { Spin } from '@fibrae/semi-ui-svelte';
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div style="margin-inline-start: 30px">
|
|
40
|
+
<div style="margin-block-end: 5px">size: small</div>
|
|
41
|
+
<Spin size="small" />
|
|
42
|
+
<br />
|
|
43
|
+
<br />
|
|
44
|
+
<div style="margin-block-end: 10px">size: middle</div>
|
|
45
|
+
<Spin size="middle" />
|
|
46
|
+
<br />
|
|
47
|
+
<br />
|
|
48
|
+
<div style="margin-block-end: 15px">size: large</div>
|
|
49
|
+
<Spin size="large" />
|
|
50
|
+
</div>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### With Description
|
|
54
|
+
|
|
55
|
+
Use the `tip` snippet to set the description texts when Spin is used as a wrapping element; the wrapped content is the `children` snippet, written inside the Spin tag.
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
import { Spin } from '@fibrae/semi-ui-svelte';
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div>
|
|
63
|
+
<Spin>
|
|
64
|
+
{#snippet tip()}加载中...{/snippet}
|
|
65
|
+
<div style="border: 1px solid var(--semi-color-primary); border-radius: 4px; padding-inline-start: 8px">
|
|
66
|
+
<p>这里是一些文字。</p>
|
|
67
|
+
<p>还有更多文字正在路上。</p>
|
|
68
|
+
</div>
|
|
69
|
+
</Spin>
|
|
70
|
+
</div>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Customized Indicator
|
|
74
|
+
|
|
75
|
+
Use the `indicator` snippet to customize Spin's indicator style.
|
|
76
|
+
|
|
77
|
+
```svelte
|
|
78
|
+
<script lang="ts">
|
|
79
|
+
import { IconLoading } from '@fibrae/semi-icons-svelte';
|
|
80
|
+
import { Spin } from '@fibrae/semi-ui-svelte';
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div style="margin-inline-start: 30px">
|
|
84
|
+
<div>自定义指示符的加载器</div>
|
|
85
|
+
<Spin>
|
|
86
|
+
{#snippet indicator()}
|
|
87
|
+
<IconLoading />
|
|
88
|
+
{/snippet}
|
|
89
|
+
</Spin>
|
|
90
|
+
</div>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Delay
|
|
94
|
+
|
|
95
|
+
Delayed to display Spin.
|
|
96
|
+
|
|
97
|
+
```svelte
|
|
98
|
+
<script lang="ts">
|
|
99
|
+
import { Button, Spin } from '@fibrae/semi-ui-svelte';
|
|
100
|
+
|
|
101
|
+
let loading = $state(false);
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<div>
|
|
105
|
+
<Button style="margin-inline-end: 20px" onclick={() => (loading = !loading)}>延迟显示的spin</Button>
|
|
106
|
+
<Spin delay={1000} spinning={loading} />
|
|
107
|
+
</div>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Controlled
|
|
111
|
+
|
|
112
|
+
Use `spinning` to determine if the component is in loading status
|
|
113
|
+
|
|
114
|
+
```svelte
|
|
115
|
+
<script lang="ts">
|
|
116
|
+
import { Button, Spin } from '@fibrae/semi-ui-svelte';
|
|
117
|
+
|
|
118
|
+
let loading = $state(false);
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<div>
|
|
122
|
+
<Button style="margin-inline-end: 20px" onclick={() => (loading = !loading)}>受控的 Spin</Button>
|
|
123
|
+
<Spin spinning={loading} />
|
|
124
|
+
</div>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## API Reference
|
|
128
|
+
|
|
129
|
+
**Props**
|
|
130
|
+
|
|
131
|
+
| Property | Description | Type | Default |
|
|
132
|
+
| - | - | - | - |
|
|
133
|
+
| children | Wrapped content. With content, Spin acts as a wrapper and carries `aria-busy` while loading, and the content cannot be focused or operated (inert). | `Snippet` | - |
|
|
134
|
+
| classNames | Class names of the inner parts, keyed by child (the element wrapping the content), appended after the built-in class names. | `Partial<Record<SpinPart, ClassValue>>` | - |
|
|
135
|
+
| delay | Delay in milliseconds before the loading effect is shown. | `number` | `0` |
|
|
136
|
+
| indicator | Snippet for a custom loading indicator. | `Snippet` | - |
|
|
137
|
+
| size | Component size. | `SpinSize` | `"middle"` |
|
|
138
|
+
| spinning | Whether it is loading. | `boolean` | `true` |
|
|
139
|
+
| styles | Style strings of the inner parts, keyed by child (the element wrapping the content). | `Partial<Record<SpinPart, string>>` | - |
|
|
140
|
+
| tip | Snippet for the description text, used when Spin acts as a wrapper. | `Snippet` | - |
|
|
141
|
+
|
|
142
|
+
`class`, `style` and native attributes and events land on the root `div` element.
|
|
143
|
+
|
|
144
|
+
While a Spin that wraps content is loading, the wrapped content is `inert`: it cannot be focused or operated, and the root carries `aria-busy`. If focus was inside the wrapped content, it moves to the Spin root first and returns to the original element when loading ends.
|
|
145
|
+
|
|
146
|
+
## Design Tokens
|
|
147
|
+
|
|
148
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/feedback/spin/>
|
|
149
|
+
|
|
150
|
+
## Content Guidelines
|
|
151
|
+
|
|
152
|
+
- Precisely state the loading status, using words such as "Loading", "Submitting", "Processing", etc.
|
|
153
|
+
- Use as few words as possible to describe the state
|
|
154
|
+
|
|
155
|
+
## FAQ
|
|
156
|
+
|
|
157
|
+
- **How to modify the color of the spin icon?**
|
|
158
|
+
|
|
159
|
+
You can override the original color by adding the color property to the .semi-spin-wrapper class (it is recommended to override with a higher weight).
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
.custom .semi-spin-wrapper {
|
|
163
|
+
color: red;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Changes from Semi Design
|
|
168
|
+
|
|
169
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
170
|
+
|
|
171
|
+
- Spin 的加载指示器由 `div` 改为 `<output>`;加载中被包裹内容带 `inert`(List、Table 的 `loading` 同样),不可聚焦;破坏性:删除 `wrapperClassName`(与根元素的 `className` 重复)和 `childStyle`,改用 `classNames.child`、`styles.child`,落在内容包裹元素上;破坏性(类型):Skeleton 占位的 `size` 只接受 `extra-extra-small` 到 `extra-large`,`shape` 只接受 `circle`、`square`,`Skeleton.Paragraph` 不再声明 `type`,`GenericProps` 即 `AvatarProps`。Vue:Spin 的 `indicator`、`tip`、Skeleton 的 `placeholder` 改为同名插槽;`Skeleton.Image`、`Title`、`Button` 不接受 `size`、`shape`;类型改名为 `SkeletonBasicProps`、`SkeletonAvatarProps`、`SkeletonParagraphProps`,`GenericProps` 删除。
|
|
172
|
+
- Svelte:Skeleton 的 `placeholder` 是 snippet,内容用 `children`;`Skeleton.Avatar`、`Title`、`Button`、`Image`、`Paragraph` 另有同一引用的具名导出 `SkeletonAvatar` 等。
|