Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: output toggle button #279

Merged
merged 9 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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