@gitlab/ui 37.5.0 → 37.5.1

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [37.5.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.5.0...v37.5.1) (2022-03-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlDropdown:** spinner replaces icon when icon dropdown is loading ([027a8a7](https://gitlab.com/gitlab-org/gitlab-ui/commit/027a8a7011c336b7c2562e4e839d4d8b4f7a4fe9))
7
+
1
8
  # [37.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.4.2...v37.5.0) (2022-03-10)
2
9
 
3
10
 
@@ -147,7 +147,7 @@ var script = {
147
147
  isIconOnly() {
148
148
  var _this$text;
149
149
 
150
- return Boolean(this.icon && (!((_this$text = this.text) !== null && _this$text !== void 0 && _this$text.length) || this.textSrOnly));
150
+ return Boolean(this.icon && (!((_this$text = this.text) !== null && _this$text !== void 0 && _this$text.length) || this.textSrOnly) && !this.hasSlotContents('button-text'));
151
151
  },
152
152
 
153
153
  isIconWithText() {
@@ -209,7 +209,7 @@ var script = {
209
209
  const __vue_script__ = script;
210
210
 
211
211
  /* template */
212
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",[(_vm.loading)?_c('gl-loading-icon',{staticClass:"gl-mr-2"}):_vm._e(),_vm._v(" "),(_vm.icon)?_c('gl-icon',{staticClass:"dropdown-icon",attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._t("button-text",[_vm._v(_vm._s(_vm.buttonText))])],2),_vm._v(" "),(_vm.renderCaret)?_c('gl-icon',{staticClass:"gl-button-icon dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()])]},proxy:true}],null,true)},'b-dropdown',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-new-dropdown-inner"},[(_vm.hasSlotContents('header') || _vm.headerText)?_c('div',{staticClass:"gl-new-dropdown-header",class:{ 'gl-border-b-0!': _vm.hideHeaderBorder }},[(_vm.headerText)?_c('p',{staticClass:"gl-new-dropdown-header-top"},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("header")],2):_vm._e(),_vm._v(" "),(_vm.hasHighlightedItemsOrClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-flex-start",class:_vm.highlightedItemsTitleClass},[_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))])]):_vm._e(),_vm._v(" "),(_vm.showClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-end",class:_vm.clearAllTextClass},[_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all', $event)}}},[_vm._v(_vm._s(_vm.clearAllText))])],1):_vm._e()]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-contents"},[(_vm.hasHighlightedItemsContent)?_c('div',{staticClass:"gl-overflow-visible",attrs:{"data-testid":"highlighted-items"}},[_vm._t("highlighted-items"),_vm._v(" "),_c('gl-dropdown-divider')],2):_vm._e(),_vm._v(" "),_vm._t("default")],2),_vm._v(" "),(_vm.hasSlotContents('footer'))?_c('div',{staticClass:"gl-new-dropdown-footer"},[_vm._t("footer")],2):_vm._e()])])};
212
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",[(_vm.loading)?_c('gl-loading-icon',{class:{ 'gl-mr-2': !_vm.isIconOnly }}):_vm._e(),_vm._v(" "),(_vm.icon && !(_vm.isIconOnly && _vm.loading))?_c('gl-icon',{staticClass:"dropdown-icon",attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._t("button-text",[_vm._v(_vm._s(_vm.buttonText))])],2),_vm._v(" "),(_vm.renderCaret)?_c('gl-icon',{staticClass:"gl-button-icon dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()])]},proxy:true}],null,true)},'b-dropdown',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-new-dropdown-inner"},[(_vm.hasSlotContents('header') || _vm.headerText)?_c('div',{staticClass:"gl-new-dropdown-header",class:{ 'gl-border-b-0!': _vm.hideHeaderBorder }},[(_vm.headerText)?_c('p',{staticClass:"gl-new-dropdown-header-top"},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("header")],2):_vm._e(),_vm._v(" "),(_vm.hasHighlightedItemsOrClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-flex-start",class:_vm.highlightedItemsTitleClass},[_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))])]):_vm._e(),_vm._v(" "),(_vm.showClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-end",class:_vm.clearAllTextClass},[_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all', $event)}}},[_vm._v(_vm._s(_vm.clearAllText))])],1):_vm._e()]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-contents"},[(_vm.hasHighlightedItemsContent)?_c('div',{staticClass:"gl-overflow-visible",attrs:{"data-testid":"highlighted-items"}},[_vm._t("highlighted-items"),_vm._v(" "),_c('gl-dropdown-divider')],2):_vm._e(),_vm._v(" "),_vm._t("default")],2),_vm._v(" "),(_vm.hasSlotContents('footer'))?_c('div',{staticClass:"gl-new-dropdown-footer"},[_vm._t("footer")],2):_vm._e()])])};
213
213
  var __vue_staticRenderFns__ = [];
