@gitlab/ui 32.29.0 → 32.31.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.
@@ -60,5 +60,20 @@ const splitAfterSymbols = (symbols, string) => {
60
60
 
61
61
  return textParts;
62
62
  };
63
+ const getAvatarChar = name => {
64
+ if (name) {
65
+ // Check if first character is an emjoi
66
+ const match = name.match(/^\p{Emoji}/u);
63
67
 
64
- export { splitAfterSymbols };
68
+ if (match) {
69
+ // Return the first match
70
+ return match[0];
71
+ }
72
+
73
+ return name.charAt(0).toUpperCase();
74
+ }
75
+
76
+ return '';
77
+ };
78
+
79
+ export { getAvatarChar, splitAfterSymbols };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "32.29.0",
3
+ "version": "32.31.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -43,6 +43,26 @@ function generateProjectFallbackProps() {
43
43
  return props;
44
44
  }
45
45
 
46
+ function generateEmojiProjectProps() {
47
+ const defaultSize = avatarSizeOptions[1];
48
+ const props = {
49
+ entityId: {
50
+ type: Number,
51
+ default: number('entityId', 123),
52
+ },
53
+ entityName: {
54
+ type: String,
55
+ default: text('entityName', '🦊Tanuki'),
56
+ },
57
+ size: {
58
+ type: Number,
59
+ default: select('size', avatarSizeOptions, defaultSize),
60
+ },
61
+ };
62
+
63
+ return props;
64
+ }
65
+
46
66
  function generateTooltipProps() {
47
67
  const props = {
48
68
  tooltipText: {
@@ -80,6 +100,16 @@ documentedStoriesOf('base/avatar', readme)
80
100
  shape="rect" />
81
101
  `,
82
102
  }))
103
+ .add('emoji-project-name', () => ({
104
+ props: generateEmojiProjectProps(),
105
+ template: `
106
+ <gl-avatar
107
+ :entity-name="entityName"
108
+ :entity-id="entityId"
109
+ :size="size"
110
+ shape="rect" />
111
+ `,
112
+ }))
83
113
  .add('with-tooltip', () => ({
84
114
  props: {
85
115
  ...generateImageProps(),
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { avatarShapeOptions, avatarSizeOptions } from '../../../utils/constants';
3
+ import { getAvatarChar } from '../../../utils/string_utils';
3
4
 
4
5
  const IDENTICON_BG_COUNT = 7;
5
6
 
@@ -62,7 +63,7 @@ export default {
62
63
  return `gl-avatar-identicon-bg${type}`;
63
64
  },
64
65
  identiconText() {
65
- return this.entityName ? this.entityName.charAt(0).toUpperCase() : '';
66
+ return getAvatarChar(this.entityName);
66
67
  },
67
68
  },
68
69
  };
@@ -8,14 +8,12 @@ describe('toggle', () => {
8
8
  let wrapper;
9
9
 
10
10
  const label = 'toggle label';
11
- const labelId = 'toggle-label-id';
12
11
  const helpText = 'help text';
13
12
 
14
13
  const createWrapper = (props = {}) => {
15
14
  wrapper = shallowMount(Toggle, {
16
15
  propsData: {
17
16
  label,
18
- labelId,
19
17
  ...props,
20
18
  },
21
19
  });
@@ -131,7 +129,7 @@ describe('toggle', () => {
131
129
  });
132
130
 
133
131
  it('has accessible name for the button', () => {
134
- expect(findButton().attributes('aria-labelledby')).toBe(labelId);
132
+ expect(findButton().attributes('aria-labelledby')).toBeDefined();
135
133
  });
136
134
  });
137
135
  });
@@ -1,4 +1,6 @@
1
1
  <script>
2
+ import { uniqueId } from 'lodash';
3
+
2
4
  import { toggleLabelPosition } from '../../../utils/constants';
3
5
  import GlIcon from '../icon/icon.vue';
4
6
  import GlLoadingIcon from '../loading_icon/loading_icon.vue';
@@ -60,13 +62,6 @@ export default {
60
62
  required: false,
61
63
  default: undefined,
62
64
  },
63
- /**
64
- * The id for the label. This id is used by the aria-labelledby attribute on the toggle button.
65
- */
66
- labelId: {
67
- type: String,
68
- required: true,
69
- },
70
65
  /**
71
66
  * The label's position relative to the toggle. If 'hidden', the toggle will add the .gl-sr-only class so the label is still accessible to screen readers.
72
67
  */
@@ -79,7 +74,11 @@ export default {
79
74
  },
80
75
  },
81
76
  },
82
-
77
+ data() {
78
+ return {
79
+ labelId: uniqueId('toggle-label-'),
80
+ };
81
+ },
83
82
  computed: {
84
83
  icon() {
85
84
  return this.value ? 'mobile-issue-close' : 'close';
@@ -78,7 +78,7 @@
78
78
  @mixin gl-media-breakpoint-up($name) {
79
79
  $min: map-get($breakpoints, $name);
80
80
  @if $min == null {
81
- @error;
81
+ @error "#{$name} is not a valid breakpoint for this @media query.";
82
82
  }
83
83
  @if $min != 0 {
84
84
  @media (min-width: $min) {
@@ -103,7 +103,7 @@
103
103
  @mixin gl-media-breakpoint-down($name) {
104
104
  $max: map-get($breakpoints, $name);
105
105
  @if ($max == null or $max == 0) {
106
- @error;
106
+ @error "#{$name} is not a valid breakpoint for this @media query.";
107
107
  }
108
108
  // The maximum value is reduced by 0.02px to work around the limitations of
109
109
  // `min-` and `max-` prefixes and with fractional viewport sizes.
@@ -889,6 +889,38 @@
889
889
  border-style: solid !important;
890
890
  }
891
891
 
892
+ .gl-border-dashed {
893
+ border-style: dashed;
894
+ }
895
+
896
+ .gl-hover-border-dashed:hover {
897
+ border-style: dashed;
898
+ }
899
+
900
+ .gl-border-dashed\! {
901
+ border-style: dashed !important;
902
+ }
903
+
904
+ .gl-hover-border-dashed\!:hover {
905
+ border-style: dashed !important;
906
+ }
907
+
908
+ .gl-border-dotted {
909
+ border-style: dotted;
910
+ }
911
+
912
+ .gl-hover-border-dotted:hover {
913
+ border-style: dotted;
914
+ }
915
+
916
+ .gl-border-dotted\! {
917
+ border-style: dotted !important;
918
+ }
919
+
920
+ .gl-hover-border-dotted\!:hover {
921
+ border-style: dotted !important;
922
+ }
923
+
892
924
  .gl-border-t-solid {
893
925
  border-top-style: solid;
894
926
  }
@@ -15,6 +15,14 @@
15
15
  border-style: solid;
16
16
  }
17
17
 
18
+ @mixin gl-border-dashed($hover: true) {
19
+ border-style: dashed;
20
+ }
21
+
22
+ @mixin gl-border-dotted($hover: true) {
23
+ border-style: dotted;
24
+ }
25
+
18
26
  @mixin gl-border-t-solid($hover: true) {
19
27
  border-top-style: solid;
20
28
  }
@@ -59,3 +59,17 @@ export const splitAfterSymbols = (symbols, string) => {
59
59
 
60
60
  return textParts;
61
61
  };
62
+
63
+ export const getAvatarChar = (name) => {
64
+ if (name) {
65
+ // Check if first character is an emjoi
66
+ const match = name.match(/^\p{Emoji}/u);
67
+ if (match) {
68
+ // Return the first match
69
+ return match[0];
70
+ }
71
+ return name.charAt(0).toUpperCase();
72
+ }
73
+
74
+ return '';
75
+ };
@@ -1,4 +1,4 @@
1
- import { splitAfterSymbols } from './string_utils';
1
+ import { splitAfterSymbols, getAvatarChar } from './string_utils';
2
2
 
3
3
  describe('string utils', () => {
4
4
  describe('splitAfterSymbols', () => {
@@ -27,4 +27,22 @@ describe('string utils', () => {
27
27
  expect(actual.join('')).toEqual(string);
28
28
  });
29
29
  });
30
+
31
+ describe('Avatar name parsing', () => {
32
+ it('Returns first character of name', () => {
33
+ expect(getAvatarChar('Some Project')).toBe('S');
34
+ });
35
+
36
+ it('Returns empty if name is empty', () => {
37
+ expect(getAvatarChar('')).toBe('');
38
+ });
39
+
40
+ it('Returns emoji if it is first character in name', () => {
41
+ expect(getAvatarChar('🦊Tanuki')).toBe('🦊');
42
+ });
43
+
44
+ it('Returns first character if emoji is not first in name', () => {
45
+ expect(getAvatarChar('tanuki🦊')).toBe('T');
46
+ });
47
+ });
30
48
  });