logigate/app/components/editor/App.vue

60 lines
2.4 KiB
Vue
Raw Normal View History

<script setup lang="ts">
const ed = useEditor()
const link = computed(() => {
const l = ed.linking.value
const end = l?.queue[l.at]
return l && end ? { n: l.at + 1, total: l.queue.length, label: end.label, dir: end.dir } : null
})
onMounted(() => {
const stop = ed.startLoop()
onBeforeUnmount(stop)
void ed.startAccount()
try {
if (!localStorage.getItem('logigate:help-seen')) ed.showHelp.value = true
} catch {}
})
</script>
<template>
<div class="app">
<EditorToolbar />
<div class="workspace" :class="{ 'no-left': !ed.sidebars.left, 'no-right': !ed.sidebars.right }">
<EditorPalette v-if="ed.sidebars.left" />
<EditorRail v-else side="left" />
<main class="stage">
<EditorCanvas />
</main>
<EditorInspector v-if="ed.sidebars.right" />
<EditorRail v-else side="right" />
</div>
<Transition name="fade">
<div v-if="ed.notice.value" class="toast" :class="ed.notice.value.kind">{{ ed.notice.value.text }}</div>
</Transition>
<div v-if="ed.cabling.value" class="placing-hint">
<strong>Cable with {{ ed.cabling.value.wires.length }} wires:</strong>
{{ ed.cabling.value.start ? 'click where it ends (its split).' : 'click where it starts (its bundle).' }} <kbd>Esc</kbd> cancels.
</div>
<div v-else-if="ed.placing.value" class="placing-hint">
Click on the canvas to place. <kbd>Shift</kbd> places several, <kbd>Esc</kbd> stops.
</div>
<div v-else-if="link" class="placing-hint">
<template v-if="link.total > 1">
<strong>{{ link.n }} of {{ link.total }}<template v-if="link.label">: {{ link.label }}</template></strong> ·
</template>
Click the pin {{ link.dir === 'out' ? 'it goes to' : 'it comes from' }}, or a part to use its next free pin. <kbd>Esc</kbd> stops.
</div>
<EditorTruthTableDialog v-if="ed.dialog.value === 'table'" />
<EditorPublishDialog v-if="ed.dialog.value === 'publish'" />
<EditorHelp v-if="ed.showHelp.value" />
<EditorProjectsDialog v-if="ed.dialog.value === 'projects'" />
<EditorShareDialog v-if="ed.dialog.value === 'share'" />
<EditorAccountDialog v-if="ed.dialog.value === 'account'" />
<EditorVersionsDialog v-if="ed.dialog.value === 'versions'" />
<EditorSettingsDialog v-if="ed.dialog.value === 'settings'" />
<EditorSearchDialog v-if="ed.dialog.value === 'search'" />
<EditorFaceDialog v-if="ed.dialog.value === 'face'" />
</div>
</template>