@gitlab/ui 123.1.0 → 123.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.
Files changed (35) hide show
  1. package/dist/components/base/button/button.js +21 -2
  2. package/dist/components/base/popover/popover.js +18 -3
  3. package/dist/components/dashboards/dashboard_panel/dashboard_panel.js +2 -2
  4. package/dist/components/experimental/experiment_badge/experiment_badge.js +1 -1
  5. package/dist/index.css +2 -2
  6. package/dist/index.css.map +1 -1
  7. package/dist/tokens/build/js/tokens.dark.js +2 -1
  8. package/dist/tokens/build/js/tokens.js +2 -1
  9. package/dist/tokens/css/tokens.css +1 -0
  10. package/dist/tokens/css/tokens.dark.css +1 -0
  11. package/dist/tokens/figma/contextual.tokens.json +18 -0
  12. package/dist/tokens/js/tokens.dark.js +1 -0
  13. package/dist/tokens/js/tokens.js +1 -0
  14. package/dist/tokens/json/tokens.dark.json +41 -0
  15. package/dist/tokens/json/tokens.json +41 -0
  16. package/dist/tokens/scss/_tokens.dark.scss +1 -0
  17. package/dist/tokens/scss/_tokens.scss +1 -0
  18. package/dist/tokens/scss/_tokens_custom_properties.scss +1 -0
  19. package/package.json +4 -4
  20. package/src/components/base/button/button.scss +23 -4
  21. package/src/components/base/button/button.vue +27 -2
  22. package/src/components/base/popover/popover.vue +21 -3
  23. package/src/components/dashboards/dashboard_panel/dashboard_panel.vue +2 -2
  24. package/src/components/experimental/experiment_badge/experiment_badge.vue +1 -1
  25. package/src/tokens/build/css/tokens.css +1 -0
  26. package/src/tokens/build/css/tokens.dark.css +1 -0
  27. package/src/tokens/build/figma/contextual.tokens.json +18 -0
  28. package/src/tokens/build/js/tokens.dark.js +1 -0
  29. package/src/tokens/build/js/tokens.js +1 -0
  30. package/src/tokens/build/json/tokens.dark.json +41 -0
  31. package/src/tokens/build/json/tokens.json +41 -0
  32. package/src/tokens/build/scss/_tokens.dark.scss +1 -0
  33. package/src/tokens/build/scss/_tokens.scss +1 -0
  34. package/src/tokens/build/scss/_tokens_custom_properties.scss +1 -0
  35. package/src/tokens/contextual/button.tokens.json +18 -0
@@ -214,13 +214,29 @@ export default {
214
214
  // so we must set it as `null` here to be a true tri-state prop
215
215
  default: null,
216
216
  },
217
+ /**
218
+ * Display a count badge next to the button text.
219
+ */
220
+ count: {
221
+ type: Number,
222
+ required: false,
223
+ default: null,
224
+ },
225
+ /**
226
+ * Screen reader text to provide context for the count value.
227
+ */
228
+ countSrText: {
229
+ type: String,
230
+ required: false,
231
+ default: null,
232
+ },
217
233
  },
