fix(ui): refine mobile sidebar layout (#1100)
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
type="button"
|
||||
class="menu-item-link"
|
||||
[pTooltip]="currentItem.label"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
(click)="runAction($event)"
|
||||
>
|
||||
@@ -33,7 +33,7 @@
|
||||
[attr.aria-current]="isRouteActive() ? 'page' : null"
|
||||
[routerLink]="currentItem.routerLink"
|
||||
[pTooltip]="currentItem.label"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
tabindex="0"
|
||||
>
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 991px) {
|
||||
@media (width <= 767px) {
|
||||
.expand-icon-button {
|
||||
opacity: 1;
|
||||
width: 2rem;
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('AppMenuSectionComponent', () => {
|
||||
|
||||
const layoutService = {
|
||||
sidebarCollapsed: signal(false),
|
||||
isDesktop: signal(true),
|
||||
sidebarExpandedState: signal<Readonly<Record<string, boolean>>>({}),
|
||||
isSidebarExpanded: vi.fn((key: string, defaultExpanded: boolean) => {
|
||||
const value = layoutService.sidebarExpandedState()[key];
|
||||
@@ -37,6 +38,8 @@ describe('AppMenuSectionComponent', () => {
|
||||
component = fixture.componentInstance;
|
||||
|
||||
layoutService.sidebarExpandedState.set({});
|
||||
layoutService.sidebarCollapsed.set(false);
|
||||
layoutService.isDesktop.set(true);
|
||||
layoutService.isSidebarExpanded.mockClear();
|
||||
layoutService.setSidebarExpanded.mockClear();
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ export class AppMenuSectionComponent {
|
||||
}
|
||||
|
||||
get submenuVisible(): boolean {
|
||||
return this.layoutService.sidebarCollapsed() || this.expanded;
|
||||
return (this.layoutService.isDesktop() && this.layoutService.sidebarCollapsed()) || this.expanded;
|
||||
}
|
||||
|
||||
toggleExpand(): void {
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
type="button"
|
||||
class="sidebar-action-link sidebar-search-button"
|
||||
[pTooltip]="t('search')"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
(click)="openSearch()"
|
||||
>
|
||||
@@ -133,7 +133,7 @@
|
||||
[attr.aria-label]="t('profile')"
|
||||
aria-haspopup="menu"
|
||||
[pTooltip]="user.name || user.username"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
(click)="openSidebarOverlay($event, userMenu, 'below')"
|
||||
>
|
||||
@@ -152,7 +152,7 @@
|
||||
[attr.aria-label]="layoutService.sidebarCollapsed() ? t('expandSidebar') : t('collapseSidebar')"
|
||||
[attr.aria-expanded]="!layoutService.sidebarCollapsed()"
|
||||
[pTooltip]="layoutService.sidebarCollapsed() ? t('expandSidebar') : t('collapseSidebar')"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
(click)="layoutService.toggleSidebarCollapsed()"
|
||||
>
|
||||
@@ -195,7 +195,7 @@
|
||||
[attr.aria-label]="layoutService.sidebarCollapsed() ? t('expandSidebar') : t('collapseSidebar')"
|
||||
[attr.aria-expanded]="!layoutService.sidebarCollapsed()"
|
||||
[pTooltip]="layoutService.sidebarCollapsed() ? t('expandSidebar') : t('collapseSidebar')"
|
||||
[tooltipDisabled]="!layoutService.sidebarCollapsed()"
|
||||
[tooltipDisabled]="!layoutService.desktopSidebarCollapsed()"
|
||||
tooltipPosition="right"
|
||||
(click)="layoutService.toggleSidebarCollapsed()"
|
||||
>
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (width <= 991px) {
|
||||
@media (width <= 767px) {
|
||||
.sidebar-header {
|
||||
align-items: flex-start;
|
||||
margin-bottom: var(--space-3);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { signal, WritableSignal } from '@angular/core';
|
||||
import { computed, signal, WritableSignal } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
@@ -52,9 +52,12 @@ describe('AppMenuComponent', () => {
|
||||
let component: AppMenuComponent;
|
||||
let commandPaletteService: { open: ReturnType<typeof vi.fn> };
|
||||
let currentUser: WritableSignal<TestUser | null>;
|
||||
const sidebarCollapsed = signal(false);
|
||||
const isDesktop = signal(true);
|
||||
const layoutService = {
|
||||
sidebarCollapsed: signal(false),
|
||||
isDesktop: signal(true),
|
||||
sidebarCollapsed,
|
||||
isDesktop,
|
||||
desktopSidebarCollapsed: computed(() => isDesktop() && sidebarCollapsed()),
|
||||
librarySort: signal({ field: 'name', order: 'desc' }),
|
||||
shelfSort: signal({ field: 'name', order: 'asc' }),
|
||||
magicShelfSort: signal({ field: 'name', order: 'asc' }),
|
||||
|
||||
@@ -215,7 +215,7 @@ export class AppMenuComponent {
|
||||
|
||||
// `above` collapses to `below` when the sidebar is narrow, because the
|
||||
// anchored left offset assumes an expanded footer row.
|
||||
const anchorAbove = anchor.placement === 'above' && !this.layoutService.sidebarCollapsed();
|
||||
const anchorAbove = anchor.placement === 'above' && !this.layoutService.desktopSidebarCollapsed();
|
||||
if (anchorAbove) {
|
||||
const bottom = Math.max(window.innerHeight - rect.top + 8, 8);
|
||||
panel.style.setProperty('--sidebar-popover-bottom', `${bottom}px`);
|
||||
|
||||
Reference in New Issue
Block a user