@gitlab/ui 42.3.1 → 42.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "42.3.1",
3
+ "version": "42.4.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -34,10 +34,6 @@ $label-close-button: '.gl-label-close.gl-button';
34
34
  @include gl-reset-color;
35
35
  @include gl-shadow-none;
36
36
  @include gl-outline-none;
37
-
38
- .gl-label-text-scoped {
39
- @include gl-text-decoration-underline;
40
- }
41
37
  }
42
38
  }
43
39
 
@@ -36,9 +36,11 @@ describe('Label component', () => {
36
36
  };
37
37
 
38
38
  const findLink = () => wrapper.findComponent(GlLink);
39
+ const findContent = () => wrapper.find('.gl-label-link');
39
40
  const findTitle = () => wrapper.find('.gl-label-text');
40
41
  const findSubTitle = () => wrapper.find('.gl-label-text-scoped');
41
- const findTooltipText = () => wrapper.findComponent(GlTooltip).text();
42
+ const findTooltip = () => wrapper.findComponent(GlTooltip);
43
+ const findTooltipText = () => findTooltip().text();
42
44
  const findCloseButton = () => wrapper.findComponent(CloseButton);
43
45
 
44
46
  describe('basic label', () => {
@@ -137,6 +139,22 @@ describe('Label component', () => {
137
139
  expect(wrapper.emitted().close).toBeFalsy();
138
140
  });
139
141
  });
142
+
143
+ describe('label has no target', () => {
144
+ const props = { ...defaultProps, target: '' };
145
+
146
+ it('renders the label content as text', () => {
147
+ createComponent(props, { mountFn: mount });
148
+
149
+ expect(findContent().element.tagName.toLowerCase()).toBe('span');
150
+ });
151
+
152
+ it('does not render a link', () => {
153
+ createComponent(props, { mountFn: shallowMount });
154
+
155
+ expect(findLink().exists()).toBe(false);
156
+ });
157
+ });
140
158
  });
141
159
 
142
160
  describe('scoped label', () => {
@@ -220,5 +238,21 @@ describe('Label component', () => {
220
238
  expect(wrapper.emitted().close).toBeFalsy();
221
239
  });
222
240
  });
241
+
242
+ describe('label has no target', () => {
243
+ const props = { ...defaultProps, target: '' };
244
+
245
+ it('renders the label content as text', () => {
246
+ createComponent(props, { mountFn: mount });
247
+
248
+ expect(findContent().element.tagName.toLowerCase()).toBe('span');
249
+ });
250
+
251
+ it('does not render a link', () => {
252
+ createComponent(props, { mountFn: shallowMount });
253
+
254
+ expect(findLink().exists()).toBe(false);
255
+ });
256
+ });
223
257
  });
224
258
  });
@@ -54,6 +54,9 @@ Scoped.args = generateProps({ title: 'scoped::label', scoped: true });
54
54
  export const WithCloseButton = Template.bind({});
55
55
  WithCloseButton.args = generateProps({ showCloseButton: true });
56
56
 
57
+ export const WithoutTarget = Template.bind({});
58
+ WithoutTarget.args = generateProps({ target: '' });
59
+
57
60
  export default {
58
61
  title: 'base/label',
59
62
  component: GlLabel,
@@ -41,7 +41,7 @@ export default {
41
41
  target: {
42
42
  type: String,
43
43
  required: false,
44
- default: '#',
44
+ default: '',
45
45
  },
46
46
  scoped: {
47
47
  type: Boolean,
@@ -91,6 +91,12 @@ export default {
91
91
  closeIconSize() {
92
92
  return this.size === 'sm' ? 12 : 16;
93
93
  },
94
+ labelComponent() {
95
+ return this.target ? GlLink : 'span';
96
+ },
97
+ tooltipTarget() {
98
+ return this.target ? this.$refs.labelTitle.$el : this.$refs.labelTitle;
99
+ },
94
100
  },
95
101
  watch: {
96
102
  title() {
@@ -122,14 +128,20 @@ export default {
122
128
 
123
129
  <template>
124
130
  <span class="gl-label" :class="cssClasses" :style="cssVariables" v-bind="$attrs" @click="onClick">
125
- <gl-link ref="labelTitle" :href="target" class="gl-label-link">
131
+ <component
132
+ :is="labelComponent"
133
+ ref="labelTitle"
134
+ :href="target ? target : false"
135
+ class="gl-label-link"
136
+ tabindex="0"
137
+ >
126
138
  <span class="gl-label-text">
127
139
  {{ scopedKey }}
128
140
  </span>
129
141
  <span v-if="scoped && scopedValue" class="gl-label-text-scoped">
130
142
  {{ scopedValue }}
131
143
  </span>
132
- </gl-link>
144
+ </component>
133
145
  <close-button
134
146
  v-if="showCloseButton"
135
147
  class="gl-label-close gl-p-0!"
@@ -140,7 +152,7 @@ export default {
140
152
  />
141
153
  <gl-tooltip
142
154
  v-if="description"
143
- :target="() => $refs.labelTitle.$el"
155
+ :target="() => tooltipTarget"
144
156
  :placement="tooltipPlacement"
145
157
  boundary="viewport"
146
158
  >