docs_vue2/components/OneRepl.vue

103 lines
1.6 KiB
Vue
Raw Normal View History

2021-11-20 13:22:48 +08:00
<template>
<article class="repl">
<header class="header">
<h1>{{ t('liveEdit') }}</h1>
<section class="actions">
<veui-button
ui="strong text"
@click="handleClose"
>
{{ t('exit') }}
</veui-button>
</section>
</header>
<one-live
class="editor"
:code="code"
/>
</article>
</template>
<script>
2021-11-21 01:52:20 +08:00
import { Button, Loading } from 'veui'
2021-11-20 13:22:48 +08:00
import i18n from 'veui/mixins/i18n'
export default {
name: 'one-repl',
components: {
'veui-button': Button,
2021-11-21 01:52:20 +08:00
'one-live': () => ({
component: import('./OneLive'),
loading: {
inheritAttrs: false,
render (h) {
return h(Loading, {
props: {
loading: true,
ui: 'strong'
},
class: 'loading'
})
}
}
})
2021-11-20 13:22:48 +08:00
},
mixins: [i18n],
props: {
code: {
type: String,
default: ''
}
},
methods: {
handleClose () {
this.$emit('close')
}
}
}
</script>
<style lang="stylus" scoped>
.repl
display flex
flex-direction column
.header
display flex
align-items center
flex none
height 48px
padding 0 24px
box-shadow 0 0 4px #0006
position relative
z-index 1
2021-11-20 13:22:48 +08:00
h1
flex none
margin 0
font-size 16px
.actions
display flex
justify-content flex-end
flex 1 1 auto
2021-11-21 01:52:20 +08:00
.editor:not(.loading)
position relative
2021-11-20 13:22:48 +08:00
flex 1 1 auto
height calc(100vh - 48px)
& >>> .live-preview
padding 24px 36px
& >>> .VueLive-error
display none
2021-11-21 01:52:20 +08:00
.loading
position absolute
top 40vh
left 50%
transform translateX(-50%)
font-size 40px
2021-11-20 13:22:48 +08:00
</style>