@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,485 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
> Card container can consist of titles, paragraphs, pictures, lists, and other content.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/show/card/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Card, CardGroup, CardMeta } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`CardMeta` is the same component as `Card.Meta`; either form works.
|
|
18
|
+
|
|
19
|
+
### Basic card
|
|
20
|
+
|
|
21
|
+
The basic card contains the title, content and other parts.
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { Card, Typography } from '@fibrae/semi-ui-svelte';
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Card style="max-width: 360px" title="Semi Design">
|
|
29
|
+
{#snippet headerExtraContent()}
|
|
30
|
+
<Typography.Text link>更多</Typography.Text>
|
|
31
|
+
{/snippet}
|
|
32
|
+
Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。
|
|
33
|
+
</Card>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Simple card
|
|
37
|
+
|
|
38
|
+
The card can only set the content area.
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
import { IconInfoCircle } from '@fibrae/semi-icons-svelte';
|
|
43
|
+
import { Avatar, Card, Popover } from '@fibrae/semi-ui-svelte';
|
|
44
|
+
|
|
45
|
+
const styles = { body: 'display: flex; align-items: center; justify-content: space-between' };
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
{#snippet avatar()}
|
|
49
|
+
<Avatar alt="Card meta img" size="default" src="/assets/placeholder/logo.svg" />
|
|
50
|
+
{/snippet}
|
|
51
|
+
{#snippet content()}
|
|
52
|
+
<article style="padding: 6px">这是一个 Card</article>
|
|
53
|
+
{/snippet}
|
|
54
|
+
|
|
55
|
+
<Card style="max-width: 360px">Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。</Card>
|
|
56
|
+
<br />
|
|
57
|
+
<Card style="max-width: 360px" {styles}>
|
|
58
|
+
<Card.Meta {avatar} title="Semi Doc" />
|
|
59
|
+
<Popover {content} position="top" showArrow>
|
|
60
|
+
<IconInfoCircle aria-label="信息" style="color: var(--semi-color-primary)" />
|
|
61
|
+
</Popover>
|
|
62
|
+
</Card>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Cover
|
|
66
|
+
|
|
67
|
+
You can use the `cover` snippet to set the cover.
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<script lang="ts">
|
|
71
|
+
import { Card } from '@fibrae/semi-ui-svelte';
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
{#snippet cover()}
|
|
75
|
+
<img alt="example" src="/assets/root-web-sites/card-cover-docs-demo2.jpeg" />
|
|
76
|
+
{/snippet}
|
|
77
|
+
|
|
78
|
+
<Card {cover} style="max-width: 300px">
|
|
79
|
+
<Card.Meta title="卡片封面" />
|
|
80
|
+
</Card>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Border and line
|
|
84
|
+
|
|
85
|
+
You can use `bordered` to set whether the card has an outer border, the default is true. At the same time, you can also use `headerLine` to set whether the content area and title area have borders, and `footerLine` to set whether the content area and footer area have borders.
|
|
86
|
+
|
|
87
|
+
```svelte
|
|
88
|
+
<script lang="ts">
|
|
89
|
+
import { Card } from '@fibrae/semi-ui-svelte';
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<div style="display: inline-block; padding: 20px; background-color: var(--semi-color-fill-0)">
|
|
93
|
+
<Card bordered={false} headerLine style="max-width: 360px" title="Semi Design">Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。</Card>
|
|
94
|
+
</div>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Shadows
|
|
98
|
+
|
|
99
|
+
You can use `shadows` to set the timing of the shadow display. Optional: `hover` (show shadow when hover), `always` (show shadow always), if this property is not set, there will be no shadow.
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<script lang="ts">
|
|
103
|
+
import { IconInfoCircle } from '@fibrae/semi-icons-svelte';
|
|
104
|
+
import { Avatar, Card, Popover } from '@fibrae/semi-ui-svelte';
|
|
105
|
+
|
|
106
|
+
const styles = { body: 'display: flex; align-items: center; justify-content: space-between' };
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
{#snippet avatar()}
|
|
110
|
+
<Avatar alt="Card meta img" size="default" src="/assets/placeholder/logo.svg" />
|
|
111
|
+
{/snippet}
|
|
112
|
+
{#snippet content()}
|
|
113
|
+
<article style="padding: 6px">这是一个 Card</article>
|
|
114
|
+
{/snippet}
|
|
115
|
+
|
|
116
|
+
<div>
|
|
117
|
+
<Card shadows="hover" style="max-width: 360px" {styles}>
|
|
118
|
+
<Card.Meta {avatar} title="Semi Doc" />
|
|
119
|
+
<Popover {content} position="top" showArrow>
|
|
120
|
+
<IconInfoCircle aria-label="信息" style="color: var(--semi-color-primary)" />
|
|
121
|
+
</Popover>
|
|
122
|
+
</Card>
|
|
123
|
+
<br />
|
|
124
|
+
<Card shadows="always" style="max-width: 360px" {styles}>
|
|
125
|
+
<Card.Meta {avatar} title="Semi Doc" />
|
|
126
|
+
<Popover {content} position="top" showArrow>
|
|
127
|
+
<IconInfoCircle aria-label="信息" style="color: var(--semi-color-primary)" />
|
|
128
|
+
</Popover>
|
|
129
|
+
</Card>
|
|
130
|
+
</div>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Customized content
|
|
134
|
+
|
|
135
|
+
You can use `CardMeta` to support more flexible content, allowing you to set `title`, `avatar`, and `description`. The last two are snippets, and `title` can be a string or a snippet.
|
|
136
|
+
|
|
137
|
+
```svelte
|
|
138
|
+
<script lang="ts">
|
|
139
|
+
import { Avatar, Button, Card, Space, Typography } from '@fibrae/semi-ui-svelte';
|
|
140
|
+
</script>
|
|
141
|
+
|
|
142
|
+
{#snippet title()}
|
|
143
|
+
<Card.Meta title="Semi Doc">
|
|
144
|
+
{#snippet description()}全面、易用、优质{/snippet}
|
|
145
|
+
{#snippet avatar()}
|
|
146
|
+
<Avatar alt="Card meta img" size="default" src="/assets/placeholder/logo.svg" />
|
|
147
|
+
{/snippet}
|
|
148
|
+
</Card.Meta>
|
|
149
|
+
{/snippet}
|
|
150
|
+
{#snippet headerExtraContent()}
|
|
151
|
+
<Typography.Text link>More</Typography.Text>
|
|
152
|
+
{/snippet}
|
|
153
|
+
{#snippet cover()}
|
|
154
|
+
<img alt="example" src="/assets/root-web-sites/card-cover-docs-demo.jpeg" />
|
|
155
|
+
{/snippet}
|
|
156
|
+
{#snippet footer()}
|
|
157
|
+
<Space>
|
|
158
|
+
<Button theme="borderless" type="primary">精选案例</Button>
|
|
159
|
+
<Button theme="solid" type="primary">开始使用</Button>
|
|
160
|
+
</Space>
|
|
161
|
+
{/snippet}
|
|
162
|
+
|
|
163
|
+
<Card {cover} {footer} footerLine {headerExtraContent} style="max-width: 340px" styles={{ footer: 'display: flex; justify-content: flex-end' }} {title}>Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。</Card>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Inner card
|
|
167
|
+
|
|
168
|
+
Other cards can be nested inside the card.
|
|
169
|
+
|
|
170
|
+
```svelte
|
|
171
|
+
<script lang="ts">
|
|
172
|
+
import { Card, Typography } from '@fibrae/semi-ui-svelte';
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<Card title="Card title">
|
|
176
|
+
<Card style="margin-bottom: 20px" title="Inner Card title">
|
|
177
|
+
{#snippet headerExtraContent()}
|
|
178
|
+
<Typography.Text link>More</Typography.Text>
|
|
179
|
+
{/snippet}
|
|
180
|
+
Inner Card content
|
|
181
|
+
</Card>
|
|
182
|
+
<Card title="Inner Card title">
|
|
183
|
+
{#snippet headerExtraContent()}
|
|
184
|
+
<Typography.Text link>More</Typography.Text>
|
|
185
|
+
{/snippet}
|
|
186
|
+
Inner Card content
|
|
187
|
+
</Card>
|
|
188
|
+
</Card>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Card in column
|
|
192
|
+
|
|
193
|
+
The system overview page is often combined with the grid.
|
|
194
|
+
|
|
195
|
+
```svelte
|
|
196
|
+
<script lang="ts">
|
|
197
|
+
import { Card, Col, Row } from '@fibrae/semi-ui-svelte';
|
|
198
|
+
</script>
|
|
199
|
+
|
|
200
|
+
<div style="background-color: var(--semi-color-fill-0); padding: 20px">
|
|
201
|
+
<Row gutter={[16, 16]}>
|
|
202
|
+
<Col span={8}>
|
|
203
|
+
<Card bordered={false} title="Card Title">Card Content</Card>
|
|
204
|
+
</Col>
|
|
205
|
+
<Col span={8}>
|
|
206
|
+
<Card bordered={false} title="Card Title">Card Content</Card>
|
|
207
|
+
</Col>
|
|
208
|
+
<Col span={8}>
|
|
209
|
+
<Card bordered={false} title="Card Title">Card Content</Card>
|
|
210
|
+
</Col>
|
|
211
|
+
</Row>
|
|
212
|
+
<Row gutter={[16, 16]}>
|
|
213
|
+
<Col span={16}>
|
|
214
|
+
<Card bordered={false} title="Card Title">Card Content</Card>
|
|
215
|
+
</Col>
|
|
216
|
+
<Col span={8}>
|
|
217
|
+
<Card bordered={false} title="Card Title">Card Content</Card>
|
|
218
|
+
</Col>
|
|
219
|
+
</Row>
|
|
220
|
+
</div>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### loading
|
|
224
|
+
|
|
225
|
+
You can use the `loading` property of `Card` to set whether to display placeholder elements in the card content area. When it is true, the placeholder elements will be displayed, and vice versa.
|
|
226
|
+
|
|
227
|
+
```svelte
|
|
228
|
+
<script lang="ts">
|
|
229
|
+
import { Card, Switch } from '@fibrae/semi-ui-svelte';
|
|
230
|
+
|
|
231
|
+
let loading = $state(true);
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<Switch aria-label="显示内容" onChange={(v) => (loading = !v)} />
|
|
235
|
+
<br />
|
|
236
|
+
<br />
|
|
237
|
+
<Card {loading} style="max-width: 360px">
|
|
238
|
+
<Card.Meta title="Semi Doc">
|
|
239
|
+
{#snippet description()}全面、易用、优质{/snippet}
|
|
240
|
+
</Card.Meta>
|
|
241
|
+
</Card>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### With Skeleton
|
|
245
|
+
|
|
246
|
+
The `loading` property of `Card` can only set the preloading effect of the content area. If you want to set the preloading of other parts, or customize a richer preloading effect, you can combine it with the Skeleton component.
|
|
247
|
+
|
|
248
|
+
```svelte
|
|
249
|
+
<script lang="ts">
|
|
250
|
+
import { Avatar, Card, Skeleton, Switch, Typography } from '@fibrae/semi-ui-svelte';
|
|
251
|
+
|
|
252
|
+
let loading = $state(true);
|
|
253
|
+
</script>
|
|
254
|
+
|
|
255
|
+
{#snippet title()}
|
|
256
|
+
<Card.Meta>
|
|
257
|
+
{#snippet title()}
|
|
258
|
+
<Skeleton {loading} style="width: 80px">
|
|
259
|
+
{#snippet placeholder()}<Skeleton.Title />{/snippet}
|
|
260
|
+
<Typography.Title heading={5}>Semi Doc</Typography.Title>
|
|
261
|
+
</Skeleton>
|
|
262
|
+
{/snippet}
|
|
263
|
+
{#snippet description()}
|
|
264
|
+
<Skeleton {loading} style="width: 150px; margin-top: 12px">
|
|
265
|
+
{#snippet placeholder()}<Skeleton.Paragraph rows={1} />{/snippet}
|
|
266
|
+
<Typography.Text>全面、易用、优质</Typography.Text>
|
|
267
|
+
</Skeleton>
|
|
268
|
+
{/snippet}
|
|
269
|
+
{#snippet avatar()}
|
|
270
|
+
<Skeleton {loading}>
|
|
271
|
+
{#snippet placeholder()}<Skeleton.Avatar />{/snippet}
|
|
272
|
+
<Avatar alt="Card meta img" size="default" src="/assets/placeholder/logo.svg" />
|
|
273
|
+
</Skeleton>
|
|
274
|
+
{/snippet}
|
|
275
|
+
</Card.Meta>
|
|
276
|
+
{/snippet}
|
|
277
|
+
{#snippet headerExtraContent()}
|
|
278
|
+
<Skeleton {loading} style="width: 50px">
|
|
279
|
+
{#snippet placeholder()}<Skeleton.Paragraph rows={1} />{/snippet}
|
|
280
|
+
<Typography.Text link>More</Typography.Text>
|
|
281
|
+
</Skeleton>
|
|
282
|
+
{/snippet}
|
|
283
|
+
{#snippet cover()}
|
|
284
|
+
<Skeleton {loading} style="max-width: 100%; height: 220px">
|
|
285
|
+
{#snippet placeholder()}<Skeleton.Image />{/snippet}
|
|
286
|
+
<img alt="example" src="/assets/root-web-sites/card-cover-docs-demo.jpeg" />
|
|
287
|
+
</Skeleton>
|
|
288
|
+
{/snippet}
|
|
289
|
+
|
|
290
|
+
<Switch aria-label="显示内容" onChange={(v) => (loading = !v)} />
|
|
291
|
+
<br />
|
|
292
|
+
<br />
|
|
293
|
+
<Card {cover} {headerExtraContent} style="max-width: 300px" {title} />
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### With tabs
|
|
297
|
+
|
|
298
|
+
You can use the `Tabs` component in the card component.
|
|
299
|
+
|
|
300
|
+
```svelte
|
|
301
|
+
<script lang="ts">
|
|
302
|
+
import { Card, Tabs } from '@fibrae/semi-ui-svelte';
|
|
303
|
+
|
|
304
|
+
const tabList = [
|
|
305
|
+
{ itemKey: '1', tab: 'Tab 1' },
|
|
306
|
+
{ itemKey: '2', tab: 'Tab 2' },
|
|
307
|
+
];
|
|
308
|
+
</script>
|
|
309
|
+
|
|
310
|
+
<Card title="Card title">
|
|
311
|
+
<Tabs style="margin-top: -20px; margin-bottom: -20px" {tabList} type="line">
|
|
312
|
+
{#snippet panel(tab)}
|
|
313
|
+
<p>content{tab.itemKey}</p>
|
|
314
|
+
<p>content{tab.itemKey}</p>
|
|
315
|
+
<p>content{tab.itemKey}</p>
|
|
316
|
+
{/snippet}
|
|
317
|
+
</Tabs>
|
|
318
|
+
</Card>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Actions
|
|
322
|
+
|
|
323
|
+
`actions` receives an array of snippets, each one is an action, displayed at the bottom of the content area with a horizontal spacing of 12px.
|
|
324
|
+
|
|
325
|
+
```svelte
|
|
326
|
+
<script lang="ts">
|
|
327
|
+
import { Card, Rating } from '@fibrae/semi-ui-svelte';
|
|
328
|
+
</script>
|
|
329
|
+
|
|
330
|
+
{#snippet cover()}
|
|
331
|
+
<img alt="example" src="/assets/root-web-sites/card-cover-docs-demo.jpeg" />
|
|
332
|
+
{/snippet}
|
|
333
|
+
{#snippet rating()}
|
|
334
|
+
<Rating size="small" value={4} />
|
|
335
|
+
{/snippet}
|
|
336
|
+
|
|
337
|
+
<Card actions={[rating]} {cover} headerLine={false} style="max-width: 300px">
|
|
338
|
+
<Card.Meta title="Semi Doc">
|
|
339
|
+
{#snippet description()}全面、易用、优质{/snippet}
|
|
340
|
+
</Card.Meta>
|
|
341
|
+
</Card>
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Card group
|
|
345
|
+
|
|
346
|
+
Use `CardGroup` to present the cards in an evenly spaced arrangement.
|
|
347
|
+
|
|
348
|
+
```svelte
|
|
349
|
+
<script lang="ts">
|
|
350
|
+
import { Card, CardGroup, Slider, Typography } from '@fibrae/semi-ui-svelte';
|
|
351
|
+
|
|
352
|
+
const cardIndexes = Array.from({ length: 8 }, (_, index) => index);
|
|
353
|
+
|
|
354
|
+
let spacing = $state(12);
|
|
355
|
+
|
|
356
|
+
const onSpacingChange = (value: number | number[]) => {
|
|
357
|
+
if (typeof value === 'number') spacing = value;
|
|
358
|
+
};
|
|
359
|
+
</script>
|
|
360
|
+
|
|
361
|
+
<Typography.Text id="card-group-spacing">滑动调节 Card 间距</Typography.Text>
|
|
362
|
+
<Slider aria-labelledby="card-group-spacing" max={40} min={10} onChange={onSpacingChange} style="width: 360px" value={12} />
|
|
363
|
+
<br />
|
|
364
|
+
<CardGroup {spacing}>
|
|
365
|
+
{#each cardIndexes as idx (idx)}
|
|
366
|
+
<Card headerLine={false} shadows="hover" style="width: 260px" title="Card title">
|
|
367
|
+
{#snippet headerExtraContent()}
|
|
368
|
+
<Typography.Text link>More</Typography.Text>
|
|
369
|
+
{/snippet}
|
|
370
|
+
<Typography.Text>Card content</Typography.Text>
|
|
371
|
+
</Card>
|
|
372
|
+
{/each}
|
|
373
|
+
</CardGroup>
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Grid card
|
|
377
|
+
|
|
378
|
+
You can use the `type` property of `CardGroup` to set the card group to a grid type.
|
|
379
|
+
|
|
380
|
+
```svelte
|
|
381
|
+
<script lang="ts">
|
|
382
|
+
import { Card, CardGroup, Typography } from '@fibrae/semi-ui-svelte';
|
|
383
|
+
|
|
384
|
+
const cardIndexes = Array.from({ length: 7 }, (_, index) => index);
|
|
385
|
+
</script>
|
|
386
|
+
|
|
387
|
+
<CardGroup type="grid">
|
|
388
|
+
{#each cardIndexes as idx (idx)}
|
|
389
|
+
<Card headerLine={false} shadows="hover" style="width: 260px" title="Card title">
|
|
390
|
+
{#snippet headerExtraContent()}
|
|
391
|
+
<Typography.Text link>More</Typography.Text>
|
|
392
|
+
{/snippet}
|
|
393
|
+
<Typography.Text>Card content</Typography.Text>
|
|
394
|
+
</Card>
|
|
395
|
+
{/each}
|
|
396
|
+
</CardGroup>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### API reference
|
|
400
|
+
|
|
401
|
+
**Card**
|
|
402
|
+
|
|
403
|
+
**Props**
|
|
404
|
+
|
|
405
|
+
| Property | Description | Type | Default |
|
|
406
|
+
| - | - | - | - |
|
|
407
|
+
| actions | Actions at the bottom of the content area, spaced 12px apart; every snippet becomes one action. | `Snippet[]` | - |
|
|
408
|
+
| bordered | Whether the card has an outer border. | `boolean` | `true` |
|
|
409
|
+
| children | Card content. | `Snippet` | - |
|
|
410
|
+
| classNames | Class names of the inner parts, keyed by header, title, extra, cover, body, actions and footer; values take anything class takes (string, array or object) and merge with the built-in classes. | `Partial<Record<CardPart, ClassValue>>` | - |
|
|
411
|
+
| cover | Card cover. | `Snippet` | - |
|
|
412
|
+
| footer | Custom footer. | `Snippet` | - |
|
|
413
|
+
| footerLine | Whether there is a border between the footer and the content area. | `boolean` | `false` |
|
|
414
|
+
| header | Custom header that replaces title and headerExtraContent. | `Snippet` | - |
|
|
415
|
+
| headerExtraContent | Extra content to the right of the title. | `Snippet` | - |
|
|
416
|
+
| headerLine | Whether there is a border between the header and the content area. | `boolean` | `true` |
|
|
417
|
+
| loading | Whether the content area shows a loading placeholder; the root element's aria-busy is true while on. | `boolean` | `false` |
|
|
418
|
+
| shadows | When to show the shadow: hover or always. No shadow when unset. | `Shadows` | - |
|
|
419
|
+
| styles | Style strings of the inner parts, keyed like classNames. | `Partial<Record<CardPart, string>>` | - |
|
|
420
|
+
| title | Title. A string renders as a div styled like a level-6 heading and truncated with a tooltip when too long; a snippet renders as it is. | `string \| Snippet` | - |
|
|
421
|
+
|
|
422
|
+
`class`, `style` and native attributes and events (such as `id`, `aria-*`, `onclick`) land on the root element (`div`).
|
|
423
|
+
|
|
424
|
+
**CardGroup**
|
|
425
|
+
|
|
426
|
+
**Props**
|
|
427
|
+
|
|
428
|
+
| Property | Description | Type | Default |
|
|
429
|
+
| - | - | - | - |
|
|
430
|
+
| align | Cross-axis alignment of the children, passed to Space: start, center, end or baseline. | `Align` | - |
|
|
431
|
+
| children | The cards to arrange. | `Snippet` | - |
|
|
432
|
+
| spacing | Spacing between cards, a number or \[horizontal, vertical]; ignored when type is grid. | `number \| [number, number]` | `16` |
|
|
433
|
+
| type | Set to grid for a grid layout, which overrides spacing. | `CardGroupType` | - |
|
|
434
|
+
| vertical | Whether to lay out vertically, passed to Space. | `boolean` | `false` |
|
|
435
|
+
| wrap | Whether to wrap, passed to Space; ignored when vertical. | `boolean` | `true` |
|
|
436
|
+
|
|
437
|
+
`class`, `style` and native attributes and events land on the root element of the inner `Space`.
|
|
438
|
+
|
|
439
|
+
**Card.Meta**
|
|
440
|
+
|
|
441
|
+
**Props**
|
|
442
|
+
|
|
443
|
+
| Property | Description | Type | Default |
|
|
444
|
+
| - | - | - | - |
|
|
445
|
+
| avatar | Avatar. | `Snippet` | - |
|
|
446
|
+
| description | Description. | `Snippet` | - |
|
|
447
|
+
| title | Title, a string or a snippet. | `string \| Snippet` | - |
|
|
448
|
+
|
|
449
|
+
`class`, `style` and native attributes and events (such as `id`, `aria-*`, `onclick`) land on the root element (`div`).
|
|
450
|
+
|
|
451
|
+
## Accessibility
|
|
452
|
+
|
|
453
|
+
- Card supports the input of `aria-label` or `aria-labelledby` to indicate the function of the Card; the root element then gets `role="group"` (an explicit `role` wins)
|
|
454
|
+
- When Card loading, `aria-busy` will be turned on
|
|
455
|
+
- A string `title` is styled as an h6 but rendered as a `div` without heading semantics, so it does not disturb the page's heading levels; pass your own heading element as `title` when you need one (in Vue, put it in the `#title` slot)
|
|
456
|
+
- Card is a container-type component, and any elements inside the card need to follow their respective accessibility guidelines
|
|
457
|
+
|
|
458
|
+
## Content Guidelines
|
|
459
|
+
|
|
460
|
+
- Card title
|
|
461
|
+
- Card titles should be informative and focus on the most important information
|
|
462
|
+
- try to limit the title to 1 phrase or segment
|
|
463
|
+
- Card titles should be written in sentence case
|
|
464
|
+
- do not end with punctuation marks (except question marks)
|
|
465
|
+
- Text
|
|
466
|
+
- Actionable: Use imperative sentences instead of "you can" to describe the body, which better tells the user what can be done
|
|
467
|
+
|
|
468
|
+
| ✅ Recommended usage | ❌ Deprecated usage |
|
|
469
|
+
| - | - |
|
|
470
|
+
| Get order progress for details | You can get order progress for details |
|
|
471
|
+
|
|
472
|
+
- Always say the most important information first
|
|
473
|
+
- Use "Need to" instead of "must"
|
|
474
|
+
|
|
475
|
+
## Design Tokens
|
|
476
|
+
|
|
477
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/show/card/>
|
|
478
|
+
|
|
479
|
+
## Changes from Semi Design
|
|
480
|
+
|
|
481
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
482
|
+
|
|
483
|
+
- 破坏性:删除 `bodyStyle`、`headerStyle`、`footerStyle`,改用按部位分键的 `classNames` 与 `styles`,部位为 `header`、`title`、`extra`、`cover`、`body`、`actions`、`footer`;`classNames` 与组件自带的类名合并,根元素仍用 `className`(Vue、Solid、Svelte 为 `class`)与 `style`。`overrideDefaultProps` 里的 `classNames`、`styles` 是默认值,组件传入时整体替换,不逐键合并。
|
|
484
|
+
- 字符串 `title` 渲染为 `div`(外观仍是 6 号标题),不再是 `h6`;`headerExtraContent` 在 DOM 中位于 title 之后;`header`、`cover`、`footer` 为 `0` 时渲染在各自容器内。
|
|
485
|
+
- Svelte:`title` 是 `string | Snippet`,字符串渲染为带单行省略 Tooltip 的 6 号标题,snippet 原样渲染;`headerExtraContent`、`header`、`cover`、`footer` 是 snippet,`children` 是正文;`actions` 是 `Snippet[]`,每个元素一项;`styles` 的值只接受字符串,`classNames` 的值同 `class`;`loading` 时只要传了 `children` 就显示骨架屏;子组件 `Card.Meta` 与具名导出 `CardMeta` 是同一个组件(`title`、`avatar`、`description`)。
|