218
234
  computed: {
219
235
  hasIcon() {
220
236
  return this.icon !== '';
221
237
  },
222
238
  hasIconOnly() {
223
- return isSlotEmpty(this, 'default') && this.hasIcon;
239
+ return isSlotEmpty(this, 'default') && this.hasIcon && this.count == null;
224
240
  },
225
241
  isButtonDisabled() {
226
242
  return this.disabled || this.loading;
@@ -329,6 +345,9 @@ export default {
329
345
 
330
346
  return this.tag;
331
347
  },
348
+ hasCount() {
349
+ return this.count != null && this.count >= 0;
350
+ },
332
351
  },
333
352
  mounted() {
334
353
  // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
@@ -373,6 +392,12 @@ export default {
373
392
  <gl-loading-icon v-if="loading" inline class="gl-button-icon gl-button-loading-indicator" />
374
393
  <gl-icon v-if="hasIcon && !(hasIconOnly && loading)" class="gl-button-icon" :name="icon" />
375
394
  <slot name="emoji"></slot>
376
- <span v-if="!hasIconOnly" :class="buttonTextClasses" class="gl-button-text"><slot></slot></span>
395
+ <span v-if="!hasIconOnly" :class="buttonTextClasses" class="gl-button-text">
396
+ <slot></slot>
397
+ <span v-if="hasCount" class="gl-button-count">
398
+ {{ count }}
399
+ <span v-if="countSrText" class="gl-sr-only">{{ countSrText }}</span>
400
+ </span>
401
+ </span>
377
402
  </component>
378
403
  </template>
@@ -17,9 +17,9 @@ export default {
17
17
  inheritAttrs: false,
18
18
  props: {
19
19
  cssClasses: {
20
- type: Array,
20
+ type: [Array, String, Object],
21
21
  required: false,
22
- default: () => [],
22
+ default: '',
23
23
  },
24
24
  /**
25
25
  * Space-separated triggers for the popover.
@@ -61,7 +61,7 @@ export default {
61
61
  'gl-popover',
62
62
  this.hasTitle && 'has-title',
63
63
  this.showCloseButton && 'has-close-button',
64
- ...this.cssClasses,
64
+ ...this.normalizedCssClasses(this.cssClasses),
65
65
  ]
66
66
  .filter(Boolean)
67
67
  .join(' ');
@@ -71,6 +71,24 @@ export default {
71
71
  },
72
72
  },
73
73
  methods: {
74
+ /**
75
+ * `cssClasses can be a string, an array, or an object. This method normalizes it to an array
76
+ */
77
+ normalizedCssClasses(cssClasses) {
78
+ if (Array.isArray(cssClasses)) {
79
+ return cssClasses;
80
+ }
81
+
82
+ if (typeof cssClasses === 'string') {
83
+ return cssClasses.trim() ? cssClasses.trim().split(/\s+/) : [];
84
+ }
85
+
86
+ if (cssClasses && typeof cssClasses === 'object') {
87
+ return Object.keys(cssClasses).filter((key) => cssClasses[key]);
88
+ }
89
+
90
+ return [];
91
+ },
74
92
  close(e) {
75
93
  this.$refs[popoverRefName].doClose();
76
94
  /**
@@ -90,9 +90,9 @@ export default {
90
90
  * CSS classes to apply to the title popover (gets passed to the `css-classes` prop of the `GlPopover` component).
91
91
  */
92
92
  titlePopoverClasses: {
93
- type: Array,
93
+ type: [Array, String, Object],
94
94
  required: false,
95
- default: () => [],
95
+ default: '',
96
96
  },
97
97
  /**
98
98
  * Set to `true` to show the loading state.
@@ -85,7 +85,7 @@ export default {
85
85
  show-close-button
86
86
  :placement="popoverPlacement"
87
87
  :target="triggerId"
88
- :css-classes="['!gl-z-9999']"
88
+ css-classes="!gl-z-9999"
89
89
  :title="activeType.POPOVER_TITLE"
90
90
  >
91
91
  <gl-sprintf :message="activeType.POPOVER_CONTENT">
@@ -774,6 +774,7 @@
774
774
  --gl-button-disabled-foreground-color: var(--gl-color-neutral-500); /** Used for the foreground of a disabled button. */
775
775
  --gl-button-disabled-background-color: var(--gl-color-neutral-10); /** Used for the background of a disabled button. */
776
776
  --gl-button-disabled-border-color: var(--gl-color-neutral-100); /** Used for the border of a disabled button. */
777
+ --gl-button-count-background-color: var(--gl-color-alpha-dark-8); /** Used for the background of a button count element. */
777
778
  --gl-chart-axis-line-color: var(--gl-color-neutral-200); /** Used in charts for axis line color. */
778
779
  --gl-chart-threshold-line-color: var(--gl-color-red-500); /** Used in charts to divide a threshold area in a chart from other data. */
779
780
  --gl-chart-zoom-filler-color: var(--gl-color-alpha-dark-8); /** Used in charts for the overlay color when zooming in on a specific area of data. */
@@ -774,6 +774,7 @@
774
774
  --gl-button-disabled-foreground-color: var(--gl-color-neutral-400); /** Used for the foreground of a disabled button. */
775
775
  --gl-button-disabled-background-color: rgba(137, 136, 141, 0.16); /** Used for the background of a disabled button. */
776
776
  --gl-button-disabled-border-color: var(--gl-color-alpha-0); /** Used for the border of a disabled button. */
777
+ --gl-button-count-background-color: var(--gl-color-alpha-light-16); /** Used for the background of a button count element. */
777
778
  --gl-chart-axis-line-color: var(--gl-color-neutral-700); /** Used in charts for axis line color. */
778
779
  --gl-chart-threshold-line-color: var(--gl-color-red-600); /** Used in charts to divide a threshold area in a chart from other data. */
779
780
  --gl-chart-zoom-filler-color: var(--gl-color-alpha-light-16); /** Used in charts for the overlay color when zooming in on a specific area of data. */
@@ -4129,6 +4129,24 @@
4129
4129
  }
4130
4130
  }
4131
4131
  },
4132
+ "count": {
4133
+ "background": {
4134
+ "color": {
4135
+ "$value": {
4136
+ "default": "{color.alpha.dark.8}",
4137
+ "dark": "{color.alpha.light.16}"
4138
+ },
4139
+ "$type": "color",
4140
+ "$description": "Used for the background of a button count element.",
4141
+ "$extensions": {
4142
+ "com.figma.scope": [
4143
+ "FRAME_FILL",
4144
+ "SHAPE_FILL"
4145
+ ]
4146
+ }
4147
+ }
4148
+ }
4149
+ },
4132
4150
  "$extensions": {
4133
4151
  "com.gitlab.locked": true
4134
4152
  }
@@ -678,6 +678,7 @@ export const GL_BUTTON_SELECTED_BORDER_COLOR_ACTIVE = 'transparent';
678
678
  export const GL_BUTTON_DISABLED_FOREGROUND_COLOR = '#89888d';
679
679
  export const GL_BUTTON_DISABLED_BACKGROUND_COLOR = 'rgba(137, 136, 141, 0.16)';
680
680
  export const GL_BUTTON_DISABLED_BORDER_COLOR = 'transparent';
681
+ export const GL_BUTTON_COUNT_BACKGROUND_COLOR = 'rgba(255, 255, 255, 0.16)';
681
682
  export const GL_CARD_BORDER_RADIUS = '0.25rem';
682
683
  export const GL_CHART_AXIS_POINTER_COLOR = '#bfbfc3';
683
684
  export const GL_CHART_AXIS_LINE_COLOR = '#4c4b51';
@@ -678,6 +678,7 @@ export const GL_BUTTON_SELECTED_BORDER_COLOR_ACTIVE = '#626168';
678
678
  export const GL_BUTTON_DISABLED_FOREGROUND_COLOR = '#737278';
679
679
  export const GL_BUTTON_DISABLED_BACKGROUND_COLOR = '#fbfafd';
680
680
  export const GL_BUTTON_DISABLED_BORDER_COLOR = '#dcdcde';
681
+ export const GL_BUTTON_COUNT_BACKGROUND_COLOR = 'rgba(05, 05, 06, 0.08)';
681
682
  export const GL_CARD_BORDER_RADIUS = '0.25rem';
682
683
  export const GL_CHART_AXIS_POINTER_COLOR = '#626168';
683
684
  export const GL_CHART_AXIS_LINE_COLOR = '#bfbfc3';
@@ -19404,6 +19404,47 @@
19404
19404
  ]
19405
19405
  }
19406
19406
  }
