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 4 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
10 changes: 10 additions & 0 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export interface Props {
showErrorText?: string
monacoOptions?: monaco.editor.IStandaloneEditorConstructionOptions
}
splitPaneOptions?: {
CodeTogglerButtonText?: string
OutputTogglerButtonText?: string
}
isEmbedMode?: boolean
lecepin marked this conversation as resolved.
Show resolved Hide resolved
}

const props = withDefaults(defineProps<Props>(), {
Expand All @@ -57,6 +62,11 @@ const props = withDefaults(defineProps<Props>(), {
layout: 'horizontal',
previewOptions: () => ({}),
editorOptions: () => ({}),
splitPaneOptions: () => ({
CodeTogglerButtonText: '< Code',
OutputTogglerButtonText: 'Output >',
}),
isEmbedMode: false
lecepin marked this conversation as resolved.
Show resolved Hide resolved
})

if (!props.editor) {
Expand Down
13 changes: 10 additions & 3 deletions src/SplitPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const container = ref()
const previewRef = inject(injectKeyPreviewRef)!

// mobile only
const { store } = inject(injectKeyProps)!
const { store, splitPaneOptions, isEmbedMode } = inject(injectKeyProps)!
const showOutput = computed(() => store.value.showOutput)

const state = reactive({
Expand Down Expand Up @@ -68,6 +68,7 @@ function changeViewSize() {
dragging: state.dragging,
'show-output': showOutput,
vertical: isVertical,
'is-embed-mode': isEmbedMode,
}"
@mousemove="dragMove"
@mouseup="dragEnd"
Expand All @@ -90,8 +91,12 @@ function changeViewSize() {
<slot name="right" />
</div>

<button class="toggler" @click="showOutput = !showOutput">
{{ showOutput ? '< Code' : 'Output >' }}
<button class="toggler" @click="store.showOutput = !showOutput">
{{
showOutput
? splitPaneOptions?.CodeTogglerButtonText
: splitPaneOptions?.OutputTogglerButtonText
}}
</button>
</div>
</template>
Expand Down Expand Up @@ -215,4 +220,6 @@ function changeViewSize() {
pointer-events: none;
}
}


lecepin marked this conversation as resolved.
Show resolved Hide resolved
</style>
5 changes: 5 additions & 0 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const App = {
},
// showCompileOutput: false,
// showImportMap: false
// splitPaneOptions: {
// CodeTogglerButtonText: '< 代码',
// OutputTogglerButtonText: '输出 >',
// },
// isEmbedMode: true,
editorOptions: {
monacoOptions: {
// wordWrap: 'on',
Expand Down