@gitlab/ui 32.65.1 → 33.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.
Files changed (23) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/components/utilities/intersection_observer/intersection_observer.documentation.js +1 -20
  3. package/dist/components/utilities/intersection_observer/intersection_observer.js +12 -0
  4. package/dist/utility_classes.css +1 -1
  5. package/dist/utility_classes.css.map +1 -1
  6. package/documentation/documented_stories.js +1 -0
  7. package/package.json +2 -2
  8. package/scss_to_js/scss_variables.js +1 -0
  9. package/scss_to_js/scss_variables.json +5 -0
  10. package/src/components/utilities/intersection_observer/intersection_observer.documentation.js +0 -23
  11. package/src/components/utilities/intersection_observer/intersection_observer.stories.js +91 -80
  12. package/src/components/utilities/intersection_observer/intersection_observer.vue +15 -0
  13. package/src/scss/utilities.scss +46 -26
  14. package/src/scss/utility-mixins/flex.scss +1 -8
  15. package/src/scss/utility-mixins/sizing.scss +16 -0
  16. package/src/scss/utility-mixins/spacing.scss +7 -7
  17. package/src/scss/variables.scss +1 -0
  18. package/dist/components/utilities/intersection_observer/examples/index.js +0 -19
  19. package/dist/components/utilities/intersection_observer/examples/intersection_observer.image.example.js +0 -62
  20. package/dist/components/utilities/intersection_observer/examples/intersection_observer.last_appeared.example.js +0 -83
  21. package/src/components/utilities/intersection_observer/examples/index.js +0 -23
  22. package/src/components/utilities/intersection_observer/examples/intersection_observer.image.example.vue +0 -29
  23. package/src/components/utilities/intersection_observer/examples/intersection_observer.last_appeared.example.vue +0 -43
@@ -119,6 +119,7 @@ export const setupStorybookReadme = () =>
119
119
  'GlTable',
120
120
  'GlToast',
121
121
  'GlPaginatedList',
122
+ 'GlIntersectionObserver',
122
123
  ],
123
124
  components: {
124
125
  GlComponentDocumentation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "32.65.1",
3
+ "version": "33.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "test:unit:watch": "yarn test:unit --watch --notify",
42
42
  "test:unit:debug": "NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
43
43
  "test:visual": "NODE_ENV=test IS_VISUAL_TEST=true start-test http-get://localhost:9001 'jest ./tests/storyshots.spec.js'",
44
- "test:visual:update": "NODE_ENV=test IS_VISUAL_TEST=true start-test http-get://localhost:9001 'jest ./tests/storyshots.spec.js --updateSnapshot'",
44
+ "test:visual:update": "NODE_ENV=test IS_VISUAL_TEST=true JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 start-test http-get://localhost:9001 'jest ./tests/storyshots.spec.js --updateSnapshot'",
45
45
  "prettier": "prettier --check '**/*.{js,vue}'",
46
46
  "prettier:fix": "prettier --write '**/*.{js,vue}'",
47
47
  "eslint": "eslint --max-warnings 0 --ext .js,.vue .",
@@ -16,6 +16,7 @@ export const glSpacingScale13 = '6rem'
16
16
  export const glSpacingScale15 = '7.5rem'
17
17
  export const glSpacingScale20 = '10rem'
18
18
  export const glSpacingScale26 = '13rem'
19
+ export const glSpacingScale28 = '14rem'
19
20
  export const glSpacingScale62 = '31rem'
20
21
  export const breakpointSm = '576px'
21
22
  export const breakpointMd = '768px'
@@ -90,6 +90,11 @@
90
90
  "value": "26 * $grid-size",
91
91
  "compiledValue": "13rem"
92
92
  },