19407
+ },
19408
+ "count": {
19409
+ "background": {
19410
+ "color": {
19411
+ "key": "{button.count.background.color}",
19412
+ "$value": "rgba(255, 255, 255, 0.16)",
19413
+ "$type": "color",
19414
+ "$description": "Used for the background of a button count element.",
19415
+ "$extensions": {
19416
+ "com.figma.scope": [
19417
+ "FRAME_FILL",
19418
+ "SHAPE_FILL"
19419
+ ]
19420
+ },
19421
+ "filePath": "src/tokens/contextual/button.tokens.json",
19422
+ "isSource": true,
19423
+ "original": {
19424
+ "$value": {
19425
+ "default": "{color.alpha.dark.8}",
19426
+ "dark": "{color.alpha.light.16}"
19427
+ },
19428
+ "$type": "color",
19429
+ "$description": "Used for the background of a button count element.",
19430
+ "$extensions": {
19431
+ "com.figma.scope": [
19432
+ "FRAME_FILL",
19433
+ "SHAPE_FILL"
19434
+ ]
19435
+ },
19436
+ "key": "{button.count.background.color}"
19437
+ },
19438
+ "name": "BUTTON_COUNT_BACKGROUND_COLOR",
19439
+ "attributes": {},
19440
+ "path": [
19441
+ "button",
19442
+ "count",
19443
+ "background",
19444
+ "color"
19445
+ ]
19446
+ }
19447
+ }
19407
19448
  }
19408
19449
  },
19409
19450
  "card": {
@@ -19404,6 +19404,47 @@
19404
19404
  ]
19405
19405
  }
19406
19406
  }
