M1.5: main window layout and project tree against mocked engine events
Left Project tool window (hide/show stripe, pointer and keyboard resize), editor area placeholder and status bar. Project tree with lazy project.children listings, WAI-ARIA keyboard navigation, Lucide icons, dimmed ignored/excluded entries and refresh on TreeChanged. Empty state runs project.openDialog. Pinia store fed only by engine events and command results; events come through a local onEngineEvent adapter until the desktop bridge (M1.4) lands. Lucide via @lucide/vue (the renamed lucide-vue-next, ISC). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
faadb05eb3
commit
003b7970e6
16 changed files with 1541 additions and 32 deletions
231
ui/src/components/layout/ToolWindow.vue
Normal file
231
ui/src/components/layout/ToolWindow.vue
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* A tool window docked on the left side of the main window: a header with
|
||||
* the title and a hide button, the content slot, and a splitter on the right
|
||||
* edge to resize it. When hidden, a narrow stripe with a button brings it
|
||||
* back.
|
||||
*
|
||||
* The splitter is dragged with the pointer or moved with Left/Right (Shift
|
||||
* for larger steps) when focused. Width and visibility are view state of this
|
||||
* component, emitted through `v-model:width` and `v-model:open`.
|
||||
*/
|
||||
import { PanelLeftClose, PanelLeftOpen } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
/** Props of the tool window. */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** Title shown in the header and as the accessible name. */
|
||||
title: string;
|
||||
/** Width in CSS pixels. */
|
||||
width?: number;
|
||||
/** Smallest width the splitter allows. */
|
||||
minWidth?: number;
|
||||
/** Largest width the splitter allows. */
|
||||
maxWidth?: number;
|
||||
/** Whether the window is shown (true) or collapsed to its stripe. */
|
||||
open?: boolean;
|
||||
}>(),
|
||||
{ width: 260, minWidth: 140, maxWidth: 640, open: true },
|
||||
);
|
||||
|
||||
/** Events of the tool window. */
|
||||
const emit = defineEmits<{
|
||||
/** New width after a resize. */
|
||||
"update:width": [width: number];
|
||||
/** New visibility after hide or show. */
|
||||
"update:open": [open: boolean];
|
||||
}>();
|
||||
|
||||
/** Inline style carrying the current width. */
|
||||
const style = computed(() => ({ width: `${String(props.width)}px` }));
|
||||
|
||||
/**
|
||||
* Emits a width clamped to the allowed range.
|
||||
*
|
||||
* @param width - the wanted width.
|
||||
*/
|
||||
function setWidth(width: number): void {
|
||||
emit("update:width", Math.round(Math.min(props.maxWidth, Math.max(props.minWidth, width))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a pointer drag on the splitter.
|
||||
*
|
||||
* @param event - the pointer-down event.
|
||||
*/
|
||||
function onSplitterDown(event: PointerEvent): void {
|
||||
const target = event.currentTarget;
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
const startX = event.clientX;
|
||||
const startWidth = props.width;
|
||||
target.setPointerCapture(event.pointerId);
|
||||
const move = (e: PointerEvent): void => {
|
||||
setWidth(startWidth + e.clientX - startX);
|
||||
};
|
||||
const up = (e: PointerEvent): void => {
|
||||
target.releasePointerCapture(e.pointerId);
|
||||
target.removeEventListener("pointermove", move);
|
||||
target.removeEventListener("pointerup", up);
|
||||
};
|
||||
target.addEventListener("pointermove", move);
|
||||
target.addEventListener("pointerup", up);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes with the keyboard when the splitter has focus.
|
||||
*
|
||||
* @param event - the key event.
|
||||
*/
|
||||
function onSplitterKey(event: KeyboardEvent): void {
|
||||
const step = event.shiftKey ? 48 : 12;
|
||||
if (event.key === "ArrowLeft") {
|
||||
setWidth(props.width - step);
|
||||
} else if (event.key === "ArrowRight") {
|
||||
setWidth(props.width + step);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
v-if="open"
|
||||
class="tool-window"
|
||||
:style="style"
|
||||
:aria-label="title"
|
||||
data-test="tool-window"
|
||||
>
|
||||
<header class="tool-window__header">
|
||||
<span class="tool-window__title">{{ title }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="tool-window__button"
|
||||
:title="`Hide ${title}`"
|
||||
:aria-label="`Hide ${title}`"
|
||||
data-test="tool-window-hide"
|
||||
@click="emit('update:open', false)"
|
||||
>
|
||||
<PanelLeftClose :size="16" />
|
||||
</button>
|
||||
</header>
|
||||
<div class="tool-window__body">
|
||||
<slot />
|
||||
</div>
|
||||
<div
|
||||
class="tool-window__splitter"
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
tabindex="0"
|
||||
:aria-valuenow="width"
|
||||
:aria-valuemin="minWidth"
|
||||
:aria-valuemax="maxWidth"
|
||||
:aria-label="`Resize ${title}`"
|
||||
data-test="tool-window-splitter"
|
||||
@pointerdown="onSplitterDown"
|
||||
@keydown="onSplitterKey"
|
||||
/>
|
||||
</aside>
|
||||
<div
|
||||
v-else
|
||||
class="tool-window-stripe"
|
||||
data-test="tool-window-stripe"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="tool-window__button"
|
||||
:title="`Show ${title}`"
|
||||
:aria-label="`Show ${title}`"
|
||||
data-test="tool-window-show"
|
||||
@click="emit('update:open', true)"
|
||||
>
|
||||
<PanelLeftOpen :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tool-window {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: none;
|
||||
min-height: 0;
|
||||
background: var(--lt-bg);
|
||||
border-right: 1px solid var(--lt-border);
|
||||
}
|
||||
|
||||
.tool-window__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: var(--lt-header-height, 28px);
|
||||
padding: 0 var(--lt-space-s, 4px) 0 var(--lt-space-m, 8px);
|
||||
border-bottom: 1px solid var(--lt-border);
|
||||
}
|
||||
|
||||
.tool-window__title {
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tool-window__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tool-window__button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--lt-space-xs, 2px);
|
||||
color: var(--lt-fg-muted);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--lt-radius, 4px);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tool-window__button:hover {
|
||||
color: var(--lt-fg);
|
||||
background: color-mix(in srgb, var(--lt-fg) 8%, transparent);
|
||||
}
|
||||
|
||||
.tool-window__button:focus-visible {
|
||||
outline: 2px solid var(--lt-accent);
|
||||
}
|
||||
|
||||
.tool-window__splitter {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -3px;
|
||||
bottom: 0;
|
||||
width: 6px;
|
||||
cursor: col-resize;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.tool-window__splitter:hover,
|
||||
.tool-window__splitter:focus-visible {
|
||||
outline: none;
|
||||
background: color-mix(in srgb, var(--lt-accent) 50%, transparent);
|
||||
}
|
||||
|
||||
.tool-window-stripe {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
padding: var(--lt-space-s, 4px) var(--lt-space-xs, 2px);
|
||||
background: var(--lt-bg);
|
||||
border-right: 1px solid var(--lt-border);
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue