@gitlab/ui 32.64.1 → 32.67.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 (21) hide show
  1. package/CHANGELOG.md +28 -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 +1 -1
  8. package/src/components/utilities/intersection_observer/intersection_observer.documentation.js +0 -23
  9. package/src/components/utilities/intersection_observer/intersection_observer.stories.js +91 -80
  10. package/src/components/utilities/intersection_observer/intersection_observer.vue +15 -0
  11. package/src/scss/utilities.scss +52 -2
  12. package/src/scss/utility-mixins/flex.scss +1 -1
  13. package/src/scss/utility-mixins/opacity.scss +8 -0
  14. package/src/scss/utility-mixins/sizing.scss +12 -0
  15. package/src/scss/utility-mixins/spacing.scss +6 -0
  16. package/dist/components/utilities/intersection_observer/examples/index.js +0 -19
  17. package/dist/components/utilities/intersection_observer/examples/intersection_observer.image.example.js +0 -62
  18. package/dist/components/utilities/intersection_observer/examples/intersection_observer.last_appeared.example.js +0 -83
  19. package/src/components/utilities/intersection_observer/examples/index.js +0 -23
  20. package/src/components/utilities/intersection_observer/examples/intersection_observer.image.example.vue +0 -29
  21. 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.64.1",
3
+ "version": "32.67.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -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>
@@ -3145,13 +3145,13 @@
3145
3145
  }
3146
3146
 
3147
3147
  .gl-sm-justify-content-end {
3148
- @include gl-media-breakpoint-up(md) {
3148
+ @include gl-media-breakpoint-up(sm) {
3149
3149
  justify-content: flex-end;
3150
3150
  }
3151
3151
  }
3152
3152
 
3153
3153
  .gl-sm-justify-content-end\! {
3154
- @include gl-media-breakpoint-up(md) {
3154
+ @include gl-media-breakpoint-up(sm) {
3155
3155
  justify-content: flex-end !important;
3156
3156
  }
3157
3157
  }
@@ -3356,6 +3356,22 @@
3356
3356
  opacity: 0.5 !important
3357
3357
  }
3358
3358
 
3359
+ .gl-opacity-6 {
3360
+ opacity: 0.6
3361
+ }
3362
+
3363
+ .gl-opacity-6\! {
3364
+ opacity: 0.6 !important
3365
+ }
3366
+
3367
+ .gl-opacity-7 {
3368
+ opacity: 0.7
3369
+ }
3370
+
3371
+ .gl-opacity-7\! {
3372
+ opacity: 0.7 !important
3373
+ }
3374
+
3359
3375
  .gl-opacity-10 {
3360
3376
  opacity: 1
3361
3377
  }
@@ -4443,6 +4459,18 @@
4443
4459
  max-width: 100vw !important;
4444
4460
  }
4445
4461
 
4462
+ .gl-md-max-w-15p {
4463
+ @include gl-media-breakpoint-up(md) {
4464
+ max-width: 15%;
4465
+ }
4466
+ }
4467
+
4468
+ .gl-md-max-w-15p\! {
4469
+ @include gl-media-breakpoint-up(md) {
4470
+ max-width: 15% !important;
4471
+ }
4472
+ }
4473
+
4446
4474
  .gl-md-max-w-30p {
4447
4475
  @include gl-media-breakpoint-up(md) {
4448
4476
  max-width: 30%;
@@ -4478,6 +4506,18 @@
4478
4506
  max-width: 70% !important;
4479
4507
  }
4480
4508
  }
4509
+
4510
+ .gl-lg-max-w-80p {
4511
+ @include gl-media-breakpoint-up(lg) {
4512
+ max-width: 80%;
4513
+ }
4514
+ }
4515
+
4516
+ .gl-lg-max-w-80p\! {
4517
+ @include gl-media-breakpoint-up(lg) {
4518
+ max-width: 80% !important;
4519
+ }
4520
+ }
4481
4521
  .gl-p-0 {
4482
4522
  padding: 0;
4483
4523
  }
@@ -5600,6 +5640,16 @@
5600
5640
  margin-left: #{$gl-spacing-scale-3} !important;
5601
5641
  }
5602
5642
  }
