@cfasim-ui/components 0.7.7 → 0.8.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/dist/Box/Box.d.ts +7 -11
- package/dist/Button/Button.d.ts +7 -11
- package/dist/ButtonGroup/ButtonGroup.d.ts +8 -12
- package/dist/Container/Container.d.ts +7 -11
- package/dist/Expander/Expander.d.ts +12 -14
- package/dist/Grid/Grid.d.ts +6 -5
- package/dist/Hint/Hint.d.ts +2 -1
- package/dist/Icon/Icon.d.ts +3 -2
- package/dist/LightDarkToggle/LightDarkToggle.d.ts +2 -1
- package/dist/MultiSelect/MultiSelect.d.ts +6 -6
- package/dist/NumberInput/NumberInput.d.ts +13 -11
- package/dist/ParamEditor/ParamEditor.d.ts +3 -2
- package/dist/ParamEditor/ParamEditorImpl.d.ts +3 -5
- package/dist/{ParamEditorImpl-D0xZTyAN.js → ParamEditorImpl-CkElC6PI.js} +3075 -3041
- package/dist/SelectBox/SelectBox.d.ts +8 -6
- package/dist/{SelectBox-CByXZfaC.js → SelectBox-Df8dE2r-.js} +6 -6
- package/dist/SidebarLayout/SidebarLayout.d.ts +21 -20
- package/dist/Spinner/Spinner.d.ts +3 -2
- package/dist/TextInput/TextInput.d.ts +7 -5
- package/dist/Toggle/Toggle.d.ts +8 -6
- package/dist/ToggleGroup/ToggleGroup.d.ts +8 -6
- package/dist/_internal/FieldLabel.d.ts +2 -1
- package/dist/index.js +20 -20
- package/docs/Box.md +49 -0
- package/docs/Button.md +67 -0
- package/docs/ButtonGroup.md +64 -0
- package/docs/Container.md +103 -0
- package/docs/Expander.md +34 -0
- package/docs/Grid.md +170 -0
- package/docs/Hint.md +29 -0
- package/docs/Icon.md +188 -0
- package/docs/MultiSelect.md +143 -0
- package/docs/NumberInput.md +485 -0
- package/docs/ParamEditor.md +97 -0
- package/docs/SelectBox.md +182 -0
- package/docs/SidebarLayout.md +106 -0
- package/docs/Spinner.md +51 -0
- package/docs/TextInput.md +83 -0
- package/docs/Toggle.md +81 -0
- package/docs/ToggleGroup.md +163 -0
- package/docs/index.json +194 -0
- package/package.json +24 -20
- package/src/Box/Box.md +41 -0
- package/src/Box/Box.vue +52 -0
- package/src/Button/Button.md +59 -0
- package/src/Button/Button.vue +81 -0
- package/src/ButtonGroup/ButtonGroup.md +62 -0
- package/src/ButtonGroup/ButtonGroup.vue +91 -0
- package/src/Container/Container.md +99 -0
- package/src/Container/Container.vue +62 -0
- package/src/Expander/Expander.md +23 -0
- package/src/Expander/Expander.vue +95 -0
- package/src/Grid/Grid.md +175 -0
- package/src/Grid/Grid.vue +145 -0
- package/src/Hint/Hint.md +24 -0
- package/src/Hint/Hint.vue +83 -0
- package/src/Icon/Icon.md +176 -0
- package/src/Icon/Icon.vue +104 -0
- package/src/Icon/defaultIcons.ts +92 -0
- package/src/Icon/github.svg +1 -0
- package/src/Icon/registry.ts +68 -0
- package/src/LightDarkToggle/LightDarkToggle.vue +49 -0
- package/src/MultiSelect/MultiSelect.md +142 -0
- package/src/MultiSelect/MultiSelect.vue +279 -0
- package/src/NumberInput/NumberInput.md +455 -0
- package/src/NumberInput/NumberInput.vue +575 -0
- package/src/ParamEditor/ParamEditor.md +87 -0
- package/src/ParamEditor/ParamEditor.vue +43 -0
- package/src/ParamEditor/ParamEditorImpl.vue +358 -0
- package/src/SelectBox/SelectBox.md +169 -0
- package/src/SelectBox/SelectBox.vue +260 -0
- package/src/SidebarLayout/SidebarLayout.md +106 -0
- package/src/SidebarLayout/SidebarLayout.vue +468 -0
- package/src/Spinner/Spinner.md +45 -0
- package/src/Spinner/Spinner.vue +55 -0
- package/src/TextInput/TextInput.md +68 -0
- package/src/TextInput/TextInput.vue +54 -0
- package/src/Toggle/Toggle.md +68 -0
- package/src/Toggle/Toggle.vue +81 -0
- package/src/ToggleGroup/ToggleGroup.md +158 -0
- package/src/ToggleGroup/ToggleGroup.vue +138 -0
- package/src/_internal/FieldLabel.vue +27 -0
- package/src/_internal/field.ts +27 -0
- package/src/_internal/gap.ts +17 -0
- package/src/_internal/input.css +54 -0
- package/src/_internal/listbox.css +53 -0
- package/src/env.d.ts +4 -0
- package/src/index.ts +33 -0
- package/src/svg.d.ts +5 -0
package/docs/index.json
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.8.0",
|
|
3
|
+
"package": "@cfasim-ui/components",
|
|
4
|
+
"content": {
|
|
5
|
+
"components": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Box",
|
|
8
|
+
"slug": "box",
|
|
9
|
+
"docs": "docs/Box.md",
|
|
10
|
+
"source": "src/Box/Box.vue",
|
|
11
|
+
"keywords": []
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Button",
|
|
15
|
+
"slug": "button",
|
|
16
|
+
"docs": "docs/Button.md",
|
|
17
|
+
"source": "src/Button/Button.vue",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"button",
|
|
20
|
+
"click",
|
|
21
|
+
"action",
|
|
22
|
+
"primary",
|
|
23
|
+
"secondary"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "ButtonGroup",
|
|
28
|
+
"slug": "button-group",
|
|
29
|
+
"docs": "docs/ButtonGroup.md",
|
|
30
|
+
"source": "src/ButtonGroup/ButtonGroup.vue",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"button group",
|
|
33
|
+
"buttons",
|
|
34
|
+
"group",
|
|
35
|
+
"toolbar",
|
|
36
|
+
"segmented",
|
|
37
|
+
"joined"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Container",
|
|
42
|
+
"slug": "container",
|
|
43
|
+
"docs": "docs/Container.md",
|
|
44
|
+
"source": "src/Container/Container.vue",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"container",
|
|
47
|
+
"layout",
|
|
48
|
+
"stack",
|
|
49
|
+
"row",
|
|
50
|
+
"flex",
|
|
51
|
+
"scrollable",
|
|
52
|
+
"border",
|
|
53
|
+
"card"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "Expander",
|
|
58
|
+
"slug": "expander",
|
|
59
|
+
"docs": "docs/Expander.md",
|
|
60
|
+
"source": "src/Expander/Expander.vue",
|
|
61
|
+
"keywords": []
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "Grid",
|
|
65
|
+
"slug": "grid",
|
|
66
|
+
"docs": "docs/Grid.md",
|
|
67
|
+
"source": "src/Grid/Grid.vue",
|
|
68
|
+
"keywords": [
|
|
69
|
+
"grid",
|
|
70
|
+
"columns",
|
|
71
|
+
"layout",
|
|
72
|
+
"responsive",
|
|
73
|
+
"auto-fit",
|
|
74
|
+
"cards",
|
|
75
|
+
"side-by-side",
|
|
76
|
+
"proportional"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "Hint",
|
|
81
|
+
"slug": "hint",
|
|
82
|
+
"docs": "docs/Hint.md",
|
|
83
|
+
"source": "src/Hint/Hint.vue",
|
|
84
|
+
"keywords": []
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "Icon",
|
|
88
|
+
"slug": "icon",
|
|
89
|
+
"docs": "docs/Icon.md",
|
|
90
|
+
"source": "src/Icon/Icon.vue",
|
|
91
|
+
"keywords": []
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "MultiSelect",
|
|
95
|
+
"slug": "multi-select",
|
|
96
|
+
"docs": "docs/MultiSelect.md",
|
|
97
|
+
"source": "src/MultiSelect/MultiSelect.vue",
|
|
98
|
+
"keywords": [
|
|
99
|
+
"multiselect",
|
|
100
|
+
"multi-select",
|
|
101
|
+
"autocomplete",
|
|
102
|
+
"combobox",
|
|
103
|
+
"tags",
|
|
104
|
+
"chips",
|
|
105
|
+
"filter",
|
|
106
|
+
"search",
|
|
107
|
+
"typeahead"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "NumberInput",
|
|
112
|
+
"slug": "number-input",
|
|
113
|
+
"docs": "docs/NumberInput.md",
|
|
114
|
+
"source": "src/NumberInput/NumberInput.vue",
|
|
115
|
+
"keywords": []
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "ParamEditor",
|
|
119
|
+
"slug": "param-editor",
|
|
120
|
+
"docs": "docs/ParamEditor.md",
|
|
121
|
+
"source": "src/ParamEditor/ParamEditor.vue",
|
|
122
|
+
"keywords": [
|
|
123
|
+
"parameters",
|
|
124
|
+
"editor",
|
|
125
|
+
"code",
|
|
126
|
+
"json",
|
|
127
|
+
"toml",
|
|
128
|
+
"yaml",
|
|
129
|
+
"codemirror",
|
|
130
|
+
"import",
|
|
131
|
+
"export"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "SelectBox",
|
|
136
|
+
"slug": "select-box",
|
|
137
|
+
"docs": "docs/SelectBox.md",
|
|
138
|
+
"source": "src/SelectBox/SelectBox.vue",
|
|
139
|
+
"keywords": [
|
|
140
|
+
"select",
|
|
141
|
+
"dropdown",
|
|
142
|
+
"autocomplete",
|
|
143
|
+
"combobox",
|
|
144
|
+
"filter",
|
|
145
|
+
"search",
|
|
146
|
+
"typeahead"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "SidebarLayout",
|
|
151
|
+
"slug": "sidebar-layout",
|
|
152
|
+
"docs": "docs/SidebarLayout.md",
|
|
153
|
+
"source": "src/SidebarLayout/SidebarLayout.vue",
|
|
154
|
+
"keywords": []
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "Spinner",
|
|
158
|
+
"slug": "spinner",
|
|
159
|
+
"docs": "docs/Spinner.md",
|
|
160
|
+
"source": "src/Spinner/Spinner.vue",
|
|
161
|
+
"keywords": []
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "TextInput",
|
|
165
|
+
"slug": "text-input",
|
|
166
|
+
"docs": "docs/TextInput.md",
|
|
167
|
+
"source": "src/TextInput/TextInput.vue",
|
|
168
|
+
"keywords": []
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "Toggle",
|
|
172
|
+
"slug": "toggle",
|
|
173
|
+
"docs": "docs/Toggle.md",
|
|
174
|
+
"source": "src/Toggle/Toggle.vue",
|
|
175
|
+
"keywords": []
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "ToggleGroup",
|
|
179
|
+
"slug": "toggle-group",
|
|
180
|
+
"docs": "docs/ToggleGroup.md",
|
|
181
|
+
"source": "src/ToggleGroup/ToggleGroup.vue",
|
|
182
|
+
"keywords": [
|
|
183
|
+
"toggle group",
|
|
184
|
+
"segmented control",
|
|
185
|
+
"single select",
|
|
186
|
+
"multi select",
|
|
187
|
+
"button group",
|
|
188
|
+
"radio",
|
|
189
|
+
"pressed"
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfasim-ui/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vue 3 UI components for cfasim-ui",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"docs",
|
|
18
|
+
"src",
|
|
19
|
+
"!src/**/*.test.ts",
|
|
20
|
+
"!src/**/*.spec.ts"
|
|
17
21
|
],
|
|
18
22
|
"main": "./dist/index.js",
|
|
19
23
|
"types": "./dist/index.d.ts",
|
|
@@ -28,29 +32,29 @@
|
|
|
28
32
|
"*.css"
|
|
29
33
|
],
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@codemirror/lang-json": "
|
|
32
|
-
"@codemirror/lang-yaml": "
|
|
33
|
-
"@codemirror/language": "
|
|
34
|
-
"@codemirror/legacy-modes": "
|
|
35
|
-
"@codemirror/view": "
|
|
36
|
-
"codemirror": "
|
|
37
|
-
"reka-ui": "
|
|
38
|
-
"smol-toml": "
|
|
39
|
-
"vue-codemirror": "
|
|
40
|
-
"yaml": "
|
|
41
|
-
"@cfasim-ui/shared": "0.
|
|
35
|
+
"@codemirror/lang-json": "6.0.2",
|
|
36
|
+
"@codemirror/lang-yaml": "6.1.3",
|
|
37
|
+
"@codemirror/language": "6.12.4",
|
|
38
|
+
"@codemirror/legacy-modes": "6.5.3",
|
|
39
|
+
"@codemirror/view": "6.43.6",
|
|
40
|
+
"codemirror": "6.0.2",
|
|
41
|
+
"reka-ui": "2.10.1",
|
|
42
|
+
"smol-toml": "1.7.0",
|
|
43
|
+
"vue-codemirror": "6.1.1",
|
|
44
|
+
"yaml": "2.9.0",
|
|
45
|
+
"@cfasim-ui/shared": "0.8.0"
|
|
42
46
|
},
|
|
43
47
|
"peerDependencies": {
|
|
44
48
|
"vue": "^3.5.0"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@material-symbols/svg-400": "
|
|
48
|
-
"@vitejs/plugin-vue": "
|
|
49
|
-
"@vue/test-utils": "
|
|
50
|
-
"happy-dom": "
|
|
51
|
-
"vite-plugin-dts": "
|
|
52
|
-
"vite-svg-loader": "
|
|
53
|
-
"vitest": "
|
|
51
|
+
"@material-symbols/svg-400": "0.45.8",
|
|
52
|
+
"@vitejs/plugin-vue": "6.0.8",
|
|
53
|
+
"@vue/test-utils": "2.4.11",
|
|
54
|
+
"happy-dom": "20.10.6",
|
|
55
|
+
"vite-plugin-dts": "5.0.3",
|
|
56
|
+
"vite-svg-loader": "5.1.1",
|
|
57
|
+
"vitest": "4.1.10"
|
|
54
58
|
},
|
|
55
59
|
"scripts": {
|
|
56
60
|
"build": "vite build"
|
package/src/Box/Box.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Box
|
|
2
|
+
|
|
3
|
+
A colored container for callouts, alerts, and grouped content.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Variants
|
|
8
|
+
|
|
9
|
+
<ComponentDemo>
|
|
10
|
+
<Box variant="info">This is an info box.</Box>
|
|
11
|
+
<Box variant="success">This is a success box.</Box>
|
|
12
|
+
<Box variant="warning">This is a warning box.</Box>
|
|
13
|
+
<Box variant="error">This is an error box.</Box>
|
|
14
|
+
|
|
15
|
+
<template #code>
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<Box variant="info">This is an info box.</Box>
|
|
19
|
+
<Box variant="success">This is a success box.</Box>
|
|
20
|
+
<Box variant="warning">This is a warning box.</Box>
|
|
21
|
+
<Box variant="error">This is an error box.</Box>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
</template>
|
|
25
|
+
</ComponentDemo>
|
|
26
|
+
|
|
27
|
+
### Custom colors
|
|
28
|
+
|
|
29
|
+
<ComponentDemo>
|
|
30
|
+
<Box bg-color="#f0e6ff" text-color="#4a1d96">Custom purple box</Box>
|
|
31
|
+
|
|
32
|
+
<template #code>
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<Box bg-color="#f0e6ff" text-color="#4a1d96">Custom purple box</Box>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
</template>
|
|
39
|
+
</ComponentDemo>
|
|
40
|
+
|
|
41
|
+
<!--@include: ./_api/box.md-->
|
package/src/Box/Box.vue
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
export type BoxVariant = "info" | "success" | "warning" | "error";
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
variant?: BoxVariant;
|
|
6
|
+
bgColor?: string;
|
|
7
|
+
textColor?: string;
|
|
8
|
+
role?: string;
|
|
9
|
+
}>();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div
|
|
14
|
+
class="box"
|
|
15
|
+
:class="variant ? `box-${variant}` : undefined"
|
|
16
|
+
:style="{
|
|
17
|
+
backgroundColor: bgColor,
|
|
18
|
+
color: textColor,
|
|
19
|
+
}"
|
|
20
|
+
:role="role"
|
|
21
|
+
>
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<style scoped>
|
|
27
|
+
.box {
|
|
28
|
+
padding: 0.75em 1.25em;
|
|
29
|
+
border-radius: 0.375em;
|
|
30
|
+
font-size: var(--font-size-sm);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.box-info {
|
|
34
|
+
background-color: var(--color-box-info-bg);
|
|
35
|
+
color: var(--color-box-info-text);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.box-success {
|
|
39
|
+
background-color: var(--color-box-success-bg);
|
|
40
|
+
color: var(--color-box-success-text);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.box-warning {
|
|
44
|
+
background-color: var(--color-box-warning-bg);
|
|
45
|
+
color: var(--color-box-warning-text);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.box-error {
|
|
49
|
+
background-color: var(--color-box-error-bg);
|
|
50
|
+
color: var(--color-box-error-text);
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
keywords: [button, click, action, primary, secondary]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Button
|
|
6
|
+
|
|
7
|
+
A button for triggering actions. Supports primary and secondary variants.
|
|
8
|
+
|
|
9
|
+
Built on [reka-ui Primitive](https://reka-ui.com/docs/utilities/primitive), so it supports `as` and `asChild` for rendering as different elements.
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### Variants
|
|
14
|
+
|
|
15
|
+
<ComponentDemo>
|
|
16
|
+
<Button>Primary</Button>
|
|
17
|
+
<Button variant="secondary">Secondary</Button>
|
|
18
|
+
|
|
19
|
+
<template #code>
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<Button>Primary</Button>
|
|
23
|
+
<Button variant="secondary">Secondary</Button>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
</template>
|
|
27
|
+
</ComponentDemo>
|
|
28
|
+
|
|
29
|
+
### Disabled
|
|
30
|
+
|
|
31
|
+
<ComponentDemo>
|
|
32
|
+
<Button disabled>Disabled</Button>
|
|
33
|
+
<Button variant="secondary" disabled>Disabled</Button>
|
|
34
|
+
|
|
35
|
+
<template #code>
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<Button disabled>Disabled</Button>
|
|
39
|
+
<Button variant="secondary" disabled>Disabled</Button>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
</template>
|
|
43
|
+
</ComponentDemo>
|
|
44
|
+
|
|
45
|
+
### With label prop
|
|
46
|
+
|
|
47
|
+
<ComponentDemo>
|
|
48
|
+
<Button label="Click me" />
|
|
49
|
+
|
|
50
|
+
<template #code>
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<Button label="Click me" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
</template>
|
|
57
|
+
</ComponentDemo>
|
|
58
|
+
|
|
59
|
+
<!--@include: ./_api/button.md-->
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Primitive } from "reka-ui";
|
|
3
|
+
import type { PrimitiveProps } from "reka-ui";
|
|
4
|
+
|
|
5
|
+
interface Props extends PrimitiveProps {
|
|
6
|
+
label?: string;
|
|
7
|
+
variant?: "primary" | "secondary";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
withDefaults(defineProps<Props>(), {
|
|
11
|
+
as: "button",
|
|
12
|
+
variant: "primary",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
defineEmits<{
|
|
16
|
+
click: [event: MouseEvent];
|
|
17
|
+
}>();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<Primitive
|
|
22
|
+
class="button"
|
|
23
|
+
:data-variant="variant"
|
|
24
|
+
:as="as"
|
|
25
|
+
:as-child="asChild"
|
|
26
|
+
@click="$emit('click', $event)"
|
|
27
|
+
>
|
|
28
|
+
<slot>{{ label }}</slot>
|
|
29
|
+
</Primitive>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<style scoped>
|
|
33
|
+
.button {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
border: none;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
align-self: flex-start;
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
min-height: 2.5em;
|
|
41
|
+
padding: 0 1em;
|
|
42
|
+
font-size: var(--font-size-sm);
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
border-radius: 0.375em;
|
|
45
|
+
background-color: var(--color-primary);
|
|
46
|
+
color: var(--color-text-on-primary);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.button:hover {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
background-color: var(--color-primary-hover);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.button:active {
|
|
55
|
+
background-color: var(--color-primary-active);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.button:focus-visible {
|
|
59
|
+
outline: none;
|
|
60
|
+
box-shadow: var(--shadow-focus);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.button:disabled {
|
|
64
|
+
opacity: 0.5;
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.button[data-variant="secondary"] {
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
color: var(--color-primary);
|
|
71
|
+
border: 1px solid var(--color-primary);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.button[data-variant="secondary"]:hover {
|
|
75
|
+
background-color: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.button[data-variant="secondary"]:active {
|
|
79
|
+
background-color: color-mix(in srgb, var(--color-primary) 15%, transparent);
|
|
80
|
+
}
|
|
81
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
keywords: [button group, buttons, group, toolbar, segmented, joined]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ButtonGroup
|
|
6
|
+
|
|
7
|
+
A container that visually joins a set of [`Button`](./button)s (or any
|
|
8
|
+
elements) into a single connected unit. It only handles layout and styling —
|
|
9
|
+
each button keeps its own click handler and state. For a stateful "pick one (or
|
|
10
|
+
more)" control that looks like a button group, use
|
|
11
|
+
[`ToggleGroup`](./toggle-group) instead.
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
### Joined buttons
|
|
16
|
+
|
|
17
|
+
<ComponentDemo>
|
|
18
|
+
<ButtonGroup aria-label="Document actions">
|
|
19
|
+
<Button variant="secondary">Cut</Button>
|
|
20
|
+
<Button variant="secondary">Copy</Button>
|
|
21
|
+
<Button variant="secondary">Paste</Button>
|
|
22
|
+
</ButtonGroup>
|
|
23
|
+
|
|
24
|
+
<template #code>
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<ButtonGroup aria-label="Document actions">
|
|
28
|
+
<Button variant="secondary">Cut</Button>
|
|
29
|
+
<Button variant="secondary">Copy</Button>
|
|
30
|
+
<Button variant="secondary">Paste</Button>
|
|
31
|
+
</ButtonGroup>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
</template>
|
|
35
|
+
</ComponentDemo>
|
|
36
|
+
|
|
37
|
+
### Vertical
|
|
38
|
+
|
|
39
|
+
Set `orientation="vertical"` to stack the buttons. They stretch to a common
|
|
40
|
+
width so the dividers line up.
|
|
41
|
+
|
|
42
|
+
<ComponentDemo>
|
|
43
|
+
<ButtonGroup orientation="vertical" aria-label="Zoom">
|
|
44
|
+
<Button>Zoom in</Button>
|
|
45
|
+
<Button>Reset</Button>
|
|
46
|
+
<Button>Zoom out</Button>
|
|
47
|
+
</ButtonGroup>
|
|
48
|
+
|
|
49
|
+
<template #code>
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<ButtonGroup orientation="vertical" aria-label="Zoom">
|
|
53
|
+
<Button>Zoom in</Button>
|
|
54
|
+
<Button>Reset</Button>
|
|
55
|
+
<Button>Zoom out</Button>
|
|
56
|
+
</ButtonGroup>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
</template>
|
|
60
|
+
</ComponentDemo>
|
|
61
|
+
|
|
62
|
+
<!--@include: ./_api/button-group.md-->
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
withDefaults(
|
|
3
|
+
defineProps<{
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
orientation?: "horizontal" | "vertical";
|
|
6
|
+
}>(),
|
|
7
|
+
{ orientation: "horizontal" },
|
|
8
|
+
);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div
|
|
13
|
+
class="button-group"
|
|
14
|
+
role="group"
|
|
15
|
+
:data-orientation="orientation"
|
|
16
|
+
:aria-label="ariaLabel"
|
|
17
|
+
>
|
|
18
|
+
<slot />
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<style scoped>
|
|
23
|
+
.button-group {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.button-group[data-orientation="vertical"] {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Children butt directly against each other; only the outer corners stay
|
|
32
|
+
* rounded and all children stretch to a common size. */
|
|
33
|
+
.button-group :deep(> *) {
|
|
34
|
+
border-radius: 0;
|
|
35
|
+
align-self: stretch;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Pull each child onto its neighbour so a pair of adjacent borders collapses
|
|
39
|
+
* into a single shared 1px divider (instead of two borders + a gap). */
|
|
40
|
+
.button-group[data-orientation="horizontal"] :deep(> *:not(:first-child)) {
|
|
41
|
+
margin-left: -1px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.button-group[data-orientation="vertical"] :deep(> *:not(:first-child)) {
|
|
45
|
+
margin-top: -1px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Lift the active child so its full border / focus ring shows above the
|
|
49
|
+
* overlapping neighbour. */
|
|
50
|
+
.button-group :deep(> *:hover),
|
|
51
|
+
.button-group :deep(> *:focus-visible),
|
|
52
|
+
.button-group :deep(> *:focus) {
|
|
53
|
+
position: relative;
|
|
54
|
+
z-index: 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Bordered buttons share their border as the divider. The solid `Button`
|
|
58
|
+
* variant has no border, so give adjacent solid buttons a divider of their
|
|
59
|
+
* own (a contrast-derived hairline that reads on the button colour). */
|
|
60
|
+
.button-group[data-orientation="horizontal"]
|
|
61
|
+
:deep(.button[data-variant="primary"] + .button[data-variant="primary"]) {
|
|
62
|
+
border-left: 1px solid
|
|
63
|
+
color-mix(in srgb, var(--color-text-on-primary) 35%, transparent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.button-group[data-orientation="vertical"]
|
|
67
|
+
:deep(.button[data-variant="primary"] + .button[data-variant="primary"]) {
|
|
68
|
+
border-top: 1px solid
|
|
69
|
+
color-mix(in srgb, var(--color-text-on-primary) 35%, transparent);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.button-group[data-orientation="horizontal"] :deep(> *:first-child) {
|
|
73
|
+
border-top-left-radius: 0.375em;
|
|
74
|
+
border-bottom-left-radius: 0.375em;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.button-group[data-orientation="horizontal"] :deep(> *:last-child) {
|
|
78
|
+
border-top-right-radius: 0.375em;
|
|
79
|
+
border-bottom-right-radius: 0.375em;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button-group[data-orientation="vertical"] :deep(> *:first-child) {
|
|
83
|
+
border-top-left-radius: 0.375em;
|
|
84
|
+
border-top-right-radius: 0.375em;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.button-group[data-orientation="vertical"] :deep(> *:last-child) {
|
|
88
|
+
border-bottom-left-radius: 0.375em;
|
|
89
|
+
border-bottom-right-radius: 0.375em;
|
|
90
|
+
}
|
|
91
|
+
</style>
|