debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/code_block.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
764 B
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
export default {
name: 'CodeBlock',
props: {
code: {
type: String,
2022-10-11 01:57:18 +05:30
required: false,
default: '',
2018-11-18 11:00:15 +05:30
},
2020-05-24 23:13:21 +05:30
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;
},
2018-11-18 11:00:15 +05:30
},
2021-11-11 11:23:49 +05:30
userColorScheme: window.gon.user_color_scheme,
2018-11-18 11:00:15 +05:30
};
</script>
<template>
2021-11-11 11:23:49 +05:30
<pre
class="code-block rounded code"
:class="$options.userColorScheme"
:style="styleObject"
2022-10-11 01:57:18 +05:30
><slot><code class="d-block">{{ code }}</code></slot></pre>
2018-11-18 11:00:15 +05:30
</template>