Skip to content

Commit

Permalink
feat: add layout reverse api #162 (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
gimmyhehe authored Oct 16, 2023
1 parent 9ca27a1 commit c1cd77a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import SplitPane from './SplitPane.vue'
import Output from './output/Output.vue'
import { Store, ReplStore, SFCOptions } from './store'
import { provide, ref, toRef } from 'vue'
import { provide, ref, toRef, computed } from 'vue'
import type { EditorComponentType } from './editor/types'
import EditorContainer from './editor/EditorContainer.vue'
Expand All @@ -17,6 +17,7 @@ export interface Props {
clearConsole?: boolean
sfcOptions?: SFCOptions
layout?: 'horizontal' | 'vertical'
layoutReverse?: boolean
ssr?: boolean
previewOptions?: {
headHTML?: string
Expand All @@ -37,6 +38,7 @@ const props = withDefaults(defineProps<Props>(), {
showImportMap: true,
showTsConfig: true,
clearConsole: true,
layoutReverse: false,
ssr: false,
previewOptions: () => ({
headHTML: '',
Expand Down Expand Up @@ -73,6 +75,9 @@ sfcOptions.script.fs = {
store.init()
const editorSlotName = computed(() => props.layoutReverse ? 'right' : 'left')
const outputSlotName = computed(() => props.layoutReverse ? 'left' : 'right')
provide('store', store)
provide('autoresize', props.autoResize)
provide('import-map', toRef(props, 'showImportMap'))
Expand All @@ -93,10 +98,10 @@ defineExpose({ reload })
<template>
<div class="vue-repl">
<SplitPane :layout="layout">
<template #left>
<template #[editorSlotName]>
<EditorContainer :editorComponent="editor" />
</template>
<template #right>
<template #[outputSlotName]>
<Output
ref="outputRef"
:editorComponent="editor"
Expand Down

0 comments on commit c1cd77a

Please sign in to comment.