Skip to content

Commit

Permalink
fix: output toggle button (#279)
Browse files Browse the repository at this point in the history
Co-authored-by: 三咲智子 Kevin Deng <[email protected]>
  • Loading branch information
lecepin and sxzz committed Sep 16, 2024
1 parent ec393cf commit 93051f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface Props {
autoSaveText?: string | false
monacoOptions?: monaco.editor.IStandaloneEditorConstructionOptions
}
splitPaneOptions?: {
codeTogglerText?: string
outputTogglerText?: string
}
}
const autoSave = defineModel<boolean>({ default: true })
Expand All @@ -57,6 +61,7 @@ const props = withDefaults(defineProps<Props>(), {
layout: 'horizontal',
previewOptions: () => ({}),
editorOptions: () => ({}),
splitPaneOptions: () => ({}),
})
if (!props.editor) {
Expand Down
13 changes: 8 additions & 5 deletions src/SplitPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const containerRef = useTemplateRef('container')
const previewRef = inject(injectKeyPreviewRef)!
// mobile only
const { store } = inject(injectKeyProps)!
const showOutput = computed(() => store.value.showOutput)
const { store, splitPaneOptions } = inject(injectKeyProps)!
const state = reactive({
dragging: false,
Expand Down Expand Up @@ -66,7 +65,7 @@ function changeViewSize() {
class="split-pane"
:class="{
dragging: state.dragging,
'show-output': showOutput,
'show-output': store.showOutput,
vertical: isVertical,
}"
@mousemove="dragMove"
Expand All @@ -90,8 +89,12 @@ function changeViewSize() {
<slot name="right" />
</div>

<button class="toggler" @click="showOutput = !showOutput">
{{ showOutput ? '< Code' : 'Output >' }}
<button class="toggler" @click="store.showOutput = !store.showOutput">
{{
store.showOutput
? splitPaneOptions?.codeTogglerText || '< Code'
: splitPaneOptions?.outputTogglerText || 'Output >'
}}
</button>
</div>
</template>
Expand Down

0 comments on commit 93051f3

Please sign in to comment.