2018-07-31 11:50:34 -04:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'CodeBlock',
|
|
|
|
props: {
|
|
|
|
code: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-05-14 08:08:21 -04:00
|
|
|
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-07-31 11:50:34 -04:00
|
|
|
},
|
2021-09-01 14:08:49 -04:00
|
|
|
userColorScheme: window.gon.user_color_scheme,
|
2018-07-31 11:50:34 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2021-09-01 14:08:49 -04:00
|
|
|
<pre
|
|
|
|
class="code-block rounded code"
|
|
|
|
:class="$options.userColorScheme"
|
|
|
|
:style="styleObject"
|
|
|
|
><code class="d-block">{{ code }}</code></pre>
|
2018-07-31 11:50:34 -04:00
|
|
|
</template>
|