214
214
 
215
215
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "37.5.0",
3
+ "version": "37.5.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -336,6 +336,7 @@ describe('new dropdown', () => {
336
336
  const slots = { 'button-text': mockComponent };
337
337
  buildWrapper({ loading: true, icon: 'close' }, slots);
338
338
  expect(wrapper.findComponent(mockComponent).exists()).toBe(true);
339
+ expect(wrapper.text()).toBe('mock');
339
340
  expect(findLoadingIcon().exists()).toBe(true);
340
341
  expect(findIcon().exists()).toBe(true);
341
342
  expect(findCaret().exists()).toBe(true);
@@ -345,12 +346,40 @@ describe('new dropdown', () => {
345
346
  const slots = { 'button-content': mockComponent };
346
347
  buildWrapper({ loading: true, icon: 'close' }, slots);
347
348
  expect(wrapper.findComponent(mockComponent).exists()).toBe(true);
349
+ expect(wrapper.text()).toBe('mock');
348
350
  expect(findLoadingIcon().exists()).toBe(false);
349
351
  expect(findIcon().exists()).toBe(false);
350
352
  expect(findCaret().exists()).toBe(false);
351
353
  });
352
354
  });
353
355
 
356
+ describe('icon only dropdown', () => {
357
+ it('shows the icon and dropdown caret', () => {
358
+ buildWrapper({ icon: 'paper-airplane' });
359
+ expect(wrapper.text()).toBe('');
360
+ expect(findLoadingIcon().exists()).toBe(false);
361
+ expect(findIcon().exists()).toBe(true);
362
+ expect(findCaret().exists()).toBe(true);
363
+ });
364
+
365
+ it('shows text for screen readers', () => {
366
+ buildWrapper({ icon: 'paper-airplane', text: 'screenreader button text', textSrOnly: true });
367
+ expect(wrapper.text()).toBe('screenreader button text');
368
+ expect(wrapper.find('span').classes()).toContain('gl-sr-only');
369
+ expect(findLoadingIcon().exists()).toBe(false);
370
+ expect(findIcon().exists()).toBe(true);
371
+ expect(findCaret().exists()).toBe(true);
372
+ });
373
+
374
+ it('shows loading spinner instead of icon when loading', () => {
375
+ buildWrapper({ icon: 'paper-airplane', loading: true });
376
+ expect(wrapper.text()).toBe('');
377
+ expect(findLoadingIcon().exists()).toBe(true);
378
+ expect(findIcon().exists()).toBe(false);
379
+ expect(findCaret().exists()).toBe(true);
380
+ });
381
+ });
382
+
354
383
  describe('Clear all button', () => {
355
384
  it('is not visible by default', () => {
356
385
  buildWrapper({});
@@ -151,7 +151,9 @@ export default {
151
151
  return !this.split;
152
152
  },
153
153
  isIconOnly() {
154
- return Boolean(this.icon && (!this.text?.length || this.textSrOnly));
154
+ return Boolean(
155
+ this.icon && (!this.text?.length || this.textSrOnly) && !this.hasSlotContents('button-text')
156
+ );
155
157
  },
156
158
  isIconWithText() {
157
159
  return Boolean(this.icon && this.text?.length && !this.textSrOnly);
@@ -282,8 +284,8 @@ export default {
282
284
  </div>
283
285
  <template #button-content>
284
286
  <slot name="button-content">
285
- <gl-loading-icon v-if="loading" class="gl-mr-2" />
286
- <gl-icon v-if="icon" class="dropdown-icon" :name="icon" />
287
+ <gl-loading-icon v-if="loading" :class="{ 'gl-mr-2': !isIconOnly }" />
288
+ <gl-icon v-if="icon && !(isIconOnly && loading)" class="dropdown-icon" :name="icon" />
287
289
  <span class="gl-new-dropdown-button-text" :class="{ 'gl-sr-only': textSrOnly }">
288
290
  <slot name="button-text">{{ buttonText }}</slot>
289
291
  </span>