feat: panel-toggle-button

This commit is contained in:
2026-02-17 11:41:35 +01:00
parent 70bc0b1b09
commit 4ac29a6528
3 changed files with 67 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ describe('WindowTitleBar', () => {
beforeEach(() => {
useAppStore.setState({
sidebarVisible: true,
panelVisible: false,
});
});
@@ -37,6 +38,42 @@ describe('WindowTitleBar', () => {
expect(iconPane).toHaveAttribute('data-shape', 'left-half');
});
it('renders a right-side panel toggle button and toggles panel visibility', () => {
render(<WindowTitleBar />);
const toggleButton = screen.getByLabelText('Toggle Panel');
expect(toggleButton).toBeInTheDocument();
expect(toggleButton).toHaveAttribute('title', 'Show Panel (Ctrl+J)');
fireEvent.click(toggleButton);
expect(useAppStore.getState().panelVisible).toBe(true);
expect(toggleButton).toHaveAttribute('title', 'Hide Panel (Ctrl+J)');
});
it('uses a VS Code-like panel toggle icon shape', () => {
render(<WindowTitleBar />);
const toggleButton = screen.getByLabelText('Toggle Panel');
const iconFrame = toggleButton.querySelector('.window-titlebar-panel-icon');
const iconPane = toggleButton.querySelector('.window-titlebar-panel-pane');
expect(iconFrame).not.toBeNull();
expect(iconPane).not.toBeNull();
expect(iconFrame).toHaveAttribute('data-shape', 'frame-square');
expect(iconPane).toHaveAttribute('data-shape', 'bottom-half');
});
it('places panel toggle to the right of sidebar toggle', () => {
render(<WindowTitleBar />);
const actionButtons = Array.from(document.querySelectorAll('.window-titlebar-actions .window-titlebar-action-button'));
expect(actionButtons).toHaveLength(2);
expect(actionButtons[0]).toHaveAttribute('aria-label', 'Toggle Sidebar');
expect(actionButtons[1]).toHaveAttribute('aria-label', 'Toggle Panel');
});
it('updates overlay inset CSS variables when window controls geometry changes', () => {
const geometryListeners = new Set<EventListener>();
let rect = {