Welcome to mirror list, hosted at ThFree Co, Russian Federation.

code_block.vue « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4a69845d3a42979aa17ccab85ff4ed4a84f51ed7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<script>
export default {
  name: 'CodeBlock',
  props: {
    code: {
      type: String,
      required: false,
      default: '',
    },
    maxHeight: {
      type: String,
      required: false,
      default: 'initial',
    },
  },
  computed: {
    styleObject() {
      const { maxHeight } = this;
      const isScrollable = maxHeight !== 'initial';
      const scrollableStyles = {
        maxHeight,
        overflowY: 'auto',
      };

      return isScrollable ? scrollableStyles : null;
    },
  },
  userColorScheme: window.gon.user_color_scheme,
};
</script>
<template>
  <pre
    class="code-block rounded code"
    :class="$options.userColorScheme"
    :style="styleObject"
  ><slot><code class="d-block">{{ code }}</code></slot></pre>
</template>