logigate/app/components/editor/Rail.vue

35 lines
1.2 KiB
Vue

<script setup lang="ts">
// A hidden side panel shrinks to this strip; its buttons bring it back.
const props = defineProps<{ side: 'left' | 'right' }>()
const ed = useEditor()
const TABS = [
{ id: 'selection', label: 'Selection', icon: 'lucide:mouse-pointer-2' },
{ id: 'circuit', label: 'Circuit', icon: 'lucide:cpu' },
{ id: 'pins', label: 'Pins', icon: 'lucide:list' },
{ id: 'test', label: 'Test', icon: 'lucide:table' },
] as const
function openTab(id: (typeof TABS)[number]['id']) {
ed.rightTab.value = id
ed.toggleSidebar('right', true)
}
</script>
<template>
<aside class="rail" :class="props.side">
<button
class="rail-btn"
:title="props.side === 'left' ? 'Show parts and challenges ([)' : 'Show the side panel (])'"
@click="ed.toggleSidebar(props.side, true)"
>
<Icon :name="props.side === 'left' ? 'lucide:panel-left-open' : 'lucide:panel-right-open'" class="size-4" />
</button>
<template v-if="props.side === 'right'">
<button v-for="t in TABS" :key="t.id" class="rail-btn" :title="t.label" @click="openTab(t.id)">
<Icon :name="t.icon" class="size-4" />
</button>
</template>
</aside>
</template>