@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,103 @@
|
|
|
1
|
+
# Divider
|
|
2
|
+
|
|
3
|
+
> Divider is a linear, lightweight component used to logically organize element content and page structure or areas.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/basic/divider/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Divider } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic Usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { Divider } from '@fibrae/semi-ui-svelte';
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div>
|
|
25
|
+
<h3>水平实线</h3>
|
|
26
|
+
<span>Semi Design 是一个设计系统。</span>
|
|
27
|
+
<Divider margin="12px" />
|
|
28
|
+
<span>它定义了一套中后台设计与前端基础组件。</span>
|
|
29
|
+
|
|
30
|
+
<h3 style="margin-block-start: 40px">水平虚线</h3>
|
|
31
|
+
<span>Semi Design 是一个设计系统。</span>
|
|
32
|
+
<Divider dashed margin="12px" />
|
|
33
|
+
<span>它定义了一套中后台设计与前端基础组件。</span>
|
|
34
|
+
|
|
35
|
+
<h3 style="margin-block-start: 40px">垂直实线</h3>
|
|
36
|
+
|
|
37
|
+
<div>
|
|
38
|
+
<span>左</span>
|
|
39
|
+
<Divider layout="vertical" margin="12px" />
|
|
40
|
+
<span>中</span>
|
|
41
|
+
<Divider layout="vertical" margin="12px" />
|
|
42
|
+
<span>右</span>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<h3 style="margin-block-start: 40px">垂直虚线</h3>
|
|
46
|
+
<div>
|
|
47
|
+
<span>左</span>
|
|
48
|
+
<Divider dashed layout="vertical" margin="12px" />
|
|
49
|
+
<span>中</span>
|
|
50
|
+
<Divider dashed layout="vertical" margin="12px" />
|
|
51
|
+
<span>右</span>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### With Children
|
|
57
|
+
|
|
58
|
+
The content of a horizontal divider is written inside the tag (`children`); a vertical divider shows no content. For a horizontal divider with content, the content is always wrapped in `semi-divider_inner-text`, whether it is plain text or an element.
|
|
59
|
+
|
|
60
|
+
```svelte
|
|
61
|
+
<script lang="ts">
|
|
62
|
+
import { IconSemiLogo } from '@fibrae/semi-icons-svelte';
|
|
63
|
+
import { Divider } from '@fibrae/semi-ui-svelte';
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<div>
|
|
67
|
+
<Divider align="left" margin="12px">这是居左文字</Divider>
|
|
68
|
+
|
|
69
|
+
<Divider align="center" margin="12px">这是居中文字</Divider>
|
|
70
|
+
|
|
71
|
+
<Divider align="right" margin="12px">这是居右文字</Divider>
|
|
72
|
+
|
|
73
|
+
<Divider margin="12px">
|
|
74
|
+
<IconSemiLogo />
|
|
75
|
+
</Divider>
|
|
76
|
+
</div>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## API Reference
|
|
80
|
+
|
|
81
|
+
**Props**
|
|
82
|
+
|
|
83
|
+
| Property | Description | Type | Default |
|
|
84
|
+
| - | - | - | - |
|
|
85
|
+
| align | Alignment of the content: left, center or right. | `'center' \| 'left' \| 'right'` | `"center"` |
|
|
86
|
+
| children | Content of a horizontal divider. A vertical divider shows no content. | `Snippet` | - |
|
|
87
|
+
| dashed | Whether the line is dashed. | `boolean` | - |
|
|
88
|
+
| layout | Direction of the divider: horizontal or vertical. | `'horizontal' \| 'vertical'` | `"horizontal"` |
|
|
89
|
+
| margin | Margin above and below the divider, or left and right when vertical. A number is in pixels. | `number \| string` | - |
|
|
90
|
+
|
|
91
|
+
`class`, `style` and other native attributes land on the root element; `style` comes after `margin`, so your value wins. The default `role` is `separator`, which is not set when the divider has content; a `role` you pass overrides the default.
|
|
92
|
+
|
|
93
|
+
## Design Tokens
|
|
94
|
+
|
|
95
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/basic/divider/>
|
|
96
|
+
|
|
97
|
+
## Changes from Semi Design
|
|
98
|
+
|
|
99
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
100
|
+
|
|
101
|
+
- `children` 全是文本(含数字 `0`)时包进 `semi-divider_inner-text`;无文字内容时根元素带 `role="separator"`,可用 `role` 覆盖。Vue:内容用默认插槽,规则相同。
|
|
102
|
+
- Svelte:`layout` 为 horizontal 且传了 `children` 时算带文字,内容一律包进 `semi-divider_inner-text`(不区分纯文本与元素)。
|
|
103
|
+
- 破坏性(深路径导入):`@fibrae/semi-foundation/divider/constants` 的 `cssClasses.PREFIX` 由 `semi` 改为 `semi-divider`。
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# FloatButton
|
|
2
|
+
|
|
3
|
+
> A floating button is an actionable button that can float on the page
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/basic/float-button/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { FloatButton, FloatButtonGroup } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
22
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
23
|
+
|
|
24
|
+
const onclick = () => {
|
|
25
|
+
console.log('float button clicked');
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<span>基本使用:页面右下第三列 1 </span>
|
|
30
|
+
<FloatButton aria-label="AI 编辑" style="inset-block-end: 270px" {onclick}>
|
|
31
|
+
{#snippet icon()}
|
|
32
|
+
<IconAIEditLevel1 />
|
|
33
|
+
{/snippet}
|
|
34
|
+
</FloatButton>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Size
|
|
38
|
+
|
|
39
|
+
Three sizes are supported: default, small, large.
|
|
40
|
+
|
|
41
|
+
```svelte
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
44
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
45
|
+
|
|
46
|
+
const onclick = () => {
|
|
47
|
+
console.log('float button clicked');
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<span>大尺寸:页面右下第三列 2</span>
|
|
52
|
+
<FloatButton aria-label="AI 编辑" size="large" style="inset-block-end: 200px" {onclick}>
|
|
53
|
+
{#snippet icon()}
|
|
54
|
+
<IconAIEditLevel1 />
|
|
55
|
+
{/snippet}
|
|
56
|
+
</FloatButton>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Shape
|
|
60
|
+
|
|
61
|
+
Two shapes are defined by default: round (default) and square.
|
|
62
|
+
|
|
63
|
+
```svelte
|
|
64
|
+
<script lang="ts">
|
|
65
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
66
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
67
|
+
|
|
68
|
+
const onclick = () => {
|
|
69
|
+
console.log('float button clicked');
|
|
70
|
+
};
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<span>方形:页面右下第三列 3</span>
|
|
74
|
+
<FloatButton aria-label="AI 编辑" shape="square" style="inset-block-end: 150px" {onclick}>
|
|
75
|
+
{#snippet icon()}
|
|
76
|
+
<IconAIEditLevel1 />
|
|
77
|
+
{/snippet}
|
|
78
|
+
</FloatButton>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Click to jump
|
|
82
|
+
|
|
83
|
+
With `href` set, the button renders as a native `<a>` link: `target` specifies the window or frame in which the linked page opens, and `rel` the relationship to it. Opening in a new tab with the middle button and copying the link address from the context menu are native browser behaviour. Without `href` it renders as a native `<button type="button">`.
|
|
84
|
+
|
|
85
|
+
```svelte
|
|
86
|
+
<script lang="ts">
|
|
87
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
88
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<span>点击跳转:页面右下第三列 4</span>
|
|
92
|
+
<FloatButton aria-label="访问 Semi 官网" href="https://semi-design-next.pages.dev/" rel="noopener noreferrer" style="inset-block-end: 100px" target="_blank">
|
|
93
|
+
{#snippet icon()}
|
|
94
|
+
<IconAIEditLevel1 />
|
|
95
|
+
{/snippet}
|
|
96
|
+
</FloatButton>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### AI style - Colorful floating buttons
|
|
100
|
+
|
|
101
|
+
You can set `colorful` to true to display colorful floating buttons.
|
|
102
|
+
|
|
103
|
+
```svelte
|
|
104
|
+
<script lang="ts">
|
|
105
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
106
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<span>多彩按钮:页面右下第一列</span>
|
|
110
|
+
<FloatButton aria-label="访问 Semi 官网" colorful href="https://semi-design-next.pages.dev/" rel="noopener noreferrer" style="inset-block-end: 110px; inset-inline-end: 150px" target="_blank">
|
|
111
|
+
{#snippet icon()}
|
|
112
|
+
<IconAIEditLevel1 />
|
|
113
|
+
{/snippet}
|
|
114
|
+
</FloatButton>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Badge
|
|
118
|
+
|
|
119
|
+
```svelte
|
|
120
|
+
<script lang="ts">
|
|
121
|
+
import { IconAIEditLevel1 } from '@fibrae/semi-icons-svelte';
|
|
122
|
+
import { FloatButton } from '@fibrae/semi-ui-svelte';
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
{#snippet icon()}
|
|
126
|
+
<IconAIEditLevel1 />
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
129
|
+
<span>带徽章:页面右下第二列</span>
|
|
130
|
+
<FloatButton aria-label="AI 编辑" badge={{ dot: true, type: 'danger' }} disabled {icon} style="inset-block-end: 270px; inset-inline-end: 100px" />
|
|
131
|
+
<FloatButton aria-label="AI 编辑,999+" badge={{ count: 1000, overflowCount: 999 }} {icon} size="large" style="inset-block-end: 210px; inset-inline-end: 100px" />
|
|
132
|
+
<FloatButton aria-label="AI 编辑" badge={{ dot: true }} colorful {icon} style="inset-block-end: 170px; inset-inline-end: 100px" />
|
|
133
|
+
<FloatButton aria-label="AI 编辑,VIP" badge={{ count: 'VIP', type: 'danger' }} colorful {icon} size="large" style="inset-block-end: 110px; inset-inline-end: 100px" />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Floating button Group
|
|
137
|
+
|
|
138
|
+
Subitems can be passed in via `items`, and their icons come from the `icon` snippet, which receives `{ item, index }`. Like a single FloatButton, each item renders as a native button or link and honours its own `href`, `target`, `rel`, `disabled` and `onClick`; clicking an item calls its `onClick(event)` first, then the group's `onClick(value, event)`. The group's `disabled` disables every item.
|
|
139
|
+
|
|
140
|
+
```svelte
|
|
141
|
+
<script lang="ts">
|
|
142
|
+
import { IconAIStrokedLevel3, IconHelpCircleStroked, IconSearchStroked } from '@fibrae/semi-icons-svelte';
|
|
143
|
+
import { FloatButtonGroup } from '@fibrae/semi-ui-svelte';
|
|
144
|
+
|
|
145
|
+
const icons = [IconAIStrokedLevel3, IconSearchStroked, IconHelpCircleStroked];
|
|
146
|
+
|
|
147
|
+
const items = [
|
|
148
|
+
{ content: '编辑', value: 'editor' },
|
|
149
|
+
{ content: '搜索', value: 'search', disabled: true },
|
|
150
|
+
{ content: '帮助', value: 'help', href: 'https://semi-design-next.pages.dev/', target: '_blank' },
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
const onClick = (value?: string) => {
|
|
154
|
+
console.log('点击了 ', value);
|
|
155
|
+
};
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<span>页面右下方最后一行</span>
|
|
159
|
+
<FloatButtonGroup {items} {onClick} style="inset-inline-end: 24px; inset-block-end: 50px">
|
|
160
|
+
{#snippet icon({ index })}
|
|
161
|
+
{@const Icon = icons[index]}
|
|
162
|
+
<Icon />
|
|
163
|
+
{/snippet}
|
|
164
|
+
</FloatButtonGroup>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## API Reference
|
|
168
|
+
|
|
169
|
+
### FloatButton
|
|
170
|
+
|
|
171
|
+
**Props**
|
|
172
|
+
|
|
173
|
+
| Property | Description | Type | Default |
|
|
174
|
+
| - | - | - | - |
|
|
175
|
+
| badge | Badge props, same as Badge without children. class, style, onclick, onmouseenter and onmouseleave reach the Badge root element. | `FloatButtonBadge` | - |
|
|
176
|
+
| badgeCount | Snippet for custom badge content, in place of badge.count. | `Snippet` | - |
|
|
177
|
+
| colorful | Colorful float button. | `boolean` | `false` |
|
|
178
|
+
| disabled | Disabled state. | `boolean` | `false` |
|
|
179
|
+
| href | Link address. Renders an a element when set; a disabled link drops it. | `string` | - |
|
|
180
|
+
| icon | Snippet for the button icon. | `Snippet` | - |
|
|
181
|
+
| rel | Relationship to the link target. Only takes effect with href. | `string` | - |
|
|
182
|
+
| shape | Shape: round or square. | `FloatButtonShape` | `"round"` |
|
|
183
|
+
| size | Size: default, small or large. | `FloatButtonSize` | `"default"` |
|
|
184
|
+
| target | Where to display the linked URL. Only takes effect with href. | `string` | - |
|
|
185
|
+
|
|
186
|
+
`class`, `style` and native attributes and events (such as `id`, `aria-*` and `onclick`) land on the root element: an `<a>` when `href` is set, otherwise a `<button>`. The click callback is the native `onclick`, which receives the event, and is not called while disabled. `style` only accepts a string, and a number does not get `px` added. Refs are not supported.
|
|
187
|
+
|
|
188
|
+
### FloatButtonGroupItem
|
|
189
|
+
|
|
190
|
+
Add the following parameters based on the props of FloatButton. An item's `href`, `target`, `rel`, `disabled`, `class` and `style` mean the same as on FloatButton, and listeners such as `onClick` go in the data; `shape`, `size` and `colorful` work as the props of the same name on a standalone FloatButton, and an item with `size` has that fixed width and height. An item's `ref` is not supported.
|
|
191
|
+
|
|
192
|
+
| Properties | Instructions | Type | Default |
|
|
193
|
+
| - | - | - | - |
|
|
194
|
+
| aria-label | Accessible name of the item, required when it has only an icon | string | - |
|
|
195
|
+
| class | Class name | string | - |
|
|
196
|
+
| content | Text content; richer content uses the `content` snippet | string \| number | - |
|
|
197
|
+
| data-\* | Custom data attributes | string | - |
|
|
198
|
+
| id | Element id | string | - |
|
|
199
|
+
| onClick | Click callback, called before the group's `onClick` | (event: MouseEvent) => void | - |
|
|
200
|
+
| oncontextmenu | Context menu callback | (event: MouseEvent) => void | - |
|
|
201
|
+
| onmouseenter | Pointer enter callback | (event: MouseEvent) => void | - |
|
|
202
|
+
| onmouseleave | Pointer leave callback | (event: MouseEvent) => void | - |
|
|
203
|
+
| style | Style string | string | - |
|
|
204
|
+
| title | Native title attribute | string | - |
|
|
205
|
+
| value | Value of the item, passed as the first argument of `onClick` | string | - |
|
|
206
|
+
|
|
207
|
+
### FloatButtonGroup
|
|
208
|
+
|
|
209
|
+
**Props**
|
|
210
|
+
|
|
211
|
+
| Property | Description | Type | Default |
|
|
212
|
+
| - | - | - | - |
|
|
213
|
+
| badgeCount | Snippet for custom badge content of an item, with the argument `{ item, index }`. | `Snippet<[FloatButtonGroupItemSnippetArgs]>` | - |
|
|
214
|
+
| content | Snippet for custom content of an item, with the argument `{ item, index }`. Defaults to item.content. | `Snippet<[FloatButtonGroupItemSnippetArgs]>` | - |
|
|
215
|
+
| disabled | Disables every item. | `boolean` | `false` |
|
|
216
|
+
| icon | Snippet for the icon of an item, with the argument `{ item, index }`. | `Snippet<[FloatButtonGroupItemSnippetArgs]>` | - |
|
|
217
|
+
| items | List of items. | `FloatButtonGroupItem[]` | - |
|
|
218
|
+
| onClick | Called when an enabled item is clicked, with the item's value (undefined if unset) and the native click event. The item's own onClick runs first. Not called for clicks outside an item. | `(value: string \| undefined, event: MouseEvent) => void` | - |
|
|
219
|
+
|
|
220
|
+
`class`, `style` and native attributes (such as `aria-*`) land on the root element (`role="group"`). The `icon`, node-typed `content` and node-typed `badge.count` of `items` come from the `icon`, `content` and `badgeCount` snippets, which receive `{ item, index }`.
|
|
221
|
+
|
|
222
|
+
## Accessibility
|
|
223
|
+
|
|
224
|
+
### ARIA
|
|
225
|
+
|
|
226
|
+
- FloatButton and every FloatButtonGroup item are native elements: a link `<a>` when `href` is set, otherwise a `<button type="button">`, so screen readers announce the matching role
|
|
227
|
+
- The accessible name comes from `aria-label`, or from the visible text (an item's `content`) without it. A FloatButton usually shows only an icon, so always pass an `aria-label` that describes what it does, such as `aria-label="Back to top"`; an icon-only item needs an `aria-label` on the item as well
|
|
228
|
+
- Text shown in the badge (`badge.count`) is part of the button's visible text, and `aria-label` replaces it, so include the badge text in `aria-label`, such as `aria-label="AI edit, VIP"`, so that speech input users can operate the button by the text they see
|
|
229
|
+
- A disabled button uses the native `disabled` attribute together with `aria-disabled="true"`. A link has no native disabled state: a disabled link drops its `href` (it can no longer be clicked, opened with the middle button or the context menu, and leaves the Tab order) and takes `role="link"` with `aria-disabled="true"`, so screen readers still announce an unavailable link
|
|
230
|
+
- The root of FloatButtonGroup has `role="group"`; name the whole group with `aria-label` or `aria-labelledby` (`aria-*` attributes go to the root)
|
|
231
|
+
- FloatButtonGroup has no selected state, so items do not use `aria-pressed`
|
|
232
|
+
|
|
233
|
+
### Keyboard and focus
|
|
234
|
+
|
|
235
|
+
- Focus works as with native buttons and links: Tab and Shift + Tab move between them, and disabled items cannot be focused
|
|
236
|
+
- A focused button is activated with Enter or Space, a focused link is followed with Enter
|
|
237
|
+
- A focus outline is shown on keyboard focus
|
|
238
|
+
|
|
239
|
+
## Changes from Semi Design
|
|
240
|
+
|
|
241
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
242
|
+
|
|
243
|
+
- 每一项渲染为原生 `<button type="button">`,有 `href` 时为 `<a>`(新增 `rel`),`ref` 类型为 `React.Ref<HTMLButtonElement | HTMLAnchorElement>`,`href` 不再经 `window.open` 跳转;纯图标按钮与子项需传 `aria-label`;FloatButtonGroup 的 `disabled` 真正禁用每一项,子项的 `href`、`disabled`、`onClick`、`shape`、`size`、`colorful` 生效。
|
|
244
|
+
- 破坏性(类型):`FloatButtonProps`、`FloatButtonGroupProps` 不再接受 `children`;`FloatButtonProps` 不再含 `type` 与 `form*` 属性。Vue:`onClick` 改为 `click` 事件(FloatButton 载荷 `(event)`,Group 为 `(value, event)`),`icon` 为 `#icon` 插槽,节点型 `badge.count` 用 `#badgeCount`;Group 的 `items` 中 `className` 改 `class`,`icon`、`content`、`badge.count` 改为作用域插槽 `#icon`、`#content`、`#badgeCount`(参数 `{ item, index }`),不支持 item 的 `ref`。
|
|
245
|
+
- Svelte:FloatButton 的 `onClick` 改为原生 `onclick`(参数 `(event)`),与 Button 一致;有 `href` 时根元素为 `<a>`,否则为 `<button>`,不支持 ref;`icon`、`badgeCount` 是 snippet。
|
|
246
|
+
- Svelte:FloatButtonGroup 的 `onClick(value, event)` 保持原名,只在点击落在项上时调用;items 里 item 的 `onClick` 保持原名,先于分组的 `onClick` 调用;分组的 `icon`、`content`、`badgeCount` 是 snippet,参数 `{ item, index }`;items 里的 `class`、`style` 是字符串,`oncontextmenu`、`onmouseenter`、`onmouseleave` 用小写原生名。
|