@gitlab/ui 77.2.0 → 77.4.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/CHANGELOG.md +15 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +10 -3
- package/dist/components/base/sorting/sorting.js +1 -4
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/tokens/common_story_options.js +28 -68
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/tokens/tokens_story.js +83 -0
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/button/button.stories.js +0 -30
- package/src/components/base/button_group/button_group.md +22 -0
- package/src/components/base/button_group/button_group.stories.js +92 -12
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -1
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +8 -1
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.md +13 -9
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.scss +0 -32
- package/src/components/base/new_dropdowns/dropdown.scss +58 -2
- package/src/components/base/new_dropdowns/listbox/listbox.md +19 -15
- package/src/components/base/sorting/sorting.vue +1 -9
- package/src/scss/utilities.scss +12 -0
- package/src/scss/utility-mixins/flex.scss +6 -0
- package/src/tokens/color.dark.tokens.stories.js +8 -38
- package/src/tokens/color.data_viz.dark.tokens.stories.js +7 -27
- package/src/tokens/color.data_viz.tokens.stories.js +7 -27
- package/src/tokens/color.theme.dark.tokens.stories.js +8 -32
- package/src/tokens/color.theme.tokens.stories.js +8 -32
- package/src/tokens/color.tokens.stories.js +8 -38
- package/src/tokens/color.transparency.tokens.stories.js +5 -14
- package/src/tokens/common_story_options.js +21 -67
- package/src/tokens/text.tokens.stories.js +4 -7
- package/src/tokens/tokens_story.vue +73 -0
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import GlDropdown from '../dropdown/dropdown.vue';
|
|
2
2
|
import GlDropdownItem from '../dropdown/dropdown_item.vue';
|
|
3
|
-
import GlSorting from '../sorting/sorting.vue';
|
|
4
3
|
import {
|
|
5
4
|
buttonCategoryOptions,
|
|
6
5
|
buttonVariantOptions,
|
|
@@ -498,35 +497,6 @@ export const BadgeWithSROnlyText = (args, { argTypes = {} }) => ({
|
|
|
498
497
|
});
|
|
499
498
|
BadgeWithSROnlyText.parameters = { controls: { disable: true } };
|
|
500
499
|
|
|
501
|
-
export const SortingDropdownSplitButton = (args, { argTypes }) => ({
|
|
502
|
-
props: Object.keys(argTypes),
|
|
503
|
-
components: { GlSorting },
|
|
504
|
-
template: `
|
|
505
|
-
<gl-sorting
|
|
506
|
-
text="Sorting options"
|
|
507
|
-
:sort-options="sortOptions"
|
|
508
|
-
sort-by="first"
|
|
509
|
-
/>
|
|
510
|
-
`,
|
|
511
|
-
});
|
|
512
|
-
SortingDropdownSplitButton.args = {
|
|
513
|
-
sortOptions: [
|
|
514
|
-
{
|
|
515
|
-
value: 'first',
|
|
516
|
-
text: 'First item',
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
value: 'second',
|
|
520
|
-
text: 'Second item',
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
value: 'last',
|
|
524
|
-
text: 'Last item',
|
|
525
|
-
},
|
|
526
|
-
],
|
|
527
|
-
};
|
|
528
|
-
SortingDropdownSplitButton.parameters = { controls: { disable: true } };
|
|
529
|
-
|
|
530
500
|
export default {
|
|
531
501
|
title: 'base/button',
|
|
532
502
|
component: GlButton,
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
Button groups are an easy way to group a series of buttons together.
|
|
2
2
|
|
|
3
|
+
## Split dropdowns
|
|
4
|
+
|
|
5
|
+
Both `GlCollapsibleListbox` and `GlDisclosureDropdown` can be added as the last
|
|
6
|
+
child of a button group to produce a "split" dropdown.
|
|
7
|
+
|
|
8
|
+
For the correct styling, the dropdown component must render a caret _only_.
|
|
9
|
+
This means no icon, and no visible text. For accessbility, ensure the
|
|
10
|
+
dropdown's `toggle-text` _and_ `text-sr-only` props are set.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<gl-button-group>
|
|
14
|
+
<gl-button>Split listbox</gl-button>
|
|
15
|
+
|
|
16
|
+
<gl-collapsible-listbox
|
|
17
|
+
v-model="foo"
|
|
18
|
+
:items="items"
|
|
19
|
+
toggle-text="Choose button action"
|
|
20
|
+
text-sr-only
|
|
21
|
+
/>
|
|
22
|
+
</gl-button-group>
|
|
23
|
+
```
|
|
24
|
+
|
|
3
25
|
## vue-bootstrap component
|
|
4
26
|
|
|
5
27
|
This component uses [`BButtonGroup`](https://bootstrap-vue.org/docs/components/button-group) from vue-bootstrap
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import GlButton from '../button/button.vue';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import GlDisclosureDropdown from '../new_dropdowns/disclosure/disclosure_dropdown.vue';
|
|
3
|
+
import GlCollapsibleListbox from '../new_dropdowns/listbox/listbox.vue';
|
|
4
|
+
import {
|
|
5
|
+
buttonCategoryOptions,
|
|
6
|
+
buttonSizeOptions,
|
|
7
|
+
buttonVariantOptions,
|
|
8
|
+
} from '../../../utils/constants';
|
|
5
9
|
import GlButtonGroup from './button_group.vue';
|
|
6
10
|
import readme from './button_group.md';
|
|
7
11
|
|
|
8
12
|
const defaultValue = (prop) => GlButton.props[prop].default;
|
|
9
13
|
|
|
10
|
-
const generateProps = ({
|
|
14
|
+
const generateProps = ({
|
|
15
|
+
vertical = false,
|
|
16
|
+
category = buttonCategoryOptions.primary,
|
|
17
|
+
size = defaultValue('size'),
|
|
18
|
+
variant = 'default',
|
|
19
|
+
} = {}) => ({
|
|
11
20
|
vertical,
|
|
21
|
+
category,
|
|
12
22
|
size,
|
|
23
|
+
variant,
|
|
13
24
|
});
|
|
14
25
|
|
|
15
26
|
const template = `
|
|
16
27
|
<gl-button-group :vertical="vertical">
|
|
17
|
-
<gl-button :size="size">Button 1</gl-button>
|
|
18
|
-
<gl-button :size="size">Button 2</gl-button>
|
|
19
|
-
<gl-
|
|
20
|
-
<gl-dropdown-item>First item</gl-dropdown-item>
|
|
21
|
-
<gl-dropdown-item>Second item</gl-dropdown-item>
|
|
22
|
-
<gl-dropdown-item>Last item</gl-dropdown-item>
|
|
23
|
-
</gl-dropdown>
|
|
28
|
+
<gl-button :category="category" :size="size" :variant="variant">Button 1</gl-button>
|
|
29
|
+
<gl-button :category="category" :size="size" :variant="variant">Button 2</gl-button>
|
|
30
|
+
<gl-button :category="category" :size="size" :variant="variant">Button 3</gl-button>
|
|
24
31
|
</gl-button-group>`;
|
|
25
32
|
|
|
26
33
|
const Template = (args, { argTypes }) => ({
|
|
27
|
-
components: { GlButton, GlButtonGroup
|
|
34
|
+
components: { GlButton, GlButtonGroup },
|
|
28
35
|
props: Object.keys(argTypes),
|
|
29
36
|
template,
|
|
30
37
|
});
|
|
@@ -32,6 +39,71 @@ const Template = (args, { argTypes }) => ({
|
|
|
32
39
|
export const Default = Template.bind({});
|
|
33
40
|
Default.args = generateProps();
|
|
34
41
|
|
|
42
|
+
export const SplitDropdowns = (args, { argTypes }) => ({
|
|
43
|
+
components: { GlButton, GlButtonGroup, GlCollapsibleListbox, GlDisclosureDropdown },
|
|
44
|
+
props: Object.keys(argTypes),
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
firstListboxValue: 1,
|
|
48
|
+
secondListboxValue: 1,
|
|
49
|
+
items: [
|
|
50
|
+
{ text: 'One', value: 1 },
|
|
51
|
+
{ text: 'Two', value: 2 },
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
template: `
|
|
56
|
+
<div class="gl-display-flex gl-flex-direction-column gl-gap-6 gl-align-items-flex-start">
|
|
57
|
+
<gl-button-group>
|
|
58
|
+
<gl-button
|
|
59
|
+
:disabled="disabled"
|
|
60
|
+
:category="category"
|
|
61
|
+
:size="size"
|
|
62
|
+
:variant="variant"
|
|
63
|
+
>Split disclosure</gl-button>
|
|
64
|
+
|
|
65
|
+
<gl-disclosure-dropdown
|
|
66
|
+
:disabled="disabled"
|
|
67
|
+
:items="items"
|
|
68
|
+
toggle-text="Other actions"
|
|
69
|
+
text-sr-only
|
|
70
|
+
:category="category"
|
|
71
|
+
:size="size"
|
|
72
|
+
:variant="variant"
|
|
73
|
+
/>
|
|
74
|
+
</gl-button-group>
|
|
75
|
+
|
|
76
|
+
<gl-button-group>
|
|
77
|
+
<gl-button
|
|
78
|
+
:disabled="disabled"
|
|
79
|
+
:category="category"
|
|
80
|
+
:size="size"
|
|
81
|
+
:variant="variant"
|
|
82
|
+
>Split listbox</gl-button>
|
|
83
|
+
|
|
84
|
+
<gl-collapsible-listbox
|
|
85
|
+
v-model="secondListboxValue"
|
|
86
|
+
:disabled="disabled"
|
|
87
|
+
:items="items"
|
|
88
|
+
toggle-text="Choose button action"
|
|
89
|
+
text-sr-only
|
|
90
|
+
:category="category"
|
|
91
|
+
:size="size"
|
|
92
|
+
:variant="variant"
|
|
93
|
+
/>
|
|
94
|
+
</gl-button-group>
|
|
95
|
+
</div>
|
|
96
|
+
`,
|
|
97
|
+
});
|
|
98
|
+
Object.assign(SplitDropdowns, {
|
|
99
|
+
args: { ...generateProps({ variant: 'confirm' }), disabled: false },
|
|
100
|
+
parameters: {
|
|
101
|
+
controls: {
|
|
102
|
+
include: ['category', 'disabled', 'size', 'variant'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
35
107
|
export default {
|
|
36
108
|
title: 'base/button group',
|
|
37
109
|
component: GlButtonGroup,
|
|
@@ -44,9 +116,17 @@ export default {
|
|
|
44
116
|
},
|
|
45
117
|
},
|
|
46
118
|
argTypes: {
|
|
119
|
+
category: {
|
|
120
|
+
options: Object.keys(buttonCategoryOptions),
|
|
121
|
+
control: 'select',
|
|
122
|
+
},
|
|
47
123
|
size: {
|
|
48
124
|
options: Object.keys(buttonSizeOptions),
|
|
49
125
|
control: 'select',
|
|
50
126
|
},
|
|
127
|
+
variant: {
|
|
128
|
+
options: Object.keys(buttonVariantOptions),
|
|
129
|
+
control: 'select',
|
|
130
|
+
},
|
|
51
131
|
},
|
|
52
132
|
};
|
|
@@ -231,7 +231,7 @@ describe('base dropdown', () => {
|
|
|
231
231
|
|
|
232
232
|
describe.each`
|
|
233
233
|
props | toggleClasses
|
|
234
|
-
${{}} | ${[]}
|
|
234
|
+
${{}} | ${['gl-new-dropdown-caret-only']}
|
|
235
235
|
${{ toggleText: 'toggleText' }} | ${[]}
|
|
236
236
|
${{ icon: 'close' }} | ${['gl-new-dropdown-icon-only', 'btn-icon']}
|
|
237
237
|
${{ icon: 'close', toggleText: 'toggleText', textSrOnly: true }} | ${['gl-new-dropdown-icon-only', 'btn-icon']}
|
|
@@ -160,8 +160,14 @@ export default {
|
|
|
160
160
|
};
|
|
161
161
|
},
|
|
162
162
|
computed: {
|
|
163
|
+
hasNoVisibleToggleText() {
|
|
164
|
+
return !this.toggleText?.length || this.textSrOnly;
|
|
165
|
+
},
|
|
163
166
|
isIconOnly() {
|
|
164
|
-
return Boolean(this.icon &&
|
|
167
|
+
return Boolean(this.icon && this.hasNoVisibleToggleText);
|
|
168
|
+
},
|
|
169
|
+
isCaretOnly() {
|
|
170
|
+
return !this.noCaret && !this.icon && this.hasNoVisibleToggleText;
|
|
165
171
|
},
|
|
166
172
|
ariaAttributes() {
|
|
167
173
|
return {
|
|
@@ -178,6 +184,7 @@ export default {
|
|
|
178
184
|
'gl-new-dropdown-toggle': true,
|
|
179
185
|
'gl-new-dropdown-icon-only btn-icon': this.isIconOnly,
|
|
180
186
|
'gl-new-dropdown-toggle-no-caret': this.noCaret,
|
|
187
|
+
'gl-new-dropdown-caret-only': this.isCaretOnly,
|
|
181
188
|
},
|
|
182
189
|
];
|
|
183
190
|
},
|
|
@@ -2,13 +2,13 @@ A disclosure dropdown is a button that toggles a panel containing a list of acti
|
|
|
2
2
|
[this decision tree](https://design.gitlab.com/components/dropdown-overview#which-component-should-you-use)
|
|
3
3
|
to make sure this is the right dropdown component for you.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Basic usage
|
|
6
6
|
|
|
7
7
|
```html
|
|
8
8
|
<gl-disclosure-dropdown toggle-text="Actions" :items="items" />
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Icon-only disclosure dropdown
|
|
12
12
|
|
|
13
13
|
Icon-only disclosure dropdowns must have an accessible name.
|
|
14
14
|
You can provide this with the combination of `toggleText` and `textSrOnly` props.
|
|
@@ -25,12 +25,12 @@ Optionally, you can use `no-caret` to remove the caret and `category="tertiary"`
|
|
|
25
25
|
/>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Opening the disclosure dropdown
|
|
29
29
|
|
|
30
30
|
Disclosure dropdown will open on toggle button click (if it was previously closed).
|
|
31
31
|
On open, `GlDisclosureDropdown` will emit the `shown` event.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
## Closing the disclosure dropdown
|
|
34
34
|
|
|
35
35
|
The disclosure dropdown is closed by any of the following:
|
|
36
36
|
|
|
@@ -61,7 +61,7 @@ You can use the `preventDefault` to filter out events that are causing undesired
|
|
|
61
61
|
|
|
62
62
|
After closing, `GlDisclosureDropdown` emits a `hidden` event.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
## Setting disclosure dropdown items
|
|
65
65
|
|
|
66
66
|
Use the `items` prop to provide actions/links to the disclosure dropdown. Each
|
|
67
67
|
item can be either an item or a group. For `Item`s, provide an `href` string to
|
|
@@ -101,7 +101,7 @@ type Group = {
|
|
|
101
101
|
type ItemsProp = Array<Item> | Array<Group>;
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
### Actions/links
|
|
105
105
|
|
|
106
106
|
The `text` property is used to render the default disclosure dropdown item
|
|
107
107
|
template. If you want to render a custom template for items, use the
|
|
@@ -118,7 +118,7 @@ template. If you want to render a custom template for items, use the
|
|
|
118
118
|
</gl-disclosure-dropdown>
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
### Groups
|
|
122
122
|
|
|
123
123
|
Actions/links can be contained within groups. A group can have a `name`
|
|
124
124
|
property, which will be used as the group header if present.
|
|
@@ -148,15 +148,19 @@ using the `border-position` property:
|
|
|
148
148
|
</gl-disclosure-dropdown>
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
### Miscellaneous content
|
|
152
152
|
|
|
153
153
|
Besides default components, disclosure dropdown can render miscellaneous content inside it.
|
|
154
154
|
In this case the user is responsible for handling all events and navigation inside the disclosure.
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
### Dealing with long option texts
|
|
157
157
|
|
|
158
158
|
- Some options might have long non-wrapping text that would overflow the dropdown maximum width. In
|
|
159
159
|
such cases, it's recommended to override the `#list-item` slot and to truncate the option text using
|
|
160
160
|
`GlTruncate`.
|
|
161
161
|
- If the toggle text reflects the selected option text, it might be necessary to truncate
|
|
162
162
|
it too by overriding the `#toggle` slot.
|
|
163
|
+
|
|
164
|
+
## Split dropdown
|
|
165
|
+
|
|
166
|
+
See [button group documentation](/docs/base-button-group--docs#split-dropdowns).
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
.btn-group {
|
|
2
|
-
.gl-disclosure-dropdown:not(:last-child) {
|
|
3
|
-
.gl-new-dropdown-toggle {
|
|
4
|
-
@include gl-rounded-top-right-none;
|
|
5
|
-
@include gl-rounded-bottom-right-none;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.gl-disclosure-dropdown:not(:first-child) {
|
|
10
|
-
.gl-new-dropdown-toggle {
|
|
11
|
-
@include gl-rounded-top-left-none;
|
|
12
|
-
@include gl-rounded-bottom-left-none;
|
|
13
|
-
|
|
14
|
-
// Prevent double borders when buttons are next to each other
|
|
15
|
-
margin-left: -1px;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.gl-disclosure-dropdown:hover {
|
|
20
|
-
.gl-new-dropdown-toggle {
|
|
21
|
-
@include gl-z-index-1;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.gl-disclosure-dropdown {
|
|
26
|
-
.gl-new-dropdown-toggle:focus,
|
|
27
|
-
.gl-new-dropdown-toggle:active {
|
|
28
|
-
@include gl-z-index-1;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
1
|
.gl-disclosure-dropdown {
|
|
34
2
|
&.gl-new-dropdown {
|
|
35
3
|
.gl-new-dropdown-inner {
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
&.gl-new-dropdown-toggle-no-caret .gl-new-dropdown-chevron {
|
|
65
65
|
@include gl-display-none;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
.gl-new-dropdown-toggle {
|
|
@@ -110,7 +109,15 @@
|
|
|
110
109
|
&.btn-sm .gl-new-dropdown-chevron {
|
|
111
110
|
@include gl-mx-0;
|
|
112
111
|
}
|
|
113
|
-
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.gl-new-dropdown-caret-only {
|
|
115
|
+
// optically center the caret
|
|
116
|
+
@include gl-pl-2;
|
|
117
|
+
|
|
118
|
+
&.btn-sm {
|
|
119
|
+
@include gl-pl-0;
|
|
120
|
+
}
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
$dropdown-content-padding: 0.25rem;
|
|
@@ -178,3 +185,52 @@
|
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
187
|
}
|
|
188
|
+
|
|
189
|
+
.btn-group {
|
|
190
|
+
.gl-new-dropdown:not(:last-child) {
|
|
191
|
+
.gl-new-dropdown-toggle {
|
|
192
|
+
@include gl-rounded-top-right-none;
|
|
193
|
+
@include gl-rounded-bottom-right-none;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.gl-new-dropdown:not(:first-child) {
|
|
198
|
+
.gl-new-dropdown-toggle {
|
|
199
|
+
@include gl-rounded-top-left-none;
|
|
200
|
+
@include gl-rounded-bottom-left-none;
|
|
201
|
+
|
|
202
|
+
// Prevent double borders when buttons are next to each other
|
|
203
|
+
margin-left: -1px;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// The dropdown toggle of a "split" is by design supposed to be the last
|
|
208
|
+
// child of a button group, so only apply styles for that.
|
|
209
|
+
.gl-new-dropdown:last-child {
|
|
210
|
+
.gl-new-dropdown-caret-only {
|
|
211
|
+
&.btn-confirm,
|
|
212
|
+
&.btn-danger {
|
|
213
|
+
margin-left: 1px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
&:disabled,
|
|
217
|
+
&.disabled,
|
|
218
|
+
&[class*='-secondary'] {
|
|
219
|
+
margin-left: -1px;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.gl-new-dropdown:hover {
|
|
225
|
+
.gl-new-dropdown-toggle {
|
|
226
|
+
@include gl-z-index-1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.gl-new-dropdown {
|
|
231
|
+
.gl-new-dropdown-toggle:focus,
|
|
232
|
+
.gl-new-dropdown-toggle:active {
|
|
233
|
+
@include gl-z-index-1;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -8,7 +8,7 @@ When option is selected, the dropdown will be closed and focus set on the toggle
|
|
|
8
8
|
**Multi-select:** Selecting an option will not update the toggle, but it can be customized
|
|
9
9
|
providing `toggleText` property. Also, selecting or deselecting an item won't close the dropdown.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Icon-only listbox
|
|
12
12
|
|
|
13
13
|
Icon-only listboxes must have an accessible name.
|
|
14
14
|
You can provide this with the combination of `toggleText` and `textSrOnly` props.
|
|
@@ -27,12 +27,12 @@ Optionally, you can use `no-caret` to remove the caret and `category="tertiary"`
|
|
|
27
27
|
>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
## Opening the listbox
|
|
31
31
|
|
|
32
32
|
Listbox will open on toggle button click (if it was previously closed).
|
|
33
33
|
On open, `GlCollapsibleListbox` will emit the `shown` event.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Closing the listbox
|
|
36
36
|
|
|
37
37
|
The listbox is closed by any of the following:
|
|
38
38
|
|
|
@@ -42,21 +42,21 @@ The listbox is closed by any of the following:
|
|
|
42
42
|
|
|
43
43
|
After closing, `GlCollapsibleListbox` emits a `hidden` event.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
## Selecting items
|
|
46
46
|
|
|
47
47
|
Set the `v-model` on the listbox to have 2-way data binding for the selected items in the listbox.
|
|
48
48
|
Alternatively, you can set `selected` property to the array of selected items
|
|
49
49
|
`value` properties (for multi-select) or to the selected item `value` property for a single-select.
|
|
50
50
|
On selection the listbox will emit the `select` event with the selected values.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
## Resetting the selection
|
|
53
53
|
|
|
54
54
|
`GlCollapsibleListbox` can render a reset button if the `headerText` and
|
|
55
55
|
`resetButtonLabel` props are provided.
|
|
56
56
|
When clicking on the reset button, a `reset` event is emitted. It is the consumer's responsibility
|
|
57
57
|
to listen to that event and to update the model as needed.
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
## Setting listbox options
|
|
60
60
|
|
|
61
61
|
Use the `items` prop to provide options to the listbox. Each item can be
|
|
62
62
|
either an option or a group. Below are the expected shapes of these
|
|
@@ -77,7 +77,7 @@ type Group = {
|
|
|
77
77
|
type ItemsProp = Array<Option> | Array<Group>
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
### Options
|
|
81
81
|
|
|
82
82
|
The `value` property of options must be unique across all options
|
|
83
83
|
provided to the listbox, as it's used as a primary key.
|
|
@@ -100,7 +100,7 @@ template. If you want to render a custom template for items, use the
|
|
|
100
100
|
</gl-collapsible-listbox>
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
### Groups
|
|
104
104
|
|
|
105
105
|
Options can be contained within groups. A group has a required `text`
|
|
106
106
|
property, which must be unique across all groups within the listbox, as
|
|
@@ -123,7 +123,15 @@ To render custom group labels, use the `group-label` scoped slot:
|
|
|
123
123
|
</gl-collapsible-listbox>
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
### Dealing with long option texts
|
|
127
|
+
|
|
128
|
+
- Some options might have long non-wrapping text that would overflow the dropdown maximum width. In
|
|
129
|
+
such cases, it's recommended to override the `#list-item` slot and to truncate the option text using
|
|
130
|
+
`GlTruncate`.
|
|
131
|
+
- If the toggle text reflects the selected option text, it might be necessary to truncate
|
|
132
|
+
it too by overriding the `#toggle` slot.
|
|
133
|
+
|
|
134
|
+
## Search
|
|
127
135
|
|
|
128
136
|
To filter out items by search query set `searchable` property to `true`.
|
|
129
137
|
Listbox will render the search field and will emit `search` event with the `searchQuery` value.
|
|
@@ -146,10 +154,6 @@ Screen reader will announce this text when the list is updated.
|
|
|
146
154
|
</gl-collapsible-listbox>
|
|
147
155
|
```
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
## Split dropdown
|
|
150
158
|
|
|
151
|
-
|
|
152
|
-
such cases, it's recommended to override the `#list-item` slot and to truncate the option text using
|
|
153
|
-
`GlTruncate`.
|
|
154
|
-
- If the toggle text reflects the selected option text, it might be necessary to truncate
|
|
155
|
-
it too by overriding the `#toggle` slot.
|
|
159
|
+
See [button group documentation](/docs/base-button-group--docs#split-dropdowns).
|
|
@@ -105,14 +105,6 @@ export default {
|
|
|
105
105
|
? translate('GlSorting.sortAscending', 'Sort direction: ascending')
|
|
106
106
|
: translate('GlSorting.sortDescending', 'Sort direction: descending');
|
|
107
107
|
},
|
|
108
|
-
listboxToggleClass() {
|
|
109
|
-
return [
|
|
110
|
-
this.dropdownToggleClass,
|
|
111
|
-
'gl-rounded-top-right-none!',
|
|
112
|
-
'gl-rounded-bottom-right-none!',
|
|
113
|
-
'gl-focus-z-index-1',
|
|
114
|
-
];
|
|
115
|
-
},
|
|
116
108
|
},
|
|
117
109
|
methods: {
|
|
118
110
|
toggleSortDirection() {
|
|
@@ -150,7 +142,7 @@ export default {
|
|
|
150
142
|
:toggle-text="text"
|
|
151
143
|
:items="sortOptions"
|
|
152
144
|
:selected="sortBy"
|
|
153
|
-
:toggle-class="
|
|
145
|
+
:toggle-class="dropdownToggleClass"
|
|
154
146
|
:class="dropdownClass"
|
|
155
147
|
placement="right"
|
|
156
148
|
:block="block"
|
package/src/scss/utilities.scss
CHANGED
|
@@ -3915,6 +3915,18 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
|
|
|
3915
3915
|
}
|
|
3916
3916
|
}
|
|
3917
3917
|
|
|
3918
|
+
.gl-md-justify-content-center {
|
|
3919
|
+
@include gl-media-breakpoint-up(md) {
|
|
3920
|
+
justify-content: center;
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
.gl-md-justify-content-center\! {
|
|
3925
|
+
@include gl-media-breakpoint-up(md) {
|
|
3926
|
+
justify-content: center !important;
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3918
3930
|
.gl-md-justify-content-end {
|
|
3919
3931
|
@include gl-media-breakpoint-up(md) {
|
|
3920
3932
|
justify-content: flex-end;
|
|
@@ -271,6 +271,12 @@
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
@mixin gl-md-justify-content-center {
|
|
275
|
+
@include gl-media-breakpoint-up(md) {
|
|
276
|
+
@include gl-justify-content-center;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
274
280
|
@mixin gl-md-justify-content-end {
|
|
275
281
|
@include gl-media-breakpoint-up(md) {
|
|
276
282
|
@include gl-justify-content-end;
|
|
@@ -1,54 +1,24 @@
|
|
|
1
1
|
import COMPILED_TOKENS from '../../dist/tokens/json/tokens.dark.json';
|
|
2
|
-
import {
|
|
2
|
+
import { createDesignTokenStory } from './common_story_options';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
export const Default = (args, { argTypes }) => ({
|
|
7
|
-
props: Object.keys(argTypes),
|
|
8
|
-
...colorTokenStoryOptions,
|
|
9
|
-
});
|
|
10
|
-
Default.args = generateProps({
|
|
4
|
+
export const Default = createDesignTokenStory({
|
|
11
5
|
tokens: {
|
|
12
6
|
white: COMPILED_TOKENS.white,
|
|
13
7
|
black: COMPILED_TOKENS.black,
|
|
14
8
|
},
|
|
15
9
|
});
|
|
16
10
|
|
|
17
|
-
export const Gray = (
|
|
18
|
-
props: Object.keys(argTypes),
|
|
19
|
-
...colorTokenStoryOptions,
|
|
20
|
-
});
|
|
21
|
-
Gray.args = generateProps({ tokens: COMPILED_TOKENS.gray });
|
|
11
|
+
export const Gray = createDesignTokenStory({ tokens: COMPILED_TOKENS.gray });
|
|
22
12
|
|
|
23
|
-
export const Blue = (
|
|
24
|
-
props: Object.keys(argTypes),
|
|
25
|
-
...colorTokenStoryOptions,
|
|
26
|
-
});
|
|
27
|
-
Blue.args = generateProps({ tokens: COMPILED_TOKENS.blue });
|
|
13
|
+
export const Blue = createDesignTokenStory({ tokens: COMPILED_TOKENS.blue });
|
|
28
14
|
|
|
29
|
-
export const Green = (
|
|
30
|
-
props: Object.keys(argTypes),
|
|
31
|
-
...colorTokenStoryOptions,
|
|
32
|
-
});
|
|
33
|
-
Green.args = generateProps({ tokens: COMPILED_TOKENS.green });
|
|
15
|
+
export const Green = createDesignTokenStory({ tokens: COMPILED_TOKENS.green });
|
|
34
16
|
|
|
35
|
-
export const Orange = (
|
|
36
|
-
props: Object.keys(argTypes),
|
|
37
|
-
...colorTokenStoryOptions,
|
|
38
|
-
});
|
|
39
|
-
Orange.args = generateProps({ tokens: COMPILED_TOKENS.orange });
|
|
17
|
+
export const Orange = createDesignTokenStory({ tokens: COMPILED_TOKENS.orange });
|
|
40
18
|
|
|
41
|
-
export const Red = (
|
|
42
|
-
props: Object.keys(argTypes),
|
|
43
|
-
...colorTokenStoryOptions,
|
|
44
|
-
});
|
|
45
|
-
Red.args = generateProps({ tokens: COMPILED_TOKENS.red });
|
|
19
|
+
export const Red = createDesignTokenStory({ tokens: COMPILED_TOKENS.red });
|
|
46
20
|
|
|
47
|
-
export const Purple = (
|
|
48
|
-
props: Object.keys(argTypes),
|
|
49
|
-
...colorTokenStoryOptions,
|
|
50
|
-
});
|
|
51
|
-
Purple.args = generateProps({ tokens: COMPILED_TOKENS.purple });
|
|
21
|
+
export const Purple = createDesignTokenStory({ tokens: COMPILED_TOKENS.purple });
|
|
52
22
|
|
|
53
23
|
// eslint-disable-next-line storybook/csf-component
|
|
54
24
|
export default {
|