@gitlab/ui 77.2.0 → 77.3.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 +7 -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/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/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
|
@@ -1,74 +1,34 @@
|
|
|
1
1
|
import { WHITE, GRAY_950 } from '../../dist/tokens/js/tokens';
|
|
2
|
-
import
|
|
3
|
-
import GlColorContrast from '../internal/color_contrast/color_contrast';
|
|
2
|
+
import TokensStory from './tokens_story';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
getTokenName(token) {
|
|
16
|
-
return token.path.filter(Boolean).join('.');
|
|
17
|
-
},
|
|
18
|
-
getClasses(property, value) {
|
|
19
|
-
if (this.isAlpha(value)) return '';
|
|
20
|
-
if (!this.isBackgroundColor(property)) return '';
|
|
21
|
-
const textColorVariant = colorFromBackground(value, 4.5);
|
|
22
|
-
return {
|
|
23
|
-
'gl-text-gray-950': textColorVariant === 'dark',
|
|
24
|
-
'gl-text-white': textColorVariant === 'light'
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
getStyle(property, value) {
|
|
28
|
-
if (this.isBackgroundColor(property)) {
|
|
29
|
-
return {
|
|
30
|
-
backgroundColor: value
|
|
31
|
-
};
|
|
32
|
-
}
|
|
4
|
+
const createDesignTokenStory = function () {
|
|
5
|
+
let {
|
|
6
|
+
tokens = {},
|
|
7
|
+
isBackgroundColorStory = true,
|
|
8
|
+
containerClass = ''
|
|
9
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
|
+
const Story = (args, _ref) => {
|
|
11
|
+
let {
|
|
12
|
+
argTypes
|
|
13
|
+
} = _ref;
|
|
33
14
|
return {
|
|
34
|
-
|
|
15
|
+
props: Object.keys(argTypes),
|
|
16
|
+
components: {
|
|
17
|
+
TokensStory
|
|
18
|
+
},
|
|
19
|
+
provide: {
|
|
20
|
+
containerClass,
|
|
21
|
+
isBackgroundColorStory,
|
|
22
|
+
lightBackground: WHITE,
|
|
23
|
+
darkBackground: GRAY_950
|
|
24
|
+
},
|
|
25
|
+
template: `<tokens-story v-bind="$props" />`
|
|
35
26
|
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let darkBackground = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GRAY_950;
|
|
42
|
-
return `
|
|
43
|
-
<ul
|
|
44
|
-
class="gl-list-style-none gl-m-0 gl-p-0"
|
|
45
|
-
>
|
|
46
|
-
<li
|
|
47
|
-
v-for="token in tokens"
|
|
48
|
-
:key="token.name"
|
|
49
|
-
class="gl-display-flex gl-flex-wrap gl-align-items-center gl-justify-content-space-between gl-gap-3 gl-p-3"
|
|
50
|
-
:class="getClasses('${property}', token.value)"
|
|
51
|
-
:style="getStyle('${property}', token.value)"
|
|
52
|
-
>
|
|
53
|
-
<code class="gl-reset-color">{{ getTokenName(token) }}</code>
|
|
54
|
-
<div class="gl-display-flex gl-align-items-center gl-gap-3">
|
|
55
|
-
<code class="gl-reset-color">{{ token.value }}</code>
|
|
56
|
-
<gl-color-contrast v-if="!isAlpha(token.value)" :foreground="token.value" background="${darkBackground}" />
|
|
57
|
-
<gl-color-contrast v-if="!isAlpha(token.value)" :foreground="token.value" background="${lightBackground}" />
|
|
58
|
-
</div>
|
|
59
|
-
</li>
|
|
60
|
-
</ul>
|
|
61
|
-
`;
|
|
62
|
-
};
|
|
63
|
-
const colorTokenStoryOptions = {
|
|
64
|
-
components,
|
|
65
|
-
methods,
|
|
66
|
-
template: colorTemplate('backgroundColor')
|
|
67
|
-
};
|
|
68
|
-
const colorTextTokenStoryOptions = {
|
|
69
|
-
components,
|
|
70
|
-
methods,
|
|
71
|
-
template: colorTemplate('color')
|
|
27
|
+
};
|
|
28
|
+
Story.args = {
|
|
29
|
+
tokens
|
|
30
|
+
};
|
|
31
|
+
return Story;
|
|
72
32
|
};
|
|
73
33
|
|
|
74
|
-
export {
|
|
34
|
+
export { createDesignTokenStory };
|
package/dist/tokens/js/tokens.js
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { colorFromBackground } from '../utils/utils';
|
|
2
|
+
import GlColorContrast from '../internal/color_contrast/color_contrast';
|
|
3
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
4
|
+
|
|
5
|
+
var script = {
|
|
6
|
+
name: 'TokensStory',
|
|
7
|
+
components: {
|
|
8
|
+
GlColorContrast
|
|
9
|
+
},
|
|
10
|
+
inject: ['isBackgroundColorStory', 'lightBackground', 'darkBackground', 'containerClass'],
|
|
11
|
+
props: {
|
|
12
|
+
tokens: {
|
|
13
|
+
type: Object,
|
|
14
|
+
required: false,
|
|
15
|
+
default: () => ({})
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
methods: {
|
|
19
|
+
isAlpha(value) {
|
|
20
|
+
return value.startsWith('rgba(');
|
|
21
|
+
},
|
|
22
|
+
getTokenName(token) {
|
|
23
|
+
return token.path.filter(Boolean).join('.');
|
|
24
|
+
},
|
|
25
|
+
getClasses(value) {
|
|
26
|
+
if (this.isAlpha(value)) return '';
|
|
27
|
+
if (!this.isBackgroundColorStory) return '';
|
|
28
|
+
const textColorVariant = colorFromBackground(value, 4.5);
|
|
29
|
+
return {
|
|
30
|
+
'gl-text-gray-950': textColorVariant === 'dark',
|
|
31
|
+
'gl-text-white': textColorVariant === 'light'
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
getStyle(value) {
|
|
35
|
+
if (this.isBackgroundColorStory) {
|
|
36
|
+
return {
|
|
37
|
+
backgroundColor: value
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
color: value
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/* script */
|
|
48
|
+
const __vue_script__ = script;
|
|
49
|
+
|
|
50
|
+
/* template */
|
|
51
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.containerClass},[_c('ul',{staticClass:"gl-list-style-none gl-m-0 gl-p-0"},_vm._l((_vm.tokens),function(token){return _c('li',{key:token.name,staticClass:"gl-display-flex gl-flex-wrap gl-align-items-center gl-justify-content-space-between gl-gap-3 gl-p-3",class:_vm.getClasses(token.value),style:(_vm.getStyle(token.value))},[_c('code',{staticClass:"gl-reset-color"},[_vm._v(_vm._s(_vm.getTokenName(token)))]),_vm._v(" "),_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-gap-3"},[_c('code',{staticClass:"gl-reset-color"},[_vm._v(_vm._s(token.value))]),_vm._v(" "),(!_vm.isAlpha(token.value))?_c('gl-color-contrast',{attrs:{"foreground":token.value,"background":_vm.darkBackground}}):_vm._e(),_vm._v(" "),(!_vm.isAlpha(token.value))?_c('gl-color-contrast',{attrs:{"foreground":token.value,"background":_vm.lightBackground}}):_vm._e()],1)])}),0)])};
|
|
52
|
+
var __vue_staticRenderFns__ = [];
|
|
53
|
+
|
|
54
|
+
/* style */
|
|
55
|
+
const __vue_inject_styles__ = undefined;
|
|
56
|
+
/* scoped */
|
|
57
|
+
const __vue_scope_id__ = undefined;
|
|
58
|
+
/* module identifier */
|
|
59
|
+
const __vue_module_identifier__ = undefined;
|
|
60
|
+
/* functional template */
|
|
61
|
+
const __vue_is_functional_template__ = false;
|
|
62
|
+
/* style inject */
|
|
63
|
+
|
|
64
|
+
/* style inject SSR */
|
|
65
|
+
|
|
66
|
+
/* style inject shadow dom */
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const __vue_component__ = __vue_normalize__(
|
|
71
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
72
|
+
__vue_inject_styles__,
|
|
73
|
+
__vue_script__,
|
|
74
|
+
__vue_scope_id__,
|
|
75
|
+
__vue_is_functional_template__,
|
|
76
|
+
__vue_module_identifier__,
|
|
77
|
+
false,
|
|
78
|
+
undefined,
|
|
79
|
+
undefined,
|
|
80
|
+
undefined
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export default __vue_component__;
|
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 {
|