feat(admin): build shared admin shell
Sidebar (Dashboard/Catalog group/Products/Categories/Orders/Transactions/ Reviews/Reports/Content/Media/Marketplace Builder/Users/Settings/ Monitoring/Analytics + Documentation/Help/Logout), sticky topbar (breadcrumbs, page title/description, search, notifications, tenant selector and quick-publish placeholders, current user), reserved right-rail slot, scrollable content area. Desktop 280px sidebar, tablet icon rail, mobile drawer with focus management and Escape-to-close. Nav items without a built page (Reviews, Reports, Settings, Docs, Help) render disabled with a coming-soon badge instead of dead links; Content and Marketplace Builder route to the existing project-editor pages (static-pages / general) rather than duplicating them. All 15 /backoffice/** routes now render through AdminLayoutComponent; the public storefront header/back-button/footer no longer render on admin routes (app.ts/app.html gate on a new isAdminRoute signal). Added the adminShell i18n namespace (ru/en/hy) for every new shell string so this doesn't add to the existing untranslated-admin-UI gap tracked in KNOWN-ISSUES.md. Colors/type sizes follow DESIGN.md tokens; the two rgba() modal-scrim values are a documented, intentional exception (neutral overlay, not a themed token). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
160
src/app/features/admin/shell/admin-layout.component.html
Normal file
160
src/app/features/admin/shell/admin-layout.component.html
Normal file
@@ -0,0 +1,160 @@
|
||||
<a class="admin-layout__skip-link" href="#admin-content">{{ 'adminShell.skipToContent' | translate }}</a>
|
||||
|
||||
<div class="admin-layout" [class.admin-layout--drawer-open]="mobileDrawerOpen()">
|
||||
@if (mobileDrawerOpen()) {
|
||||
<div class="admin-layout__backdrop" (click)="closeMobileDrawer()"></div>
|
||||
}
|
||||
|
||||
<nav
|
||||
#drawer
|
||||
class="admin-layout__sidebar"
|
||||
[attr.aria-label]="'adminShell.nav.dashboard' | translate"
|
||||
>
|
||||
<a class="admin-layout__brand" [routerLink]="['/', currentLang(), 'backoffice', 'dashboard']">
|
||||
<span class="admin-layout__brand-mark" aria-hidden="true">M</span>
|
||||
<span class="admin-layout__brand-name">Marketplace</span>
|
||||
</a>
|
||||
|
||||
<ul class="admin-layout__nav-list">
|
||||
@for (entry of navPrimary; track (entry.type === 'group' ? entry.labelKey : entry.id)) {
|
||||
@if (entry.type === 'group') {
|
||||
<li class="admin-layout__nav-group" role="presentation">{{ entry.labelKey | translate }}</li>
|
||||
} @else if (entry.type === 'link' && !entry.comingSoon) {
|
||||
<li>
|
||||
<a
|
||||
class="admin-layout__nav-link"
|
||||
[routerLink]="adminLinkFor(entry)"
|
||||
routerLinkActive="admin-layout__nav-link--active"
|
||||
[routerLinkActiveOptions]="{ exact: false }"
|
||||
>
|
||||
<span class="pi {{ entry.icon }}" aria-hidden="true"></span>
|
||||
<span class="admin-layout__nav-label">{{ entry.labelKey | translate }}</span>
|
||||
</a>
|
||||
</li>
|
||||
} @else if (entry.type === 'link' && entry.comingSoon) {
|
||||
<li>
|
||||
<button type="button" class="admin-layout__nav-link admin-layout__nav-link--disabled" disabled>
|
||||
<span class="pi {{ entry.icon }}" aria-hidden="true"></span>
|
||||
<span class="admin-layout__nav-label">{{ entry.labelKey | translate }}</span>
|
||||
<span class="admin-layout__soon-badge">{{ 'adminShell.nav.comingSoonBadge' | translate }}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
|
||||
<ul class="admin-layout__nav-list admin-layout__nav-list--bottom">
|
||||
@for (entry of navBottom; track $index) {
|
||||
@if (entry.type === 'link' && entry.comingSoon) {
|
||||
<li>
|
||||
<button type="button" class="admin-layout__nav-link admin-layout__nav-link--disabled" disabled>
|
||||
<span class="pi {{ entry.icon }}" aria-hidden="true"></span>
|
||||
<span class="admin-layout__nav-label">{{ entry.labelKey | translate }}</span>
|
||||
<span class="admin-layout__soon-badge">{{ 'adminShell.nav.comingSoonBadge' | translate }}</span>
|
||||
</button>
|
||||
</li>
|
||||
} @else if (entry.type === 'action') {
|
||||
<li>
|
||||
<button type="button" class="admin-layout__nav-link" (click)="logout()">
|
||||
<span class="pi {{ entry.icon }}" aria-hidden="true"></span>
|
||||
<span class="admin-layout__nav-label">{{ entry.labelKey | translate }}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<header class="admin-layout__topbar">
|
||||
<button
|
||||
#menuToggle
|
||||
type="button"
|
||||
class="admin-layout__menu-toggle"
|
||||
[attr.aria-expanded]="mobileDrawerOpen()"
|
||||
[attr.aria-label]="(mobileDrawerOpen() ? 'adminShell.closeSidebar' : 'adminShell.openSidebar') | translate"
|
||||
(click)="toggleMobileDrawer()"
|
||||
>
|
||||
<span class="pi pi-bars" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
||||
<div class="admin-layout__heading">
|
||||
<nav class="admin-layout__breadcrumb" [attr.aria-label]="'adminShell.breadcrumbHome' | translate">
|
||||
<ol>
|
||||
<li>
|
||||
<a [routerLink]="['/', currentLang(), 'backoffice', 'dashboard']">{{ 'adminShell.breadcrumbHome' | translate }}</a>
|
||||
</li>
|
||||
@for (crumb of breadcrumb(); track crumb.labelKey; let last = $last) {
|
||||
<li>
|
||||
<span class="admin-layout__breadcrumb-sep" aria-hidden="true">/</span>
|
||||
@if (!last) {
|
||||
<a [routerLink]="breadcrumbLink(crumb)">{{ crumb.labelKey | translate }}</a>
|
||||
} @else {
|
||||
<span aria-current="page">{{ crumb.labelKey | translate }}</span>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
</nav>
|
||||
<h1 class="admin-layout__title">{{ pageTitleKey() | translate }}</h1>
|
||||
<p class="admin-layout__description">{{ pageDescriptionKey() | translate }}</p>
|
||||
</div>
|
||||
|
||||
<div class="admin-layout__topbar-actions">
|
||||
<label class="admin-layout__search">
|
||||
<span class="visually-hidden">{{ 'adminShell.topbar.searchLabel' | translate }}</span>
|
||||
<span class="pi pi-search admin-layout__search-icon" aria-hidden="true"></span>
|
||||
<input type="search" [placeholder]="'adminShell.topbar.searchPlaceholder' | translate" />
|
||||
</label>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="admin-layout__icon-button"
|
||||
disabled
|
||||
[title]="'adminShell.topbar.quickPublishComingSoon' | translate"
|
||||
>
|
||||
<span class="pi pi-upload" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">{{ 'adminShell.topbar.quickPublish' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="admin-layout__icon-button"
|
||||
disabled
|
||||
[title]="'adminShell.topbar.tenantSelectorComingSoon' | translate"
|
||||
>
|
||||
<span class="pi pi-building" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">{{ 'adminShell.topbar.tenantSelector' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<div class="admin-layout__notifications">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-layout__icon-button"
|
||||
aria-haspopup="true"
|
||||
[attr.aria-expanded]="notificationsOpen()"
|
||||
[attr.aria-label]="'adminShell.topbar.notifications' | translate"
|
||||
(click)="toggleNotifications()"
|
||||
>
|
||||
<span class="pi pi-bell" aria-hidden="true"></span>
|
||||
</button>
|
||||
@if (notificationsOpen()) {
|
||||
<div class="admin-layout__notifications-panel" role="menu">
|
||||
<p>{{ 'adminShell.topbar.notificationsEmpty' | translate }}</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="admin-layout__account" [attr.aria-label]="'adminShell.topbar.account' | translate">
|
||||
<span class="admin-layout__avatar" aria-hidden="true">{{ initials() }}</span>
|
||||
<span class="admin-layout__account-name">{{ displayName() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="admin-content" class="admin-layout__content" tabindex="-1">
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
|
||||
<!-- Reserved for a future contextual inspector panel; intentionally empty. -->
|
||||
<aside class="admin-layout__inspector" aria-hidden="true"></aside>
|
||||
</div>
|
||||
500
src/app/features/admin/shell/admin-layout.component.scss
Normal file
500
src/app/features/admin/shell/admin-layout.component.scss
Normal file
@@ -0,0 +1,500 @@
|
||||
:host {
|
||||
--admin-sidebar-width: 280px;
|
||||
--admin-sidebar-width-collapsed: 72px;
|
||||
--admin-topbar-height: 72px;
|
||||
display: block;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.admin-layout__skip-link {
|
||||
position: absolute;
|
||||
top: -100px;
|
||||
left: var(--space-md);
|
||||
z-index: 1000;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
padding: var(--space-sm) var(--space-md);
|
||||
border-radius: var(--radius-sm);
|
||||
box-shadow: var(--shadow-md);
|
||||
|
||||
&:focus {
|
||||
top: var(--space-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout {
|
||||
display: grid;
|
||||
grid-template-columns: var(--admin-sidebar-width) 1fr;
|
||||
grid-template-rows: var(--admin-topbar-height) 1fr;
|
||||
grid-template-areas:
|
||||
'sidebar topbar'
|
||||
'sidebar content';
|
||||
height: 100vh;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.admin-layout__backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
/* Neutral modal/drawer scrim - intentionally not a themed token (Elevation
|
||||
section covers floating surfaces, not the dimming layer behind them);
|
||||
stays black-alpha regardless of tenant theme like the rest of the app's
|
||||
overlay scrims. */
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
z-index: 30;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------- Sidebar ---------- */
|
||||
|
||||
.admin-layout__sidebar {
|
||||
grid-area: sidebar;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
overflow-y: auto;
|
||||
background: var(--bg-primary);
|
||||
border-right: 1px solid var(--border-color);
|
||||
z-index: 40;
|
||||
}
|
||||
|
||||
.admin-layout__brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
padding: var(--space-md);
|
||||
text-decoration: none;
|
||||
color: var(--text-primary);
|
||||
font-weight: 700;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.admin-layout__brand-mark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--gradient-primary);
|
||||
color: #fff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.admin-layout__nav-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: var(--space-sm);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.admin-layout__nav-list--bottom {
|
||||
margin-top: auto;
|
||||
border-top: 1px solid var(--border-color);
|
||||
padding-top: var(--space-sm);
|
||||
}
|
||||
|
||||
.admin-layout__nav-group {
|
||||
padding: var(--space-md) var(--space-sm) var(--space-xs);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.admin-layout__nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
width: 100%;
|
||||
padding: var(--space-sm) var(--space-md);
|
||||
border: none;
|
||||
background: none;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
|
||||
.pi {
|
||||
font-size: 1rem;
|
||||
width: 1.2rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--primary-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
color: var(--text-light);
|
||||
cursor: not-allowed;
|
||||
|
||||
&:hover {
|
||||
background: none;
|
||||
color: var(--text-light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__soon-badge {
|
||||
margin-left: auto;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-lg);
|
||||
background: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--primary-color);
|
||||
border: 1px solid color-mix(in srgb, var(--primary-color) 20%, transparent);
|
||||
}
|
||||
|
||||
/* ---------- Topbar ---------- */
|
||||
|
||||
.admin-layout__topbar {
|
||||
grid-area: topbar;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-md);
|
||||
padding: 0 var(--space-lg);
|
||||
background: var(--bg-primary);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.admin-layout__menu-toggle {
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__heading {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
padding: var(--space-sm) 0;
|
||||
}
|
||||
|
||||
.admin-layout__breadcrumb {
|
||||
ol {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
list-style: none;
|
||||
margin: 0 0 2px;
|
||||
padding: 0;
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--text-light);
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary-color);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
[aria-current='page'] {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__breadcrumb-sep {
|
||||
margin: 0 var(--space-xs);
|
||||
}
|
||||
|
||||
.admin-layout__title {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.admin-layout__description {
|
||||
margin: 2px 0 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.admin-layout__topbar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.admin-layout__search {
|
||||
position: relative;
|
||||
display: none;
|
||||
|
||||
input {
|
||||
width: 220px;
|
||||
padding: 10px 12px 10px 32px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-field, var(--radius-sm));
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__search-icon {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--text-light);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.admin-layout__icon-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--primary-color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__notifications {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.admin-layout__notifications-panel {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: calc(100% + 8px);
|
||||
width: 240px;
|
||||
padding: var(--space-md);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-lg);
|
||||
font-size: 1rem;
|
||||
color: var(--text-secondary);
|
||||
z-index: 25;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__account {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-xs);
|
||||
padding-left: var(--space-sm);
|
||||
border-left: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.admin-layout__avatar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background: var(--primary-color);
|
||||
color: #fff;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.admin-layout__account-name {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
max-width: 140px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------- Content / inspector ---------- */
|
||||
|
||||
.admin-layout__content {
|
||||
grid-area: content;
|
||||
overflow-y: auto;
|
||||
padding: var(--space-lg);
|
||||
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__inspector {
|
||||
display: none;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
/* ---------- Responsive ---------- */
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.admin-layout__search {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-layout__account-name {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tablet: icon-only rail */
|
||||
@media (max-width: 1023px) and (min-width: 768px) {
|
||||
/* Doubled selector: deliberate specificity bump so this reliably wins over
|
||||
the base .admin-layout grid-template-columns declaration regardless of
|
||||
the two rules' relative order after the build's CSS bundling pass. */
|
||||
.admin-layout.admin-layout {
|
||||
grid-template-columns: var(--admin-sidebar-width-collapsed) 1fr;
|
||||
}
|
||||
|
||||
.admin-layout__brand-name,
|
||||
.admin-layout__nav-label,
|
||||
.admin-layout__soon-badge {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-layout__brand {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.admin-layout__nav-link {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile: drawer */
|
||||
@media (max-width: 767px) {
|
||||
.admin-layout.admin-layout {
|
||||
grid-template-columns: 0 1fr;
|
||||
}
|
||||
|
||||
.admin-layout__menu-toggle {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.admin-layout__sidebar {
|
||||
position: fixed;
|
||||
inset: 0 auto 0 0;
|
||||
width: min(var(--admin-sidebar-width), 84vw);
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.2s ease;
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.admin-layout--drawer-open {
|
||||
.admin-layout__sidebar {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.admin-layout__backdrop {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout__title,
|
||||
.admin-layout__description {
|
||||
max-width: 55vw;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.admin-layout__sidebar {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.admin-layout__backdrop {
|
||||
/* Same neutral-scrim exception as the light-mode rule above, just darker. */
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
}
|
||||
142
src/app/features/admin/shell/admin-layout.component.ts
Normal file
142
src/app/features/admin/shell/admin-layout.component.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, HostListener, computed, inject, signal, viewChild } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { TranslatePipe } from '../../../i18n/translate.pipe';
|
||||
import { TranslateService } from '../../../i18n/translate.service';
|
||||
import { LanguageService } from '../../../services/language.service';
|
||||
import { AdminAuthService } from '../../../core/admin-auth/admin-auth.service';
|
||||
import { ADMIN_NAV_BOTTOM, ADMIN_NAV_PRIMARY, AdminBreadcrumbEntry, AdminNavEntry } from './admin-nav.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-layout',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterOutlet, RouterLink, RouterLinkActive, TranslatePipe],
|
||||
templateUrl: './admin-layout.component.html',
|
||||
styleUrl: './admin-layout.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AdminLayoutComponent {
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly translate = inject(TranslateService);
|
||||
private readonly languageService = inject(LanguageService);
|
||||
private readonly adminAuth = inject(AdminAuthService);
|
||||
|
||||
private readonly drawerEl = viewChild<ElementRef<HTMLElement>>('drawer');
|
||||
private readonly menuToggleEl = viewChild<ElementRef<HTMLElement>>('menuToggle');
|
||||
|
||||
readonly navPrimary: AdminNavEntry[] = ADMIN_NAV_PRIMARY;
|
||||
readonly navBottom: AdminNavEntry[] = ADMIN_NAV_BOTTOM;
|
||||
|
||||
readonly mobileDrawerOpen = signal(false);
|
||||
readonly notificationsOpen = signal(false);
|
||||
|
||||
readonly currentLang = this.languageService.currentLanguage;
|
||||
readonly displayName = this.adminAuth.displayName;
|
||||
|
||||
readonly initials = computed(() => {
|
||||
const name = this.displayName();
|
||||
if (!name) {
|
||||
return '?';
|
||||
}
|
||||
return name
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.slice(0, 2)
|
||||
.map(part => part[0]?.toUpperCase())
|
||||
.join('');
|
||||
});
|
||||
|
||||
private readonly breadcrumbSignal = signal<AdminBreadcrumbEntry[]>([]);
|
||||
private readonly titleKeySignal = signal<string>('adminShell.pages.dashboard.title');
|
||||
private readonly descriptionKeySignal = signal<string>('adminShell.pages.dashboard.description');
|
||||
|
||||
readonly breadcrumb = this.breadcrumbSignal.asReadonly();
|
||||
readonly pageTitleKey = this.titleKeySignal.asReadonly();
|
||||
readonly pageDescriptionKey = this.descriptionKeySignal.asReadonly();
|
||||
|
||||
constructor() {
|
||||
this.readRouteData();
|
||||
this.router.events
|
||||
.pipe(
|
||||
filter(event => event instanceof NavigationEnd),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.readRouteData();
|
||||
this.closeMobileDrawer();
|
||||
this.notificationsOpen.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
onEscape(): void {
|
||||
if (this.mobileDrawerOpen()) {
|
||||
this.closeMobileDrawer();
|
||||
return;
|
||||
}
|
||||
if (this.notificationsOpen()) {
|
||||
this.notificationsOpen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
toggleMobileDrawer(): void {
|
||||
this.mobileDrawerOpen.update(open => !open);
|
||||
if (this.mobileDrawerOpen()) {
|
||||
queueMicrotask(() => {
|
||||
const drawer = this.drawerEl()?.nativeElement;
|
||||
drawer?.querySelector<HTMLElement>('a, button')?.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
closeMobileDrawer(): void {
|
||||
if (!this.mobileDrawerOpen()) {
|
||||
return;
|
||||
}
|
||||
this.mobileDrawerOpen.set(false);
|
||||
this.menuToggleEl()?.nativeElement.focus();
|
||||
}
|
||||
|
||||
toggleNotifications(): void {
|
||||
this.notificationsOpen.update(open => !open);
|
||||
}
|
||||
|
||||
adminLinkFor(entry: Extract<AdminNavEntry, { type: 'link' }>): string[] {
|
||||
const lang = this.currentLang();
|
||||
if (entry.absolutePath) {
|
||||
return ['/', lang, ...entry.absolutePath];
|
||||
}
|
||||
return ['/', lang, 'backoffice', ...(entry.path ?? [])];
|
||||
}
|
||||
|
||||
breadcrumbLink(entry: AdminBreadcrumbEntry): string[] {
|
||||
return ['/', this.currentLang(), 'backoffice', ...(entry.path ?? [])];
|
||||
}
|
||||
|
||||
logout(): void {
|
||||
this.adminAuth.logout();
|
||||
}
|
||||
|
||||
cardTitle(key: string): string {
|
||||
return this.translate.t(key);
|
||||
}
|
||||
|
||||
private readRouteData(): void {
|
||||
let leaf = this.route;
|
||||
while (leaf.firstChild) {
|
||||
leaf = leaf.firstChild;
|
||||
}
|
||||
const data = leaf.snapshot.data as {
|
||||
titleKey?: string;
|
||||
descriptionKey?: string;
|
||||
breadcrumb?: AdminBreadcrumbEntry[];
|
||||
};
|
||||
this.titleKeySignal.set(data.titleKey ?? 'adminShell.pages.dashboard.title');
|
||||
this.descriptionKeySignal.set(data.descriptionKey ?? 'adminShell.pages.dashboard.description');
|
||||
this.breadcrumbSignal.set(data.breadcrumb ?? []);
|
||||
}
|
||||
}
|
||||
62
src/app/features/admin/shell/admin-nav.model.ts
Normal file
62
src/app/features/admin/shell/admin-nav.model.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
export interface AdminNavLink {
|
||||
type: 'link';
|
||||
id: string;
|
||||
icon: string;
|
||||
labelKey: string;
|
||||
/** Segments appended to /:lang/backoffice/. Mutually exclusive with absolutePath. */
|
||||
path?: string[];
|
||||
/** Segments appended to /:lang/ directly (routes outside /backoffice, e.g. the project editor). */
|
||||
absolutePath?: string[];
|
||||
/** No route exists yet - rendered as a disabled item with a "coming soon" badge. */
|
||||
comingSoon?: boolean;
|
||||
}
|
||||
|
||||
export interface AdminNavGroup {
|
||||
type: 'group';
|
||||
labelKey: string;
|
||||
}
|
||||
|
||||
export interface AdminNavAction {
|
||||
type: 'action';
|
||||
id: string;
|
||||
icon: string;
|
||||
labelKey: string;
|
||||
}
|
||||
|
||||
export type AdminNavEntry = AdminNavLink | AdminNavGroup | AdminNavAction;
|
||||
|
||||
export const ADMIN_NAV_PRIMARY: AdminNavEntry[] = [
|
||||
{ type: 'link', id: 'dashboard', icon: 'pi-home', labelKey: 'adminShell.nav.dashboard', path: ['dashboard'] },
|
||||
{ type: 'group', labelKey: 'adminShell.nav.catalogGroup' },
|
||||
{ type: 'link', id: 'products', icon: 'pi-box', labelKey: 'adminShell.nav.products', path: ['products'] },
|
||||
{ type: 'link', id: 'categories', icon: 'pi-tags', labelKey: 'adminShell.nav.categories', path: ['categories'] },
|
||||
{ type: 'link', id: 'orders', icon: 'pi-shopping-cart', labelKey: 'adminShell.nav.orders', path: ['orders'] },
|
||||
{ type: 'link', id: 'transactions', icon: 'pi-credit-card', labelKey: 'adminShell.nav.transactions', path: ['transactions'] },
|
||||
{ type: 'link', id: 'reviews', icon: 'pi-star', labelKey: 'adminShell.nav.reviews', comingSoon: true },
|
||||
{ type: 'link', id: 'reports', icon: 'pi-chart-bar', labelKey: 'adminShell.nav.reports', comingSoon: true },
|
||||
{ type: 'link', id: 'content', icon: 'pi-file-edit', labelKey: 'adminShell.nav.content', absolutePath: ['edit', 'static-pages'] },
|
||||
{ type: 'link', id: 'media', icon: 'pi-images', labelKey: 'adminShell.nav.mediaLibrary', path: ['media'] },
|
||||
{ type: 'link', id: 'marketplace-builder', icon: 'pi-sitemap', labelKey: 'adminShell.nav.marketplaceBuilder', absolutePath: ['edit', 'general'] },
|
||||
{ type: 'link', id: 'users', icon: 'pi-users', labelKey: 'adminShell.nav.users', path: ['users'] },
|
||||
{ type: 'link', id: 'settings', icon: 'pi-cog', labelKey: 'adminShell.nav.settings', comingSoon: true },
|
||||
{ type: 'link', id: 'monitoring', icon: 'pi-desktop', labelKey: 'adminShell.nav.monitoring', path: ['monitoring'] },
|
||||
{ type: 'link', id: 'analytics', icon: 'pi-chart-line', labelKey: 'adminShell.nav.analytics', path: ['analytics'] },
|
||||
];
|
||||
|
||||
export const ADMIN_NAV_BOTTOM: AdminNavEntry[] = [
|
||||
{ type: 'link', id: 'documentation', icon: 'pi-book', labelKey: 'adminShell.nav.documentation', comingSoon: true },
|
||||
{ type: 'link', id: 'help', icon: 'pi-question-circle', labelKey: 'adminShell.nav.help', comingSoon: true },
|
||||
{ type: 'action', id: 'logout', icon: 'pi-sign-out', labelKey: 'adminShell.nav.logout' },
|
||||
];
|
||||
|
||||
export interface AdminBreadcrumbEntry {
|
||||
labelKey: string;
|
||||
/** Segments appended to /:lang/backoffice/. Omitted on the last (current) crumb. */
|
||||
path?: string[];
|
||||
}
|
||||
|
||||
export interface AdminPageData {
|
||||
titleKey: string;
|
||||
descriptionKey: string;
|
||||
breadcrumb: AdminBreadcrumbEntry[];
|
||||
}
|
||||
Reference in New Issue
Block a user