93
+ {
94
+ "name": "$gl-spacing-scale-28",
95
+ "value": "28 * $grid-size",
96
+ "compiledValue": "14rem"
97
+ },
93
98
  {
94
99
  "name": "$gl-spacing-scale-62",
95
100
  "value": "62 * $grid-size",
@@ -1,28 +1,5 @@
1
- import examples from './examples';
2
1
  import * as description from './intersection_observer.md';
3
2
 
4
3
  export default {
5
4
  description,
6
- examples,
7
- propsInfo: {
8
- options: {
9
- additionalInfo: 'Extra options to pass directly to the intersection observer API.',
10
- },
11
- },
12
- events: [
13
- {
14
- event: 'appear',
15
- description: 'Emitted when the element appears on the page',
16
- },
17
- {
18
- event: 'disappear',
19
- description: 'Emitted when the element disappears from the page',
20
- },
21
- ],
22
- slots: [
23
- {
24
- slot: 'default',
25
- description: "The element you wish to observe, or a fallback if the observer doesn't work.",
26
- },
27
- ],
28
5
  };
@@ -1,4 +1,3 @@
1
- import { documentedStoriesOf } from '../../../../documentation/documented_stories';
2
1
  import { GlIntersectionObserver } from '../../../../index';
3
2
  import readme from './intersection_observer.md';
4
3
 
@@ -31,17 +30,16 @@ const generateItems = (startingId = 0) => {
31
30
  });
32
31
  };
33
32
 
