refactor: extract member panels and constrain action menus

This commit is contained in:
illusia committed 2026-10-01 18:19:24 +08:00
1 parent a416e36bd1
commit 83b2430d18
10 files changed
+397 -196

No files matched your search

@@ -0,0 +1,25 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { placeMemberMenu, placeMemberSubmenu } from "./member-menu-placement.js";
test("the complete menu stays inside a short desktop window", () => {
assert.deepEqual(placeMemberMenu({ x: 167, y: 309 }, { width: 188, height: 271 }, { width: 1280, height: 568 }), { x: 167, y: 285 });
});
test("a submenu near the bottom moves up without moving off the right edge", () => {
assert.deepEqual(placeMemberSubmenu({ left: 180, right: 340, top: 507 }, { width: 220, height: 84 }, { width: 1280, height: 568 }), { x: 346, y: 472 });
});
test("a submenu opens to the left when the right side has no room", () => {
assert.deepEqual(placeMemberSubmenu({ left: 1020, right: 1220, top: 200 }, { width: 220, height: 180 }, { width: 1280, height: 720 }), { x: 794, y: 200 });
});
test("oversized measured content remains reachable from the viewport inset", () => {
assert.deepEqual(placeMemberMenu({ x: -40, y: 500 }, { width: 900, height: 600 }, { width: 800, height: 400 }), { x: 12, y: 12 });
});
test("placement uses rendered dimensions including CSS zoom", () => {
const result = placeMemberMenu({ x: 1500, y: 800 }, { width: 282, height: 406.5 }, { width: 1600, height: 900 });
assert.deepEqual(result, { x: 1306, y: 481.5 });
assert.equal(result.y + 406.5, 888);
});
+18
View File
@@ -0,0 +1,18 @@
interface Size { width: number; height: number }
interface Point { x: number; y: number }
interface Anchor { left: number; right: number; top: number }
// All inputs and results are rendered viewport pixels. CSS zoom conversion
// belongs to the component, after placement has been constrained.
export function placeMemberMenu(point: Point, size: Size, viewport: Size, inset = 12): Point {
return {
x: Math.max(inset, Math.min(point.x, viewport.width - size.width - inset)),
y: Math.max(inset, Math.min(point.y, viewport.height - size.height - inset)),
};
}
export function placeMemberSubmenu(anchor: Anchor, size: Size, viewport: Size, gap = 6): Point {
const right = anchor.right + gap;
const x = right + size.width <= viewport.width - 12 ? right : anchor.left - gap - size.width;
return placeMemberMenu({ x, y: anchor.top }, size, viewport);
}
+1 -1
View File
@@ -193,7 +193,7 @@ test("the activity artwork layer floats above room content without intercepting
assert.match(css, /\.app-shell \.workspace-content\s*\{\s*position: relative;\s*isolation: isolate;/);
assert.match(css, /\.voice-activity-artwork\s*\{\s*position: absolute;\s*z-index: 2;\s*inset: -26px 0 -48px;[^}]*pointer-events: none;/);
assert.match(css, /\.voice-activity-artwork\s*\{[^}]*transform: perspective\(1100px\) rotateY\(-2\.5deg\) translateZ\(22px\)/);
assert.match(css, /\.app-shell \.member-panel::before\s*\{\s*content: "";\s*position: absolute;\s*z-index: 1;\s*left: -28px;\s*bottom: 18px;\s*width: min\(430px, calc\(100vw - 24px\)\);\s*aspect-ratio: 3 \/ 2;[^}]*perspective\(1100px\) rotateY\(-8deg\)/);
assert.match(css, /:deep\(\.app-shell \.member-panel::before\)\s*\{\s*content: "";\s*position: absolute;\s*z-index: 1;\s*left: -28px;\s*bottom: 18px;\s*width: min\(430px, calc\(100vw - 24px\)\);\s*aspect-ratio: 3 \/ 2;[^}]*perspective\(1100px\) rotateY\(-8deg\)/);
assert.match(css, /:deep\(\.app-shell \.chat-empty\[data-ws-state="messages-empty"\]\)\s*\{[^}]*min-height: 210px;\s*padding: 126px 12px 10px;/);
assert.match(css, /:deep\(\.app-shell \.chat-panel \.section-heading\),[\s\S]*?:deep\(\.app-shell \.chat-panel \.message-composer\)\s*\{\s*position: relative;\s*z-index: 3;/);
assert.match(css, /\.screen-share-player\s*\{[^}]*background: var\(--surface-1\)/);