Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions main.js

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions src/views/main-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ export class AgentfilesView extends ItemView {
private detailEl!: HTMLElement;
private dashboardEl!: HTMLElement;
private marketplaceEl!: HTMLElement;
private resizeHandle1!: HTMLElement;
private resizeHandle2!: HTMLElement;

private isDashboard = false;
private isMarketplace = false;
private updateRef: ReturnType<typeof this.store.on> | null = null;
private dragCleanup: (() => void) | null = null;

constructor(
leaf: WorkspaceLeaf,
Expand Down Expand Up @@ -60,7 +63,9 @@ export class AgentfilesView extends ItemView {
container.addClass("as-container");

this.sidebarEl = container.createDiv("as-panel as-panel-sidebar");
this.resizeHandle1 = this.createResizeHandle(container, this.sidebarEl, "--as-sidebar-width", 120, 400);
this.listEl = container.createDiv("as-panel as-panel-list");
this.resizeHandle2 = this.createResizeHandle(container, this.listEl, "--as-list-width", 180, 600);
this.detailEl = container.createDiv("as-panel as-panel-detail");
this.dashboardEl = container.createDiv("as-panel as-panel-dashboard as-hidden");
this.marketplaceEl = container.createDiv("as-panel as-panel-marketplace as-hidden");
Expand Down Expand Up @@ -91,6 +96,8 @@ export class AgentfilesView extends ItemView {
}

toggleDashboard(): void {
this.dragCleanup?.();
this.dragCleanup = null;
this.isDashboard = !this.isDashboard;
if (this.isMarketplace) {
this.isMarketplace = false;
Expand All @@ -99,18 +106,24 @@ export class AgentfilesView extends ItemView {
if (this.isDashboard) {
this.listEl.addClass("as-hidden");
this.detailEl.addClass("as-hidden");
this.resizeHandle1.addClass("as-hidden");
this.resizeHandle2.addClass("as-hidden");
this.dashboardEl.removeClass("as-hidden");
this.dashboardPanel.render();
} else {
this.listEl.removeClass("as-hidden");
this.detailEl.removeClass("as-hidden");
this.resizeHandle1.removeClass("as-hidden");
this.resizeHandle2.removeClass("as-hidden");
this.dashboardEl.addClass("as-hidden");
}
this.sidebarPanel.setDashboardActive(this.isDashboard);
this.sidebarPanel.render();
}

toggleMarketplace(): void {
this.dragCleanup?.();
this.dragCleanup = null;
this.isMarketplace = !this.isMarketplace;
if (this.isDashboard) {
this.isDashboard = false;
Expand All @@ -119,11 +132,15 @@ export class AgentfilesView extends ItemView {
if (this.isMarketplace) {
this.listEl.addClass("as-hidden");
this.detailEl.addClass("as-hidden");
this.resizeHandle1.addClass("as-hidden");
this.resizeHandle2.addClass("as-hidden");
this.marketplaceEl.removeClass("as-hidden");
this.marketplacePanel.render();
} else {
this.listEl.removeClass("as-hidden");
this.detailEl.removeClass("as-hidden");
this.resizeHandle1.removeClass("as-hidden");
this.resizeHandle2.removeClass("as-hidden");
this.marketplaceEl.addClass("as-hidden");
}
this.sidebarPanel.setMarketplaceActive(this.isMarketplace);
Expand All @@ -148,7 +165,44 @@ export class AgentfilesView extends ItemView {
this.detailPanel.show(item);
}

private createResizeHandle(
container: HTMLElement,
panel: HTMLElement,
cssVar: string,
min: number,
max: number
): HTMLElement {
const handle = container.createDiv("as-resize-handle");
let startX = 0;
let startWidth = 0;

const onMouseMove = (e: MouseEvent) => {
const newWidth = Math.min(max, Math.max(min, startWidth + (e.clientX - startX)));
container.style.setProperty(cssVar, `${newWidth}px`);
};

const onMouseUp = () => {
handle.removeClass("is-dragging");
document.removeEventListener("mousemove", onMouseMove);
document.removeEventListener("mouseup", onMouseUp);
this.dragCleanup = null;
};

handle.addEventListener("mousedown", (e: MouseEvent) => {
e.preventDefault();
startX = e.clientX;
startWidth = parseInt(container.style.getPropertyValue(cssVar)) || panel.offsetWidth;
handle.addClass("is-dragging");
document.addEventListener("mousemove", onMouseMove);
document.addEventListener("mouseup", onMouseUp);
this.dragCleanup = onMouseUp;
});

return handle;
}

onClose(): void {
this.dragCleanup?.();
if (this.updateRef) {
this.store.offref(this.updateRef);
}
Expand Down
18 changes: 17 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
}

.as-container {
--as-sidebar-width: 200px;
--as-list-width: 280px;
display: grid;
grid-template-columns: 200px 280px 1fr;
grid-template-columns: var(--as-sidebar-width) 6px var(--as-list-width) 6px 1fr;
height: 100%;
overflow: hidden;
}
Expand All @@ -38,6 +40,20 @@
overflow: hidden;
}

/* Resize handles */
.as-resize-handle {
width: 6px;
background: transparent;
cursor: col-resize;
transition: background 0.15s;
z-index: 1;
}

.as-resize-handle:hover,
.as-resize-handle.is-dragging {
background: var(--interactive-accent);
}

/* Sidebar */
.as-sidebar-section {
margin-bottom: 8px;
Expand Down