@gitlab/ui 98.4.0 → 98.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "98.4.0",
3
+ "version": "98.5.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "eslint": "8.57.1",
159
159
  "eslint-import-resolver-jest": "3.0.2",
160
160
  "eslint-plugin-cypress": "3.6.0",
161
- "eslint-plugin-storybook": "0.9.0",
161
+ "eslint-plugin-storybook": "0.10.1",
162
162
  "gitlab-api-async-iterator": "^1.3.1",
163
163
  "glob": "10.3.3",
164
164
  "globby": "^11.1.0",
@@ -413,7 +413,7 @@ export default {
413
413
  class="gl-pagination-item"
414
414
  :aria-label="prevPageAriaLabel"
415
415
  :href="prevPageHref"
416
- @click="handlePrevious($event, value - 1)"
416
+ @click="!prevPageIsDisabled ? handlePrevious($event, value - 1) : null"
417
417
  >
418
418
  <!--
419
419
  @slot Content for the "previous" button. Overrides the "prevText" prop.
@@ -479,7 +479,7 @@ export default {
479
479
  class="gl-pagination-item"
480
480
  :aria-label="nextPageAriaLabel"
481
481
  :href="nextPageHref"
482
- @click="handleNext($event, value + 1)"
482
+ @click="!nextPageIsDisabled ? handleNext($event, value + 1) : null"
483
483
  >
484
484
  <!--
485
485
  @slot Content for the "next" button. Overrides the "nextText" prop.
@@ -0,0 +1,3 @@
1
+ export const DUO_CODE_SCRIM_TOP_CLASS = 'scrim-top';
2
+ export const DUO_CODE_SCRIM_BOTTOM_CLASS = 'scrim-bottom';
3
+ export const DUO_CODE_SCRIM_OFFSET = 16;
@@ -1,3 +1,6 @@
1
+ $duo-code-scrim-bottom-gradient: linear-gradient(to bottom, rgba($gray-10, 0), $gray-10);
2
+ $duo-code-scrim-top-gradient: linear-gradient(to top, rgba($gray-10, 0), $gray-10);
3
+
1
4
  .duo-chat-message {
2
5
  max-width: 90%;
3
6
  position: relative;
@@ -7,8 +10,34 @@
7
10
  }
8
11
 
9
12
  pre {
10
- @apply gl-text-inherit;
11
- padding: $gl-spacing-scale-3 $gl-spacing-scale-4;
13
+ box-shadow: none !important;
14
+ @apply gl-border gl-max-h-[60vh] gl-px-4 gl-py-3 gl-text-inherit;
15
+
16
+ &::before,
17
+ &::after {
18
+ content: '';
19
+ left: 1px;
20
+ width: calc(100% - 2px);
21
+ position: absolute;
22
+ @apply gl-pointer-events-none;
23
+ @apply gl-h-7;
24
+ }
25
+
26
+ &.scrim-top {
27
+ &::before {
28
+ background: $duo-code-scrim-top-gradient;
29
+ top: 1px;
30
+ @apply gl-rounded-t-base;
31
+ }
32
+ }
33
+
34
+ &.scrim-bottom {
35
+ &::after {
36
+ background: $duo-code-scrim-bottom-gradient;
37
+ bottom: 1px;
38
+ @apply gl-rounded-b-base;
39
+ }
40
+ }
12
41
  }
13
42
 
14
43
  pre code {
@@ -1,4 +1,5 @@
1
1
  <script>
2
+ import throttle from 'lodash/throttle';
2
3
  import GlIcon from '../../../../../base/icon/icon.vue';
3
4
  import GlLoadingIcon from '../../../../../base/loading_icon/loading_icon.vue';
4
5
  import { GlTooltipDirective } from '../../../../../../directives/tooltip';
@@ -15,6 +16,11 @@ import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
15
16
  import { CopyCodeElement } from './copy_code_element';
16
17
  import { InsertCodeSnippetElement } from './insert_code_snippet_element';
17
18
  import { concatUntilEmpty } from './utils';
19
+ import {
20
+ DUO_CODE_SCRIM_BOTTOM_CLASS,
21
+ DUO_CODE_SCRIM_OFFSET,
22
+ DUO_CODE_SCRIM_TOP_CLASS,
23
+ } from './constants';
18
24
 
19
25
  export const i18n = {
20
26
  MODAL: {
@@ -216,6 +222,7 @@ export default {
216
222
  if (!this.isChunk && this.$refs.content) {
217
223
  this.$nextTick(this.renderGFM(this.$refs.content));
218
224
  }
225
+ this.detectScrollableCodeBlocks();
219
226
  },
220
227
  logEvent(e) {
221
228
  this.$emit('track-feedback', {
@@ -240,6 +247,30 @@ export default {
240
247
  contextItem,
241
248
  });
242
249
  },
250
+ detectScrollableCodeBlocks() {
251
+ const codeBlocks = document.querySelectorAll('.duo-chat-message pre');
252
+ codeBlocks.forEach((e) => {
253
+ if (e.scrollHeight > e.offsetHeight) {
254
+ e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
255
+ e.addEventListener(
256
+ 'scroll',
257
+ throttle(() => this.toggleScrolling(e), 200)
258
+ );
259
+ }
260
+ });
261
+ },
262
+ toggleScrolling(e) {
263
+ if (e.scrollHeight - e.scrollTop <= e.offsetHeight + DUO_CODE_SCRIM_OFFSET) {
264
+ e.classList.remove(DUO_CODE_SCRIM_BOTTOM_CLASS);
265
+ } else {
266
+ e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
267
+ }
268
+ if (e.scrollTop > DUO_CODE_SCRIM_OFFSET) {
269
+ e.classList.add(DUO_CODE_SCRIM_TOP_CLASS);
270
+ } else {
271
+ e.classList.remove(DUO_CODE_SCRIM_TOP_CLASS);
272
+ }
273
+ },
243
274
  },
244
275
  };
245
276
  </script>