@gitlab/ui 32.56.0 → 32.60.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 +30 -0
- package/dist/components/base/breadcrumb/breadcrumb.js +56 -4
- package/dist/components/base/table/table.documentation.js +1 -5
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +1 -0
- package/package.json +1 -1
- package/src/components/base/breadcrumb/breadcrumb.spec.js +64 -1
- package/src/components/base/breadcrumb/breadcrumb.stories.js +22 -0
- package/src/components/base/breadcrumb/breadcrumb.vue +71 -3
- package/src/components/base/table/table.documentation.js +0 -3
- package/src/components/base/table/table.stories.js +85 -71
- package/src/scss/utilities.scss +809 -93
- package/src/scss/utility-mixins/sizing.scss +27 -3
- package/src/scss/utility-mixins/spacing.scss +399 -2
- package/src/scss/utility-mixins/typography.scss +4 -0
- package/dist/components/base/table/examples/index.js +0 -19
- package/dist/components/base/table/examples/table.basic.example.js +0 -59
- package/dist/components/base/table/examples/table.custom_fields.example.js +0 -66
- package/src/components/base/table/examples/index.js +0 -22
- package/src/components/base/table/examples/table.basic.example.vue +0 -32
- package/src/components/base/table/examples/table.custom_fields.example.vue +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { BBreadcrumbItem } from 'bootstrap-vue';
|
|
3
|
-
import Breadcrumb from './breadcrumb.vue';
|
|
3
|
+
import Breadcrumb, { COLLAPSE_AT_SIZE } from './breadcrumb.vue';
|
|
4
|
+
import { createMockDirective } from '~helpers/vue_mock_directive';
|
|
4
5
|
|
|
5
6
|
describe('Broadcast message component', () => {
|
|
6
7
|
let wrapper;
|
|
@@ -14,10 +15,24 @@ describe('Broadcast message component', () => {
|
|
|
14
15
|
{ text: 'third_breadcrumb', href: 'http://about.gitlab.com' },
|
|
15
16
|
];
|
|
16
17
|
|
|
18
|
+
const extraItems = [
|
|
19
|
+
{ text: 'fourth_breadcrumb', href: 'http://gitlab.com' },
|
|
20
|
+
{
|
|
21
|
+
text: 'fifth_breadcrumb',
|
|
22
|
+
to: 'to_value',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
17
26
|
const findAvatarSlot = () => wrapper.find('[data-testid="avatar-slot"]');
|
|
18
27
|
const findSeparatorSlot = () => wrapper.find('[data-testid="separator-slot"]');
|
|
19
28
|
const findBreadcrumbItems = () => wrapper.findAllComponents(BBreadcrumbItem);
|
|
20
29
|
const findAllSeparators = () => wrapper.findAll('[data-testid="separator"]');
|
|
30
|
+
const findCollapsedListExpander = () => wrapper.find('[data-testid="collapsed-expander"]');
|
|
31
|
+
const findExpanderSeparator = () => wrapper.find('[data-testid="expander-separator"]');
|
|
32
|
+
|
|
33
|
+
const findVisibleBreadcrumbItems = () =>
|
|
34
|
+
wrapper.findAll('.gl-breadcrumb-item:not(.gl-display-none)');
|
|
35
|
+
const findHiddenBreadcrumbItems = () => wrapper.findAll('.gl-breadcrumb-item.gl-display-none');
|
|
21
36
|
|
|
22
37
|
const createComponent = (propsData = { items }) => {
|
|
23
38
|
wrapper = shallowMount(Breadcrumb, {
|
|
@@ -26,7 +41,14 @@ describe('Broadcast message component', () => {
|
|
|
26
41
|
avatar: '<div data-testid="avatar-slot"></div>',
|
|
27
42
|
separator: '<div data-testid="separator-slot"></div>',
|
|
28
43
|
},
|
|
44
|
+
directives: { GlTooltip: createMockDirective('gl-tooltip') },
|
|
29
45
|
});
|
|
46
|
+
|
|
47
|
+
wrapper.vm.$refs.firstItem = [
|
|
48
|
+
{
|
|
49
|
+
querySelector: () => ({ focus: jest.fn() }),
|
|
50
|
+
},
|
|
51
|
+
];
|
|
30
52
|
};
|
|
31
53
|
|
|
32
54
|
describe('slots', () => {
|
|
@@ -82,4 +104,45 @@ describe('Broadcast message component', () => {
|
|
|
82
104
|
});
|
|
83
105
|
});
|
|
84
106
|
});
|
|
107
|
+
|
|
108
|
+
describe('collapsible', () => {
|
|
109
|
+
describe(`when breadcrumbs list size is NOT larger than ${COLLAPSE_AT_SIZE}`, () => {
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
createComponent();
|
|
112
|
+
});
|
|
113
|
+
it('should not display collapsed list expander && separator', () => {
|
|
114
|
+
expect(findCollapsedListExpander().exists()).toBe(false);
|
|
115
|
+
expect(findExpanderSeparator().exists()).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should display all items visible', () => {
|
|
119
|
+
expect(findVisibleBreadcrumbItems()).toHaveLength(items.length);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe(`when breadcrumbs list size is larger than ${COLLAPSE_AT_SIZE}`, () => {
|
|
124
|
+
beforeEach(() => {
|
|
125
|
+
createComponent({ items: [...items, ...extraItems] });
|
|
126
|
+
});
|
|
127
|
+
it('should display collapsed list expander && separator', () => {
|
|
128
|
+
expect(findCollapsedListExpander().exists()).toBe(true);
|
|
129
|
+
expect(findExpanderSeparator().exists()).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should display only first && 2 last items and the rest as hidden', () => {
|
|
133
|
+
const alwaysVisibleNum = 3;
|
|
134
|
+
expect(findVisibleBreadcrumbItems()).toHaveLength(alwaysVisibleNum);
|
|
135
|
+
expect(findHiddenBreadcrumbItems()).toHaveLength(
|
|
136
|
+
items.length + extraItems.length - alwaysVisibleNum
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should expand the list on expander click', async () => {
|
|
141
|
+
findCollapsedListExpander().vm.$emit('click');
|
|
142
|
+
await wrapper.vm.$nextTick();
|
|
143
|
+
expect(findHiddenBreadcrumbItems()).toHaveLength(0);
|
|
144
|
+
expect(findVisibleBreadcrumbItems()).toHaveLength(items.length + extraItems.length);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
85
148
|
});
|
|
@@ -60,3 +60,25 @@ export default {
|
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
+
|
|
64
|
+
const extraItems = [
|
|
65
|
+
{
|
|
66
|
+
text: 'Fifth Item',
|
|
67
|
+
href: '#',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
text: 'Sixth Item',
|
|
71
|
+
href: '#',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
text: 'Seventh Item',
|
|
75
|
+
href: '#',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
text: 'Eighth Item',
|
|
79
|
+
href: '#',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
export const CollapsedItems = Template.bind({});
|
|
84
|
+
CollapsedItems.args = generateProps({ items: [...defaultItems, ...extraItems] });
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { BBreadcrumb, BBreadcrumbItem } from 'bootstrap-vue';
|
|
3
3
|
import GlIcon from '../icon/icon.vue';
|
|
4
|
+
import GlButton from '../button/button.vue';
|
|
5
|
+
import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
6
|
+
|
|
7
|
+
export const COLLAPSE_AT_SIZE = 4;
|
|
4
8
|
|
|
5
9
|
export default {
|
|
6
10
|
components: {
|
|
7
11
|
BBreadcrumb,
|
|
8
12
|
BBreadcrumbItem,
|
|
9
13
|
GlIcon,
|
|
14
|
+
GlButton,
|
|
15
|
+
},
|
|
16
|
+
directives: {
|
|
17
|
+
GlTooltip: GlTooltipDirective,
|
|
10
18
|
},
|
|
11
19
|
inheritAttrs: false,
|
|
12
20
|
props: {
|
|
@@ -25,9 +33,45 @@ export default {
|
|
|
25
33
|
},
|
|
26
34
|
},
|
|
27
35
|
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
isListCollapsed: true,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
computed: {
|
|
42
|
+
breadcrumbsSize() {
|
|
43
|
+
return this.items.length;
|
|
44
|
+
},
|
|
45
|
+
hasCollapsible() {
|
|
46
|
+
return this.breadcrumbsSize > COLLAPSE_AT_SIZE;
|
|
47
|
+
},
|
|
48
|
+
nonCollapsibleIndices() {
|
|
49
|
+
return [0, this.breadcrumbsSize - 1, this.breadcrumbsSize - 2];
|
|
50
|
+
},
|
|
51
|
+
},
|
|
28
52
|
methods: {
|
|
29
|
-
|
|
30
|
-
return index ===
|
|
53
|
+
isFirstItem(index) {
|
|
54
|
+
return index === 0;
|
|
55
|
+
},
|
|
56
|
+
isLastItem(index) {
|
|
57
|
+
return index === this.breadcrumbsSize - 1;
|
|
58
|
+
},
|
|
59
|
+
expandBreadcrumbs() {
|
|
60
|
+
this.isListCollapsed = false;
|
|
61
|
+
try {
|
|
62
|
+
this.$refs.firstItem[0].querySelector('a').focus();
|
|
63
|
+
} catch (e) {
|
|
64
|
+
/* eslint-disable-next-line no-console */
|
|
65
|
+
console.error(`Failed to set focus on the last breadcrumb item.`);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
showCollapsedBreadcrumbsExpander(index) {
|
|
69
|
+
return index === 0 && this.hasCollapsible && this.isListCollapsed;
|
|
70
|
+
},
|
|
71
|
+
isItemCollapsed(index) {
|
|
72
|
+
return (
|
|
73
|
+
this.hasCollapsible && this.isListCollapsed && !this.nonCollapsibleIndices.includes(index)
|
|
74
|
+
);
|
|
31
75
|
},
|
|
32
76
|
},
|
|
33
77
|
};
|
|
@@ -40,14 +84,16 @@ export default {
|
|
|
40
84
|
<template v-for="(item, index) in items">
|
|
41
85
|
<b-breadcrumb-item
|
|
42
86
|
:key="index"
|
|
87
|
+
:ref="isFirstItem(index) ? 'firstItem' : null"
|
|
43
88
|
class="gl-breadcrumb-item"
|
|
44
89
|
:text="item.text"
|
|
45
90
|
:href="item.href"
|
|
46
91
|
:to="item.to"
|
|
92
|
+
:class="{ 'gl-display-none': isItemCollapsed(index) }"
|
|
47
93
|
>
|
|
48
94
|
<span>{{ item.text }}</span>
|
|
49
95
|
<span
|
|
50
|
-
v-if="!isLastItem(
|
|
96
|
+
v-if="!isLastItem(index)"
|
|
51
97
|
:key="`${index} ${item.text}`"
|
|
52
98
|
class="gl-breadcrumb-separator"
|
|
53
99
|
data-testid="separator"
|
|
@@ -58,6 +104,28 @@ export default {
|
|
|
58
104
|
</slot>
|
|
59
105
|
</span>
|
|
60
106
|
</b-breadcrumb-item>
|
|
107
|
+
|
|
108
|
+
<template v-if="showCollapsedBreadcrumbsExpander(index)">
|
|
109
|
+
<!-- eslint-disable-next-line vue/valid-v-for -->
|
|
110
|
+
<gl-button
|
|
111
|
+
v-gl-tooltip.hover="'Show all breadcrumbs'"
|
|
112
|
+
aria-label="Show all breadcrumbs"
|
|
113
|
+
data-testid="collapsed-expander"
|
|
114
|
+
icon="ellipsis_h"
|
|
115
|
+
category="primary"
|
|
116
|
+
@click="expandBreadcrumbs"
|
|
117
|
+
/>
|
|
118
|
+
<!-- eslint-disable-next-line vue/require-v-for-key -->
|
|
119
|
+
<span
|
|
120
|
+
key="expander"
|
|
121
|
+
class="gl-display-inline-flex gl-text-gray-500"
|
|
122
|
+
data-testid="expander-separator"
|
|
123
|
+
>
|
|
124
|
+
<slot name="separator">
|
|
125
|
+
<gl-icon name="chevron-right" />
|
|
126
|
+
</slot>
|
|
127
|
+
</span>
|
|
128
|
+
</template>
|
|
61
129
|
</template>
|
|
62
130
|
</b-breadcrumb>
|
|
63
131
|
</nav>
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
1
|
import { GlTable } from '../../../../index';
|
|
4
|
-
import { variantOptions } from '../../../utils/constants';
|
|
5
2
|
import readme from './table.md';
|
|
6
3
|
|
|
7
|
-
const components = {
|
|
8
|
-
GlTable,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
4
|
const tableItems = [
|
|
12
5
|
{
|
|
13
6
|
column_one: 'test',
|
|
@@ -23,75 +16,96 @@ const tableItems = [
|
|
|
23
16
|
},
|
|
24
17
|
];
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
const generateProps = ({ fixed = false, footClone = false, stacked = false } = {}) => ({
|
|
20
|
+
fixed,
|
|
21
|
+
footClone,
|
|
22
|
+
stacked,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const Default = (args, { argTypes }) => ({
|
|
26
|
+
props: Object.keys(argTypes),
|
|
27
|
+
template: `
|
|
28
|
+
<gl-table
|
|
29
|
+
:items="$options.items"
|
|
30
|
+
:fields="$options.fields"
|
|
31
|
+
:fixed="fixed"
|
|
32
|
+
:stacked="stacked"
|
|
33
|
+
:foot-clone="footClone"
|
|
34
|
+
hover
|
|
35
|
+
selectable
|
|
36
|
+
selected-variant="primary"
|
|
37
|
+
/>
|
|
38
|
+
`,
|
|
39
|
+
fields: [
|
|
40
|
+
{
|
|
41
|
+
key: 'column_one',
|
|
42
|
+
label: 'Column One',
|
|
43
|
+
variant: 'secondary',
|
|
44
|
+
sortable: false,
|
|
45
|
+
isRowHeader: false,
|
|
35
46
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
{
|
|
48
|
+
key: 'col_2',
|
|
49
|
+
label: 'Column 2',
|
|
50
|
+
formatter: (value) => value,
|
|
39
51
|
},
|
|
40
|
-
|
|
52
|
+
],
|
|
53
|
+
items: tableItems,
|
|
54
|
+
});
|
|
55
|
+
Default.args = generateProps();
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
documentedStoriesOf('base/table/table', readme)
|
|
46
|
-
.addDecorator(withKnobs)
|
|
47
|
-
.add('default', () => ({
|
|
48
|
-
components,
|
|
49
|
-
props: generateProps(),
|
|
50
|
-
template: `
|
|
51
|
-
<gl-table
|
|
52
|
-
:items="$options.items"
|
|
53
|
-
:fields="$options.fields"
|
|
54
|
-
:fixed="fixed"
|
|
55
|
-
:stacked="stacked"
|
|
56
|
-
:foot-clone="footClone"
|
|
57
|
-
hover
|
|
58
|
-
selectable
|
|
59
|
-
selected-variant="primary"
|
|
60
|
-
/>
|
|
61
|
-
`,
|
|
62
|
-
fields: [
|
|
63
|
-
{
|
|
64
|
-
key: 'column_one',
|
|
65
|
-
label: 'Column One',
|
|
66
|
-
variant: select('variant', variantOptions, variantOptions.secondary),
|
|
67
|
-
sortable: boolean('sortable', false),
|
|
68
|
-
isRowHeader: boolean('isRowHeader', false),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
key: 'col_2',
|
|
72
|
-
label: 'Column 2',
|
|
73
|
-
formatter: (value) => `${text('formatterExample', '$')}${value}`,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
items: tableItems,
|
|
77
|
-
}))
|
|
78
|
-
.add('empty', () => ({
|
|
79
|
-
components,
|
|
80
|
-
template: `
|
|
57
|
+
export const Empty = (args, { argTypes }) => ({
|
|
58
|
+
props: Object.keys(argTypes),
|
|
59
|
+
template: `
|
|
81
60
|
<gl-table show-empty />
|
|
82
61
|
`,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
62
|
+
});
|
|
63
|
+
Empty.parameters = { controls: { disable: true } };
|
|
64
|
+
|
|
65
|
+
export const WithFilter = (args, { argTypes }) => ({
|
|
66
|
+
props: Object.keys(argTypes),
|
|
67
|
+
template: `<div class="gl-line-height-normal">
|
|
87
68
|
<gl-form-input v-model="filter" placeholder="Type to search" />
|
|
88
69
|
<br />
|
|
89
|
-
<gl-table
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
<gl-table
|
|
71
|
+
:items="$options.items"
|
|
72
|
+
:fields="$options.fields"
|
|
73
|
+
:filter=filter
|
|
74
|
+
:fixed="fixed"
|
|
75
|
+
:stacked="stacked"
|
|
76
|
+
:foot-clone="footClone"
|
|
77
|
+
hover
|
|
78
|
+
selectable
|
|
79
|
+
selected-variant="primary"
|
|
80
|
+
/>
|
|
81
|
+
</div>`,
|
|
82
|
+
items: tableItems,
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
filter: null,
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
WithFilter.args = generateProps();
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
title: 'base/table/table',
|
|
93
|
+
component: GlTable,
|
|
94
|
+
parameters: {
|
|
95
|
+
bootstrapComponent: 'b-table',
|
|
96
|
+
knobs: { disable: true },
|
|
97
|
+
docs: {
|
|
98
|
+
description: {
|
|
99
|
+
component: readme,
|
|
100
|
+
},
|
|
96
101
|
},
|
|
97
|
-
}
|
|
102
|
+
},
|
|
103
|
+
argTypes: {
|
|
104
|
+
stacked: {
|
|
105
|
+
control: {
|
|
106
|
+
type: 'select',
|
|
107
|
+
options: ['sm', 'md', 'lg', 'xl', true, false],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|