Retained source and preview
Import the source CSS once. Supply a bounded parent and keep the slot components mounted; the panel handles clipping, visibility and resize mechanics.
<script setup lang="ts">
import { ref } from 'vue';
import { ResizablePanel, type ResizablePanelResizeEvent } from '@beehexa/vue-components';
import '@beehexa/vue-components/css';
const ratio = ref(0.62);
const previewVisible = ref(true);
const sourceHost = ref<HTMLElement>();
const previewHost = ref<HTMLElement>();
const paneSizes = ref<ResizablePanelResizeEvent>();
function resized(event: ResizablePanelResizeEvent) {
paneSizes.value = event;
}
</script>
<template>
<div style="height: 32rem; min-height: 0; min-width: 0">
<ResizablePanel
v-model:ratio="ratio"
:second-visible="previewVisible"
:min="0"
separator-label="Resize source and preview"
@resize="resized"
>
<template #first><div ref="sourceHost" style="height: 100%; min-height: 0" /></template>
<template #second><div ref="previewHost" style="height: 100%; min-height: 0" /></template>
</ResizablePanel>
</div>
</template>
Attach retained editor/canvas instances to the two hosts. React to paneSizes
with the renderer’s native layout API; preserve its existing model and zoom. Do
not replace a host or remount a model merely to react to a width/height change.
With min=0, Home/End can really collapse a pane while retaining its instance.
Enter or divider double-click restores the initial 0.62 ratio within live bounds.
Responsive direction and translated naming
The application already owns breakpoint and locale state. Derive the direction from that existing state; do not key the panel or its children on it.
<ResizablePanel
v-model:ratio="ratio"
:direction="isMobile ? 'vertical' : 'horizontal'"
:separator-label="t('resizeSourceAndPreview')"
:min="100"
resizer-size="90%"
@resize="onPaneResize"
>
<template #first><SourceEditor /></template>
<template #second><WorkflowPreview /></template>
</ResizablePanel>
isMobile, t, retained editor/preview components and the native relayout callback
belong to the consumer. The library imposes neither an app breakpoint nor a
translation singleton. Theme changes use source CSS variables live.
Both examples reserve a physical source-token gutter between the panes. In the responsive example, verify three centered vertical dots before the axis change and three centered horizontal dots afterward. The handle and hitbox sizes do not change to fake centering; root-font scaling scales dot diameter and spacing together, with equal margins around the complete ink cluster.
Fixed/fullscreen retained panes
For a first-only fullscreen surface, use min=0 and equal ratio bounds of 1;
for a second-only surface, use equal bounds of 0. This hides/disables the
separator without moving or unmounting slot children. Restoring ordinary bounds
restores the requested split. If the requirement is simply a temporarily hidden
second pane, use secondVisible instead. The component adds no fullscreen or
modal chrome; preserve native parent fullscreen/overlay behavior.