19407
+ },
19408
+ "count": {
19409
+ "background": {
19410
+ "color": {
19411
+ "key": "{button.count.background.color}",
19412
+ "$value": "rgba(05, 05, 06, 0.08)",
19413
+ "$type": "color",
19414
+ "$description": "Used for the background of a button count element.",
19415
+ "$extensions": {
19416
+ "com.figma.scope": [
19417
+ "FRAME_FILL",
19418
+ "SHAPE_FILL"
19419
+ ]
19420
+ },
19421
+ "filePath": "src/tokens/contextual/button.tokens.json",
19422
+ "isSource": true,
19423
+ "original": {
19424
+ "$value": {
19425
+ "default": "{color.alpha.dark.8}",
19426
+ "dark": "{color.alpha.light.16}"
19427
+ },
19428
+ "$type": "color",
19429
+ "$description": "Used for the background of a button count element.",
19430
+ "$extensions": {
19431
+ "com.figma.scope": [
19432
+ "FRAME_FILL",
19433
+ "SHAPE_FILL"
19434
+ ]
19435
+ },
19436
+ "key": "{button.count.background.color}"
19437
+ },
19438
+ "name": "BUTTON_COUNT_BACKGROUND_COLOR",
19439
+ "attributes": {},
19440
+ "path": [
19441
+ "button",
19442
+ "count",
19443
+ "background",
19444
+ "color"
19445
+ ]
19446
+ }
19447
+ }
19407
19448
  }
19408
19449
  },
19409
19450
  "card": {
@@ -772,6 +772,7 @@ $gl-button-selected-border-color-active: $gl-color-alpha-0; // Used for the bord
772
772
  $gl-button-disabled-foreground-color: $gl-color-neutral-400; // Used for the foreground of a disabled button.
773
773
  $gl-button-disabled-background-color: rgba(137, 136, 141, 0.16); // Used for the background of a disabled button.
774
774
  $gl-button-disabled-border-color: $gl-color-alpha-0; // Used for the border of a disabled button.
775
+ $gl-button-count-background-color: $gl-color-alpha-light-16; // Used for the background of a button count element.
775
776
  $gl-chart-axis-line-color: $gl-color-neutral-700; // Used in charts for axis line color.
776
777
  $gl-chart-threshold-line-color: $gl-color-red-600; // Used in charts to divide a threshold area in a chart from other data.
777
778
  $gl-chart-zoom-filler-color: $gl-color-alpha-light-16; // Used in charts for the overlay color when zooming in on a specific area of data.
@@ -772,6 +772,7 @@ $gl-button-selected-border-color-active: $gl-color-neutral-600; // Used for the
772
772
  $gl-button-disabled-foreground-color: $gl-color-neutral-500; // Used for the foreground of a disabled button.
773
773
  $gl-button-disabled-background-color: $gl-color-neutral-10; // Used for the background of a disabled button.
774
774
  $gl-button-disabled-border-color: $gl-color-neutral-100; // Used for the border of a disabled button.
775
+ $gl-button-count-background-color: $gl-color-alpha-dark-8; // Used for the background of a button count element.
775
776
  $gl-chart-axis-line-color: $gl-color-neutral-200; // Used in charts for axis line color.
776
777
  $gl-chart-threshold-line-color: $gl-color-red-500; // Used in charts to divide a threshold area in a chart from other data.
777
778
  $gl-chart-zoom-filler-color: $gl-color-alpha-dark-8; // Used in charts for the overlay color when zooming in on a specific area of data.
@@ -619,6 +619,7 @@ $gl-button-selected-border-color-active: var(--gl-button-selected-border-color-a
619
619
  $gl-button-disabled-foreground-color: var(--gl-button-disabled-foreground-color);
620
620
  $gl-button-disabled-background-color: var(--gl-button-disabled-background-color);
621
621
  $gl-button-disabled-border-color: var(--gl-button-disabled-border-color);
622
+ $gl-button-count-background-color: var(--gl-button-count-background-color);
622
623
  $gl-card-border-radius: var(--gl-card-border-radius);
623
624
  $gl-chart-axis-pointer-color: var(--gl-chart-axis-pointer-color);
624
625
  $gl-chart-axis-line-color: var(--gl-chart-axis-line-color);
@@ -1591,6 +1591,24 @@
1591
1591
  }
1592
1592
  }
1593
1593
  }
1594
+ },
1595
+ "count": {
1596
+ "background": {
1597
+ "color": {
1598
+ "$value": {
1599
+ "default": "{color.alpha.dark.8}",
1600
+ "dark": "{color.alpha.light.16}"
1601
+ },
1602
+ "$type": "color",
1603
+ "$description": "Used for the background of a button count element.",
1604
+ "$extensions": {
1605
+ "com.figma.scope": [
1606
+ "FRAME_FILL",
1607
+ "SHAPE_FILL"
1608
+ ]
1609
+ }
1610
+ }
1611
+ }
1594
1612
  }
1595
1613
  }
1596
1614
  }