5643
+ .gl-gap-x-5 {
5644
+ > * + * {
5645
+ margin-left: #{$gl-spacing-scale-5};
5646
+ }
5647
+ }
5648
+ .gl-gap-x-5\! {
5649
+ > * + * {
5650
+ margin-left: #{$gl-spacing-scale-5} !important;
5651
+ }
5652
+ }
5603
5653
  .gl-xs-mb-3 {
5604
5654
  @include gl-media-breakpoint-down(sm) {
5605
5655
  margin-bottom: $gl-spacing-scale-3;
@@ -199,7 +199,7 @@
199
199
  }
200
200
 
201
201
  @mixin gl-sm-justify-content-end {
202
- @include gl-media-breakpoint-up(md) {
202
+ @include gl-media-breakpoint-up(sm) {
203
203
  @include gl-justify-content-end;
204
204
  }
205
205
  }
@@ -19,6 +19,14 @@
19
19
  opacity: 0.5;
20
20
  }
21
21
 
22
+ @mixin gl-opacity-6 {
23
+ opacity: 0.6;
24
+ }
25
+
26
+ @mixin gl-opacity-7 {
27
+ opacity: 0.7;
28
+ }
29
+
22
30
  @mixin gl-opacity-10 {
23
31
  opacity: 1;
24
32
  }
@@ -335,6 +335,12 @@
335
335
  * - Utilities should strictly follow $gl-spacing-scale
336
336
  */
337
337
 
338
+ @mixin gl-md-max-w-15p {
339
+ @include gl-media-breakpoint-up(md) {
340
+ max-width: 15%;
341
+ }
342
+ }
343
+
338
344
  @mixin gl-md-max-w-30p {
339
345
  @include gl-media-breakpoint-up(md) {
340
346
  max-width: 30%;
@@ -352,3 +358,9 @@
352
358
  max-width: 70%;
353
359
  }
354
360
  }
361
+
362
+ @mixin gl-lg-max-w-80p {
363
+ @include gl-media-breakpoint-up(lg) {
364
+ max-width: 80%;
365
+ }
366
+ }
@@ -755,6 +755,12 @@
755
755
  }
756
756
  }
757
757
 
758
+ @mixin gl-gap-x-5 {
759
+ > * + * {
760
+ margin-left: #{$gl-spacing-scale-5};
761
+ }
762
+ }
763
+
758
764
  /**
759
765
  * Responsive margin utilities.
760
766
  *
@@ -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__;
@@ -1,83 +0,0 @@
1
- import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
-
3
- var script = {
4
- data: () => ({
5
- appearedAt: null,
6
- now: null,
7
- interval: null
8
- }),
9
- computed: {
10
- secondsSinceAppearance() {
11
- if (!this.appearedAt) {
12
- return 0;
13
- }
14
-
15
- return Math.floor((this.now - this.appearedAt) / 1000);
16
- }
17
-
18
- },
19
-
20
- destroyed() {
21
- this.clearInterval();
22
- },
23
-
24
- methods: {
25
- appear() {
26
- this.clearInterval();
27
- this.interval = setInterval(this.tick, 1000);
28
- this.tick();
29
- this.appearedAt = this.now;
30
- },
31
-
32
- disappear() {
33
- this.clearInterval();
34
- },
35
-
36
- clearInterval() {
37
- clearInterval(this.interval);
38
- },
39
-
40
- tick() {
41
- this.now = new Date().getTime();
42
- }
43
-
44
- }
45
- };
46
-
47
- /* script */
48
- const __vue_script__ = script;
49
-
50
- /* template */
51
- 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('span',[_vm._v("Last appeared "+_vm._s(_vm.secondsSinceAppearance)+" seconds ago")])])};
52
- var __vue_staticRenderFns__ = [];
53
-
54
- /* style */
55
- const __vue_inject_styles__ = undefined;
56
- /* scoped */
57
- const __vue_scope_id__ = undefined;
58
- /* module identifier */
59
- const __vue_module_identifier__ = undefined;
60
- /* functional template */
61
- const __vue_is_functional_template__ = false;
62
- /* style inject */
63
-
64
- /* style inject SSR */
65
-
66
- /* style inject shadow dom */
67
-
68
-
69
-
70
- const __vue_component__ = __vue_normalize__(
71
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
72
- __vue_inject_styles__,
73
- __vue_script__,
74
- __vue_scope_id__,
75
- __vue_is_functional_template__,
76
- __vue_module_identifier__,
77
- false,
78
- undefined,
79
- undefined,
80
- undefined
81
- );
82
-
83
- export default __vue_component__;
@@ -1,23 +0,0 @@
1
- import ImageExample from './intersection_observer.image.example.vue';
2
- import LastAppearedExample from './intersection_observer.last_appeared.example.vue';
3
-
4
- export default [
5
- {
6
- name: 'Intersection observer',
7
- items: [
8
- {
9
- id: 'intersection-observer-last-appeared',
10
- name: 'Last appeared at',
11
- description: 'Logs when the component last appeared on the screen',
12
- component: LastAppearedExample,
13
- },
14
- {
15
- id: 'intersection-observer-lazy-loaded-image',
16
- name: 'Lazy loaded image',
17
- description:
18
- "This image switches between a gif and a still image when it's on or off the screen",
19
- component: ImageExample,
20
- },
21
- ],
22
- },
23
- ];
@@ -1,29 +0,0 @@
1
- <script>
2
- export default {
3
- data: () => ({
4
- isInView: false,
5
- }),
6
- computed: {
7
- imageUrl() {
8
- // If the image is in view, return the high res one. If not return nothing, or a low res one
9
- return this.isInView
10
- ? '../../img/gitlab-summit-south-africa.jpg'
11
- : '../../img/gitlab-summit-south-africa-min.jpg';
12
- },
13
- },
14
- methods: {
15
- appear() {
16
- this.isInView = true;
17
- },
18
- disappear() {
19
- this.isInView = false;
20
- },
21
- },
22
- };
23
- </script>
24
-
25
- <template>
26
- <gl-intersection-observer @appear="appear" @disappear="disappear">
27
- <img :src="imageUrl" style="max-width: 100%; height: auto" />
28
- </gl-intersection-observer>
29
- </template>