2019-09-17 19:24:39 +08:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="n-code-box"
|
|
|
|
:class="{
|
|
|
|
[`n-${synthesizedTheme}-theme`]: synthesizedTheme
|
|
|
|
}"
|
2019-09-20 00:22:55 +08:00
|
|
|
n-default-theme-background-color-hint="transparent"
|
|
|
|
n-light-theme-background-color-hint="white"
|
2019-09-17 19:24:39 +08:00
|
|
|
>
|
|
|
|
<div class="n-code-box__title">
|
|
|
|
<slot name="title" />
|
2019-09-21 17:03:37 +08:00
|
|
|
<n-tooltip
|
|
|
|
:placement="'top'"
|
|
|
|
:arrow="true"
|
|
|
|
>
|
|
|
|
<template v-slot:activator>
|
|
|
|
<n-button
|
|
|
|
size="tiny"
|
|
|
|
ghost
|
|
|
|
icon="md-code"
|
|
|
|
circle
|
|
|
|
@click="toggleCodeDisplay"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
Show Code
|
|
|
|
</n-tooltip>
|
2019-09-17 19:24:39 +08:00
|
|
|
</div>
|
|
|
|
<div class="n-code-box__content">
|
|
|
|
<slot name="content" />
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="n-code-box__view"
|
|
|
|
>
|
|
|
|
<slot name="demo" />
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="showCode"
|
|
|
|
class="n-code-box__code"
|
|
|
|
>
|
|
|
|
<slot name="code" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import withapp from '../packages/mixins/withapp'
|
|
|
|
import themeable from '../packages/mixins/themeable'
|
2019-09-20 00:22:55 +08:00
|
|
|
import 'highlight.js/styles/atom-one-dark-reasonable.css'
|
|
|
|
import 'highlight.js/styles/atom-one-light.css'
|
2019-09-17 19:24:39 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [withapp, themeable],
|
|
|
|
data () {
|
|
|
|
return {
|
2019-09-20 00:22:55 +08:00
|
|
|
showCode: false,
|
|
|
|
lightThemeCSSRef: null,
|
|
|
|
defaultThemeCSSRef: null
|
2019-09-17 19:24:39 +08:00
|
|
|
}
|
|
|
|
},
|
2019-09-20 00:22:55 +08:00
|
|
|
watch: {
|
|
|
|
synthesizedTheme (value) {
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
// document.querySelector('')
|
|
|
|
},
|
2019-09-17 19:24:39 +08:00
|
|
|
methods: {
|
2019-09-20 00:22:55 +08:00
|
|
|
switchHighlightStyle () {
|
|
|
|
|
|
|
|
},
|
|
|
|
toggleCodeDisplay () {
|
2019-09-17 19:24:39 +08:00
|
|
|
this.showCode = !this.showCode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|