@gitlab/ui 58.8.0 → 59.0.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 +13 -0
- package/dist/components/base/breadcrumb/breadcrumb.js +1 -3
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/breadcrumb/breadcrumb.md +1 -11
- package/src/components/base/breadcrumb/breadcrumb.scss +8 -32
- package/src/components/base/breadcrumb/breadcrumb.spec.js +5 -28
- package/src/components/base/breadcrumb/breadcrumb.vue +14 -36
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
## Usage
|
|
2
2
|
|
|
3
|
-
This component provides
|
|
4
|
-
so an avatar can appear before the first breadcrumb. The second is a `<slot #separator>` to
|
|
5
|
-
customize the icon that appears between each breadcrumb.
|
|
3
|
+
This component provides a `<slot #avatar>` so an avatar can appear before the first breadcrumb.
|
|
6
4
|
|
|
7
5
|
**note:** the component supports passing the property `to` in the list items to enable navigation
|
|
8
6
|
through `vue-router`
|
|
9
7
|
|
|
10
8
|
### Example
|
|
11
9
|
|
|
12
|
-
You can use any kind of separator you want in the slot, like below, which uses `<svg>`
|
|
13
|
-
to draw a `/`
|
|
14
|
-
|
|
15
10
|
```html
|
|
16
11
|
<gl-breadcrumb :items="items">
|
|
17
12
|
<template #avatar>
|
|
@@ -23,10 +18,5 @@ to draw a `/`
|
|
|
23
18
|
height="16"
|
|
24
19
|
/>
|
|
25
20
|
</template>
|
|
26
|
-
<template #separator>
|
|
27
|
-
<svg height="16">
|
|
28
|
-
<line x1="100%" y1="0" x2="0" y2="100%" stroke="gray" />
|
|
29
|
-
</svg>
|
|
30
|
-
</template>
|
|
31
21
|
</gl-breadcrumb>
|
|
32
22
|
```
|
|
@@ -3,9 +3,6 @@ $breadcrumb-max-width: $grid-size * 16;
|
|
|
3
3
|
|
|
4
4
|
.gl-breadcrumbs {
|
|
5
5
|
@include gl-display-flex;
|
|
6
|
-
@include gl-border-0;
|
|
7
|
-
@include gl-inset-border-b-1-gray-200;
|
|
8
|
-
@include gl-py-5;
|
|
9
6
|
}
|
|
10
7
|
|
|
11
8
|
.gl-breadcrumb-list {
|
|
@@ -19,25 +16,11 @@ $breadcrumb-max-width: $grid-size * 16;
|
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
.gl-breadcrumb-separator {
|
|
23
|
-
@include gl-display-inline-flex;
|
|
24
|
-
@include gl-absolute;
|
|
25
|
-
right: 0;
|
|
26
|
-
|
|
27
|
-
> svg {
|
|
28
|
-
@include gl-my-auto;
|
|
29
|
-
@include gl-mx-2;
|
|
30
|
-
@include gl-w-3;
|
|
31
|
-
@include gl-text-gray-500;
|
|
32
|
-
@include gl-fill-current-color;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
19
|
.gl-breadcrumb-avatar-tile {
|
|
37
|
-
@include gl-mr-
|
|
20
|
+
@include gl-mr-2;
|
|
38
21
|
@include gl-border-1;
|
|
39
22
|
@include gl-border-solid;
|
|
40
|
-
@include gl-border-gray-
|
|
23
|
+
@include gl-border-gray-a-08;
|
|
41
24
|
@include gl-rounded-base;
|
|
42
25
|
}
|
|
43
26
|
|
|
@@ -45,22 +28,15 @@ $breadcrumb-max-width: $grid-size * 16;
|
|
|
45
28
|
.gl-breadcrumb-item {
|
|
46
29
|
@include gl-font-sm;
|
|
47
30
|
@include gl-line-height-normal;
|
|
48
|
-
@include gl-relative;
|
|
49
|
-
@include gl-pr-6;
|
|
50
|
-
|
|
51
|
-
+ .gl-breadcrumb-item {
|
|
52
|
-
@include gl-pl-0;
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
&:not(:last-child)::after {
|
|
33
|
+
@include gl-text-gray-200;
|
|
34
|
+
@include gl-px-3;
|
|
35
|
+
content: '/';
|
|
58
36
|
}
|
|
59
37
|
|
|
60
38
|
> a {
|
|
61
|
-
@include gl-
|
|
62
|
-
@include gl-align-items-center;
|
|
63
|
-
@include gl-text-gray-500;
|
|
39
|
+
@include gl-text-gray-700;
|
|
64
40
|
@include media-breakpoint-down(xs) {
|
|
65
41
|
@include str-truncated($breadcrumb-max-width);
|
|
66
42
|
}
|
|
@@ -74,6 +50,6 @@ $breadcrumb-max-width: $grid-size * 16;
|
|
|
74
50
|
}
|
|
75
51
|
|
|
76
52
|
.gl-breadcrumb-item:last-child > a {
|
|
77
|
-
@include gl-text-gray-
|
|
53
|
+
@include gl-text-gray-900;
|
|
78
54
|
@include gl-font-weight-bold;
|
|
79
55
|
}
|
|
@@ -24,22 +24,19 @@ describe('Breadcrumb component', () => {
|
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
const findAvatarSlot = () => wrapper.find('[data-testid="avatar-slot"]');
|
|
27
|
-
const findSeparatorSlot = () => wrapper.find('[data-testid="separator-slot"]');
|
|
28
27
|
const findBreadcrumbItems = () => wrapper.findAllComponents(GlBreadcrumbItem);
|
|
29
|
-
const findAllSeparators = () => wrapper.findAll('[data-testid="separator"]');
|
|
30
28
|
const findCollapsedListExpander = () => wrapper.find('[data-testid="collapsed-expander"]');
|
|
31
|
-
const findExpanderSeparator = () => wrapper.find('[data-testid="expander-separator"]');
|
|
32
29
|
|
|
33
30
|
const findVisibleBreadcrumbItems = () =>
|
|
34
|
-
|
|
35
|
-
const findHiddenBreadcrumbItems = () =>
|
|
31
|
+
findBreadcrumbItems().wrappers.filter((item) => item.isVisible());
|
|
32
|
+
const findHiddenBreadcrumbItems = () =>
|
|
33
|
+
findBreadcrumbItems().wrappers.filter((item) => !item.isVisible());
|
|
36
34
|
|
|
37
35
|
const createComponent = (propsData = { items }) => {
|
|
38
36
|
wrapper = shallowMount(Breadcrumb, {
|
|
39
37
|
propsData,
|
|
40
38
|
slots: {
|
|
41
39
|
avatar: '<div data-testid="avatar-slot"></div>',
|
|
42
|
-
separator: '<div data-testid="separator-slot"></div>',
|
|
43
40
|
},
|
|
44
41
|
stubs: {
|
|
45
42
|
GlBreadcrumbItem,
|
|
@@ -59,18 +56,6 @@ describe('Breadcrumb component', () => {
|
|
|
59
56
|
|
|
60
57
|
expect(findAvatarSlot().exists()).toBe(true);
|
|
61
58
|
});
|
|
62
|
-
|
|
63
|
-
it('has a separator slot', () => {
|
|
64
|
-
createComponent();
|
|
65
|
-
|
|
66
|
-
expect(findSeparatorSlot().exists()).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('separator slot is shown only with more than one item', () => {
|
|
70
|
-
createComponent({ items: [items[0]] });
|
|
71
|
-
|
|
72
|
-
expect(findSeparatorSlot().exists()).toBe(false);
|
|
73
|
-
});
|
|
74
59
|
});
|
|
75
60
|
|
|
76
61
|
describe('items', () => {
|
|
@@ -79,12 +64,6 @@ describe('Breadcrumb component', () => {
|
|
|
79
64
|
|
|
80
65
|
expect(findBreadcrumbItems()).toHaveLength(items.length);
|
|
81
66
|
});
|
|
82
|
-
|
|
83
|
-
it(`with ${items.length} items has ${items.length - 1} separators`, () => {
|
|
84
|
-
createComponent();
|
|
85
|
-
|
|
86
|
-
expect(findAllSeparators()).toHaveLength(items.length - 1);
|
|
87
|
-
});
|
|
88
67
|
});
|
|
89
68
|
|
|
90
69
|
describe('bindings', () => {
|
|
@@ -122,9 +101,8 @@ describe('Breadcrumb component', () => {
|
|
|
122
101
|
beforeEach(() => {
|
|
123
102
|
createComponent();
|
|
124
103
|
});
|
|
125
|
-
it('should not display collapsed list expander
|
|
104
|
+
it('should not display collapsed list expander', () => {
|
|
126
105
|
expect(findCollapsedListExpander().exists()).toBe(false);
|
|
127
|
-
expect(findExpanderSeparator().exists()).toBe(false);
|
|
128
106
|
});
|
|
129
107
|
|
|
130
108
|
it('should display all items visible', () => {
|
|
@@ -136,9 +114,8 @@ describe('Breadcrumb component', () => {
|
|
|
136
114
|
beforeEach(() => {
|
|
137
115
|
createComponent({ items: [...items, ...extraItems] });
|
|
138
116
|
});
|
|
139
|
-
it('should display collapsed list expander
|
|
117
|
+
it('should display collapsed list expander', () => {
|
|
140
118
|
expect(findCollapsedListExpander().exists()).toBe(true);
|
|
141
|
-
expect(findExpanderSeparator().exists()).toBe(true);
|
|
142
119
|
});
|
|
143
120
|
|
|
144
121
|
it('should display only first && 2 last items and the rest as hidden', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<!-- eslint-disable vue/multi-word-component-names -->
|
|
2
2
|
<script>
|
|
3
3
|
import { BBreadcrumb } from 'bootstrap-vue';
|
|
4
|
-
import GlIcon from '../icon/icon.vue';
|
|
5
4
|
import GlButton from '../button/button.vue';
|
|
6
5
|
import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
7
6
|
import GlBreadcrumbItem from './breadcrumb_item.vue';
|
|
@@ -11,7 +10,6 @@ export const COLLAPSE_AT_SIZE = 4;
|
|
|
11
10
|
export default {
|
|
12
11
|
components: {
|
|
13
12
|
BBreadcrumb,
|
|
14
|
-
GlIcon,
|
|
15
13
|
GlButton,
|
|
16
14
|
GlBreadcrumbItem,
|
|
17
15
|
},
|
|
@@ -88,49 +86,29 @@ export default {
|
|
|
88
86
|
<slot name="avatar"></slot>
|
|
89
87
|
<b-breadcrumb class="gl-breadcrumb-list" v-bind="$attrs" v-on="$listeners">
|
|
90
88
|
<template v-for="(item, index) in items">
|
|
91
|
-
<!-- eslint-disable-next-line vue/valid-v-for -->
|
|
89
|
+
<!-- eslint-disable-next-line vue/valid-v-for (for @vue/compat) -->
|
|
92
90
|
<gl-breadcrumb-item
|
|
91
|
+
v-show="!isItemCollapsed(index)"
|
|
93
92
|
:ref="isFirstItem(index) ? 'firstItem' : null"
|
|
94
93
|
:text="item.text"
|
|
95
94
|
:href="item.href"
|
|
96
95
|
:to="item.to"
|
|
97
|
-
:class="{ 'gl-display-none': isItemCollapsed(index) }"
|
|
98
96
|
:aria-current="getAriaCurrentAttr(index)"
|
|
97
|
+
>{{ item.text }}</gl-breadcrumb-item
|
|
99
98
|
>
|
|
100
|
-
<span>{{ item.text }}</span>
|
|
101
|
-
<span
|
|
102
|
-
v-if="!isLastItem(index)"
|
|
103
|
-
:key="`${index} ${item.text}`"
|
|
104
|
-
class="gl-breadcrumb-separator"
|
|
105
|
-
data-testid="separator"
|
|
106
|
-
>
|
|
107
|
-
<!-- @slot The separator to display. -->
|
|
108
|
-
<slot name="separator">
|
|
109
|
-
<gl-icon name="chevron-right" />
|
|
110
|
-
</slot>
|
|
111
|
-
</span>
|
|
112
|
-
</gl-breadcrumb-item>
|
|
113
99
|
|
|
114
100
|
<template v-if="showCollapsedBreadcrumbsExpander(index)">
|
|
115
|
-
<!-- eslint-disable-next-line vue/
|
|
116
|
-
<gl-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
key="expander"
|
|
127
|
-
class="gl-display-inline-flex gl-text-gray-500"
|
|
128
|
-
data-testid="expander-separator"
|
|
129
|
-
>
|
|
130
|
-
<slot name="separator">
|
|
131
|
-
<gl-icon name="chevron-right" />
|
|
132
|
-
</slot>
|
|
133
|
-
</span>
|
|
101
|
+
<!-- eslint-disable-next-line vue/require-v-for-key (for @vue/compat) -->
|
|
102
|
+
<li class="gl-breadcrumb-item">
|
|
103
|
+
<gl-button
|
|
104
|
+
v-gl-tooltip.hover="'Show all breadcrumbs'"
|
|
105
|
+
aria-label="Show all breadcrumbs"
|
|
106
|
+
data-testid="collapsed-expander"
|
|
107
|
+
icon="ellipsis_h"
|
|
108
|
+
category="primary"
|
|
109
|
+
@click="expandBreadcrumbs"
|
|
110
|
+
/>
|
|
111
|
+
</li>
|
|
134
112
|
</template>
|
|
135
113
|
</template>
|
|
136
114
|
</b-breadcrumb>
|