34
- documentedStoriesOf('utilities/intersection-observer', readme)
35
- .add('default', () => ({
36
- components,
37
- data: commonData,
38
- methods: commonMethods,
39
- computed: {
40
- visibility() {
41
- return this.isInView ? 'The observer is in view' : 'The observer is not in view';
42
- },
33
+ export const Default = () => ({
34
+ components,
35
+ data: commonData,
36
+ methods: commonMethods,
37
+ computed: {
38
+ visibility() {
39
+ return this.isInView ? 'The observer is in view' : 'The observer is not in view';
43
40
  },
44
- template: `
41
+ },
42
+ template: `
45
43
  <div style="height: 200px; overflow-y: scroll;">
46
44
  <h1>{{ visibility }}</h1>
47
45
  <p>This one is a hard one to demonstrate as it's invisible by nature.</p>
@@ -55,26 +53,27 @@ documentedStoriesOf('utilities/intersection-observer', readme)
55
53
  />
56
54
  <p>This line appears just after the observer.</p>
57
55
  </div>
58
- `,
59
- }))
60
- .add('big table', () => ({
61
- components,
62
- data() {
63
- return {
64
- values: Array(100)
65
- .fill(1)
66
- .map(() => Array(10).fill(0)),
67
- };
56
+ `,
57
+ });
58
+
59
+ export const BigTable = () => ({
60
+ components,
61
+ data() {
62
+ return {
63
+ values: Array(100)
64
+ .fill(1)
65
+ .map(() => Array(10).fill(0)),
66
+ };
67
+ },
68
+ methods: {
69
+ update(row, col, { intersectionRatio }) {
70
+ this.$set(this.values[row], col, intersectionRatio);
68
71
  },
69
- methods: {
70
- update(row, col, { intersectionRatio }) {
71
- this.$set(this.values[row], col, intersectionRatio);
72
- },
73
- disappear(row, col) {
74
- this.values[row][col] = 0;
75
- },
72
+ disappear(row, col) {
73
+ this.values[row][col] = 0;
76
74
  },
77
- template: `
75
+ },
76
+ template: `
78
77
  <div style="height: 600px; overflow-y: scroll;">
79
78
  <table>
80
79
  <tr v-for="(cols, row) in values" :key="row">
@@ -87,20 +86,21 @@ documentedStoriesOf('utilities/intersection-observer', readme)
87
86
  </table>
88
87
  </div>
89
88
  `,
90
- }))
91
- .add('lazy loaded image', () => ({
92
- components,
93
- data: commonData,
94
- methods: commonMethods,
95
- computed: {
96
- imageUrl() {
97
- // If the image is in view, return the high res one. If not return nothing, or a low res one
98
- return this.isInView
99
- ? '../../img/gitlab-summit-south-africa.jpg'
100
- : '../../img/gitlab-summit-south-africa-min.jpg';
101
- },
89
+ });
90
+
91
+ export const LazyLoadedImage = () => ({
92
+ components,
93
+ data: commonData,
94
+ methods: commonMethods,
95
+ computed: {
96
+ imageUrl() {
97
+ // If the image is in view, return the high res one. If not return nothing, or a low res one
98
+ return this.isInView
99
+ ? '../../img/gitlab-summit-south-africa.jpg'
100
+ : '../../img/gitlab-summit-south-africa-min.jpg';
102
101
  },
103
- template: `
102
+ },
103
+ template: `
104
104
  <div>
105
105
  <p>The image below will load a low-res version until it appears on the poage, then it will switch out for a higher res version.</p>
106
106
  <p>It's also set up to switch back to the low res version when it disappears off the page. This is not what you would usually do for lazily loaded images, but it helps to demonstrate the effect in this example.</p>
@@ -111,42 +111,53 @@ documentedStoriesOf('utilities/intersection-observer', readme)
111
111
  <img :src="imageUrl" style="max-width: 100%; height: auto;"/>
112
112
  </gl-intersection-observer>
113
113
  </div>
114
- `,
115
- }))
116
- .add(
117
- 'infinite scrolling',
118
- () => ({
119
- components,
120
- data: () => ({
121
- items: generateItems(),
122
- }),
123
- computed: {
124
- lastItemId() {
125
- return this.items[this.items.length - 1].id;
126
- },
127
- endOfList() {
128
- return this.lastItemId >= 1000;
129
- },
130
- },
131
- methods: {
132
- fetchMoreItems() {
133
- if (!this.endOfList) {
134
- this.items.push(...generateItems(this.lastItemId));
135
- }
136
- },
114
+ `,
115
+ });
116
+
117
+ export const InfiniteScrolling = () => ({
118
+ components,
119
+ data: () => ({
120
+ items: generateItems(),
121
+ }),
122
+ computed: {
123
+ lastItemId() {
124
+ return this.items[this.items.length - 1].id;
125
+ },
126
+ endOfList() {
127
+ return this.lastItemId >= 1000;
128
+ },
129
+ },
130
+ methods: {
131
+ fetchMoreItems() {
132
+ if (!this.endOfList) {
133
+ this.items.push(...generateItems(this.lastItemId));
134
+ }
135
+ },
136
+ },
137
+ template: `
138
+ <div>
139
+ <h2>Infinitely scrollable list</h2>
140
+ <p>This data will procedurally generate 1000 items, 20 at a time</p>
141
+ <ul>
142
+ <li v-for="item in items" :key="item.id">{{ item.title }}</li>
143
+ </ul>
144
+ <gl-intersection-observer v-if="!endOfList" @appear="fetchMoreItems">
145
+ <button @click="fetchMoreItems">Fetch more items</button>
146
+ </gl-intersection-observer>
147
+ </div>
148
+ `,
149
+ });
150
+
151
+ export default {
152
+ title: 'utilities/intersection-observer',
153
+ component: GlIntersectionObserver,
154
+ parameters: {
155
+ knobs: { disable: true },
156
+ storyshots: { disable: true },
157
+ docs: {
158
+ description: {
159
+ component: readme,
137
160
  },
138
- template: `
139
- <div>
140
- <h2>Infinitely scrollable list</h2>
141
- <p>This data will procedurally generate 1000 items, 20 at a time</p>
142
- <ul>
143
- <li v-for="item in items" :key="item.id">{{ item.title }}</li>
144
- </ul>
145
- <gl-intersection-observer v-if="!endOfList" @appear="fetchMoreItems">
146
- <button @click="fetchMoreItems">Fetch more items</button>
147
- </gl-intersection-observer>
148
- </div>
149
- `,
150
- }),
151
- { storyshots: false }
152
- );
161
+ },
162
+ },
163
+ };
@@ -13,6 +13,9 @@ const getObserver = memoize(
13
13
  export default {
14
14
  name: 'GlIntersectionObserver',
15
15
  props: {
16
+ /**
17
+ * Extra options to pass directly to the intersection observer API.
18
+ */
16
19
  options: {
17
20
  type: Object,
18
21
  required: false,
@@ -23,11 +26,20 @@ export default {
23
26
  const observer = getObserver(this.options);
24
27
 
25
28
  this.$el.$_gl_intersectionHandler = (entry) => {
29
+ /**
30
+ * Emitted when the element's visibility changes
31
+ */
26
32
  this.$emit('update', entry);
27
33
 
28
34
  if (entry.isIntersecting) {
35
+ /**
36
+ * Emitted when the element appears on the page
37
+ */
29
38
  this.$emit('appear');
30
39
  } else {
40
+ /**
41
+ * Emitted when the element disappears from the page
42
+ */
31
43
  this.$emit('disappear');
32
44
  }
33
45
  };
@@ -47,6 +59,9 @@ export default {
47
59
 
48
60
  <template>
49
61
  <div>
62
+ <!--
63
+ @slot The element you wish to observe, or a fallback if the observer doesn't work.
64
+ -->
50
65
  <slot></slot>
51
66
  </div>
52
67
  </template>
@@ -2908,18 +2908,6 @@
2908
2908
  }
2909
2909
  }
2910
2910
 
2911
- .gl-flex-sm-wrap {
2912
- @include gl-media-breakpoint-up(sm) {
2913
- flex-wrap: wrap;
2914
- }
2915
- }
2916
-
2917
- .gl-flex-sm-wrap\! {
2918
- @include gl-media-breakpoint-up(sm) {
2919
- flex-wrap: wrap !important;
2920
- }
2921
- }
2922
-
2923
2911
  .gl-flex-nowrap {
2924
2912
  flex-wrap: nowrap;
2925
2913
  }
@@ -3196,13 +3184,13 @@
3196
3184
  justify-content: flex-start !important;
3197
3185
  }
3198
3186
 
3199
- .gl-justify-content-md-start {
3187
+ .gl-md-justify-content-start {
3200
3188
  @include gl-media-breakpoint-up(md) {
3201
3189
  justify-content: flex-start;
3202
3190
  }
3203
3191
  }
3204
3192
 
3205
- .gl-justify-content-md-start\! {
3193
+ .gl-md-justify-content-start\! {
3206
3194
  @include gl-media-breakpoint-up(md) {
3207
3195
  justify-content: flex-start !important;
3208
3196
  }
@@ -3967,6 +3955,14 @@
3967
3955
  width: $gl-spacing-scale-20 !important;
3968
3956
  }
3969
3957
 
3958
+ .gl-w-28 {
3959
+ width: $gl-spacing-scale-28;
3960
+ }
3961
+
3962
+ .gl-w-28\! {
3963
+ width: $gl-spacing-scale-28 !important;
3964
+ }
3965
+
3970
3966
  .gl-w-eighth {
3971
3967
  width: 12.5%;
3972
3968
  }
@@ -4459,6 +4455,18 @@
4459
4455
  max-width: 100vw !important;
4460
4456
  }
4461
4457
 
4458
+ .gl-md-max-w-15p {
4459
+ @include gl-media-breakpoint-up(md) {
4460
+ max-width: 15%;
4461
+ }
4462
+ }
4463
+
4464
+ .gl-md-max-w-15p\! {
4465
+ @include gl-media-breakpoint-up(md) {
4466
+ max-width: 15% !important;
4467
+ }
4468
+ }
4469
+
4462
4470
  .gl-md-max-w-30p {
4463
4471
  @include gl-media-breakpoint-up(md) {
4464
4472
  max-width: 30%;
@@ -4494,6 +4502,18 @@
4494
4502
  max-width: 70% !important;
4495
4503
  }
4496
4504
  }
4505
+
4506
+ .gl-lg-max-w-80p {
4507
+ @include gl-media-breakpoint-up(lg) {
4508
+ max-width: 80%;
4509
+ }
4510
+ }
4511
+
4512
+ .gl-lg-max-w-80p\! {
4513
+ @include gl-media-breakpoint-up(lg) {
4514
+ max-width: 80% !important;
4515
+ }
4516
+ }
4497
4517
  .gl-p-0 {
4498
4518
  padding: 0;
4499
4519
  }
@@ -4796,16 +4816,6 @@
4796
4816
  .gl-pt-2\! {
4797
4817
  padding-top: $gl-spacing-scale-2 !important;
4798
4818
  }
4799
- .gl-pt-md-2 {
4800
- @include gl-media-breakpoint-up(md) {
4801
- padding-top: $gl-spacing-scale-2;
4802
- }
4803
- }
4804
- .gl-pt-md-2\! {
4805
- @include gl-media-breakpoint-up(md) {
4806
- padding-top: $gl-spacing-scale-2 !important;
4807
- }
4808
- }
4809
4819
  .gl-pt-3 {
4810
4820
  padding-top: $gl-spacing-scale-3;
4811
4821
  }
@@ -5068,12 +5078,12 @@
5068
5078
  .gl-mt-n1\! {
5069
5079
  margin-top: -$gl-spacing-scale-1 !important;
5070
5080
  }
5071
- .gl-mt-md-n2 {
5081
+ .gl-md-mt-n2 {
5072
5082
  @include gl-media-breakpoint-up(md) {
5073
5083
  margin-top: -$gl-spacing-scale-2;
5074
5084
  }
5075
5085
  }
5076
- .gl-mt-md-n2\! {
5086
+ .gl-md-mt-n2\! {
5077
5087
  @include gl-media-breakpoint-up(md) {
5078
5088
  margin-top: -$gl-spacing-scale-2 !important;
5079
5089
  }
@@ -5616,6 +5626,16 @@
5616
5626
  margin-left: #{$gl-spacing-scale-3} !important;
5617
5627
  }
5618
5628
  }
5629
+ .gl-gap-x-5 {
5630
+ > * + * {
5631
+ margin-left: #{$gl-spacing-scale-5};
5632
+ }
5633
+ }
5634
+ .gl-gap-x-5\! {
5635
+ > * + * {
5636
+ margin-left: #{$gl-spacing-scale-5} !important;
5637
+ }
5638
+ }
5619
5639
  .gl-xs-mb-3 {
5620
5640
  @include gl-media-breakpoint-down(sm) {
5621
5641
  margin-bottom: $gl-spacing-scale-3;
@@ -79,13 +79,6 @@
79
79
  }
80
80
  }
81
81
 
82
- // Deprecated, prefer `gl-sm-flex-wrap`
83
- @mixin gl-flex-sm-wrap {
84
- @include gl-media-breakpoint-up(sm) {
85
- @include gl-flex-wrap;
86
- }
87
- }
88
-
89
82
  @mixin gl-flex-nowrap {
90
83
  flex-wrap: nowrap;
91
84
  }
@@ -224,7 +217,7 @@
224
217
  justify-content: flex-start;
225
218
  }
226
219
 
227
- @mixin gl-justify-content-md-start {
220
+ @mixin gl-md-justify-content-start {
228
221
  @include gl-media-breakpoint-up(md) {
229
222
  @include gl-justify-content-start;
230
223
  }
@@ -65,6 +65,10 @@
65
65
  width: $gl-spacing-scale-20;
66
66
  }
67
67
 
68
+ @mixin gl-w-28 {
69
+ width: $gl-spacing-scale-28;
70
+ }
71
+
68
72
  @mixin gl-w-eighth {
69
73
  width: 12.5%;
70
74
  }
@@ -335,6 +339,12 @@
335
339
  * - Utilities should strictly follow $gl-spacing-scale
336
340
  */
337
341
 
342
+ @mixin gl-md-max-w-15p {
343
+ @include gl-media-breakpoint-up(md) {
344
+ max-width: 15%;
345
+ }
346
+ }
347
+
338
348
  @mixin gl-md-max-w-30p {
339
349
  @include gl-media-breakpoint-up(md) {
340
350
  max-width: 30%;
@@ -352,3 +362,9 @@
352
362
  max-width: 70%;
353
363
  }
354
364
  }
365
+
366
+ @mixin gl-lg-max-w-80p {
367
+ @include gl-media-breakpoint-up(lg) {
368
+ max-width: 80%;
369
+ }
370
+ }
@@ -202,12 +202,6 @@
202
202
  padding-top: $gl-spacing-scale-2;
203
203
  }
204
204
 
205
- @mixin gl-pt-md-2 {
206
- @include gl-media-breakpoint-up(md) {
207
- padding-top: $gl-spacing-scale-2;
208
- }
209
- }
210
-
211
205
  @mixin gl-pt-3 {
212
206
  padding-top: $gl-spacing-scale-3;
213
207
  }
@@ -386,7 +380,7 @@
386
380
  margin-top: -$gl-spacing-scale-1;
387
381
  }
388
382
 
389
- @mixin gl-mt-md-n2 {
383
+ @mixin gl-md-mt-n2 {
390
384
  @include gl-media-breakpoint-up(md) {
391
385
  margin-top: -$gl-spacing-scale-2;
392
386
  }
@@ -755,6 +749,12 @@
755
749
  }
756
750
  }
757
751
 
752
+ @mixin gl-gap-x-5 {
753
+ > * + * {
754
+ margin-left: #{$gl-spacing-scale-5};
755
+ }
756
+ }
757
+
758
758
  /**
759
759
  * Responsive margin utilities.
760
760
  *
@@ -19,6 +19,7 @@ $gl-spacing-scale-13: 12 * $grid-size;
19
19
  $gl-spacing-scale-15: 15 * $grid-size;
20
20
  $gl-spacing-scale-20: 20 * $grid-size;
21
21
  $gl-spacing-scale-26: 26 * $grid-size;
22
+ $gl-spacing-scale-28: 28 * $grid-size;
22
23
  $gl-spacing-scale-62: 62 * $grid-size;
23
24
 
24
25
  // Responsive breakpoints
@@ -1,19 +0,0 @@
1
- import ImageExample from './intersection_observer.image.example';
2
- import LastAppearedExample from './intersection_observer.last_appeared.example';
3
-
4
- var index = [{
5
- name: 'Intersection observer',
6
- items: [{
7
- id: 'intersection-observer-last-appeared',
8
- name: 'Last appeared at',
9
- description: 'Logs when the component last appeared on the screen',
10
- component: LastAppearedExample
11
- }, {
12
- id: 'intersection-observer-lazy-loaded-image',
13
- name: 'Lazy loaded image',
14
- description: "This image switches between a gif and a still image when it's on or off the screen",
15
- component: ImageExample
16
- }]
17
- }];
18
-
19
- export default index;
@@ -1,62 +0,0 @@
1
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
-
3
- var script = {
4
- data: () => ({
5
- isInView: false
6
- }),
7
- computed: {
8
- imageUrl() {
9
- // If the image is in view, return the high res one. If not return nothing, or a low res one
10
- return this.isInView ? '../../img/gitlab-summit-south-africa.jpg' : '../../img/gitlab-summit-south-africa-min.jpg';
11
- }
12
-
13
- },
14
- methods: {
15
- appear() {
16
- this.isInView = true;
17
- },
18
-
19
- disappear() {
20
- this.isInView = false;
21
- }
22
-
23
- }
24
- };
25
-
26
- /* script */
27
- const __vue_script__ = script;
28
-
29
- /* template */
30
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-intersection-observer',{on:{"appear":_vm.appear,"disappear":_vm.disappear}},[_c('img',{staticStyle:{"max-width":"100%","height":"auto"},attrs:{"src":_vm.imageUrl}})])};
31
- var __vue_staticRenderFns__ = [];
32
-
33
- /* style */
34
- const __vue_inject_styles__ = undefined;
35
- /* scoped */
36
- const __vue_scope_id__ = undefined;
37
- /* module identifier */
38
- const __vue_module_identifier__ = undefined;
39
- /* functional template */
40
- const __vue_is_functional_template__ = false;
41
- /* style inject */
42
-
43
- /* style inject SSR */
44
-
45
- /* style inject shadow dom */
46
-
47
-
48
-
49
- const __vue_component__ = __vue_normalize__(
50
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
51
- __vue_inject_styles__,
52
- __vue_script__,
53
- __vue_scope_id__,
54
- __vue_is_functional_template__,
55
- __vue_module_identifier__,
56
- false,
57
- undefined,
58
- undefined,
59
- undefined
60
- );
61
-
62
- export default __vue_component__;