All files / app/assets/javascripts/vue_shared/components code_block.vue

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 38  41x                               108x 108x 108x         108x                          
<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>