feat(sidebar): implement smooth expansion animations and RTL support
Add staggered transitions to sidebar labels to prevent text reflow during expansion. Update account menu to RTL direction and localize logout text. Refine collapsed sidebar layout for improved icon alignment.
This commit is contained in:
@@ -7,11 +7,14 @@
|
|||||||
background: var(--sidebar-bg);
|
background: var(--sidebar-bg);
|
||||||
color: var(--sidebar-text);
|
color: var(--sidebar-text);
|
||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
transition: width 0.3s ease;
|
/* The width transition drives the whole expansion; text reveal is gated by the
|
||||||
|
matching delay below so labels never reflow mid-flight. */
|
||||||
|
transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
z-index: 40;
|
z-index: 40;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-left: 1px solid var(--sidebar-border);
|
border-left: 1px solid var(--sidebar-border);
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar.open {
|
.sidebar.open {
|
||||||
@@ -30,6 +33,52 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sidebar width animation: 0.35s. Text must not appear until the sidebar is wide
|
||||||
|
enough to hold the label on one line, so every label fades in only AFTER the
|
||||||
|
width transition finishes (delay = full duration) and fades out immediately
|
||||||
|
when collapsing. This prevents Persian text from wrapping vertically. */
|
||||||
|
:root {
|
||||||
|
--sidebar-expand-duration: 0.35s;
|
||||||
|
--sidebar-collapse-duration: 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scoped to `.sidebar`: the account menu is a CDK overlay rendered outside the sidebar
|
||||||
|
DOM, so unscoping these selectors would hide the username inside the dropdown too. */
|
||||||
|
.sidebar .nav-label,
|
||||||
|
.sidebar .history-text,
|
||||||
|
.sidebar .history-header .history-title,
|
||||||
|
.sidebar .user-info,
|
||||||
|
.sidebar .theme-toggle span {
|
||||||
|
max-width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
transform: translateX(-8px);
|
||||||
|
/* Fast fade OUT when collapsing — no delay on the way in. */
|
||||||
|
transition:
|
||||||
|
max-width var(--sidebar-collapse-duration) ease-in,
|
||||||
|
opacity var(--sidebar-collapse-duration) ease-in,
|
||||||
|
transform var(--sidebar-collapse-duration) ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expanded state: the sidebar has finished growing, so the label can fade in.
|
||||||
|
`max-width: 100%` lets it occupy only the remaining space next to the icon
|
||||||
|
(never forcing a second line), and the delay guarantees the width is already
|
||||||
|
sufficient before the text becomes visible. */
|
||||||
|
.sidebar.open .nav-label,
|
||||||
|
.sidebar.open .history-text,
|
||||||
|
.sidebar.open .history-header .history-title,
|
||||||
|
.sidebar.open .user-info,
|
||||||
|
.sidebar.open .theme-toggle span {
|
||||||
|
max-width: 100%;
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
transition:
|
||||||
|
max-width var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
|
||||||
|
opacity var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration),
|
||||||
|
transform var(--sidebar-expand-duration) ease-out var(--sidebar-expand-duration);
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-top {
|
.sidebar-top {
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -67,16 +116,19 @@
|
|||||||
|
|
||||||
.sidebar:not(.open) .sidebar-logo-link {
|
.sidebar:not(.open) .sidebar-logo-link {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .sidebar-logo {
|
.sidebar:not(.open) .sidebar-logo {
|
||||||
height: 36px;
|
height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep the logo in the same 40px column as the nav items. */
|
||||||
.sidebar:not(.open) .sidebar-header {
|
.sidebar:not(.open) .sidebar-header {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.5rem 0.25rem;
|
padding: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .close-btn {
|
.sidebar:not(.open) .close-btn {
|
||||||
@@ -181,6 +233,8 @@
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
|
/* Keep the icon and label on one line regardless of sidebar width. */
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-item:hover {
|
.nav-item:hover {
|
||||||
@@ -193,17 +247,28 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Collapsed rail (72px): a fixed 40px item column centred in the rail, so every icon
|
||||||
|
lines up with the others and with the logo/avatar above it. */
|
||||||
|
.sidebar:not(.open) .sidebar-top {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .nav-item {
|
.sidebar:not(.open) .nav-item {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.75rem 0;
|
gap: 0;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 auto;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .nav-item svg {
|
.sidebar:not(.open) .nav-item .nav-icon {
|
||||||
margin: 0;
|
flex-shrink: 0;
|
||||||
}
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
.sidebar:not(.open) .nav-label {
|
justify-content: center;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-divider {
|
.sidebar-divider {
|
||||||
@@ -213,7 +278,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .sidebar-divider {
|
.sidebar:not(.open) .sidebar-divider {
|
||||||
margin: 0 0.5rem;
|
/* Same 40px column inset (16px each side of the 72px rail). */
|
||||||
|
margin: 0 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-bottom {
|
.sidebar-bottom {
|
||||||
@@ -229,15 +295,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-header {
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--sidebar-muted);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar:not(.open) .history-header {
|
.sidebar:not(.open) .history-header {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -277,6 +334,23 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The whole lower section collapses with the sidebar; its labels animate via
|
||||||
|
the shared width/opacity transition defined earlier. */
|
||||||
|
.sidebar:not(.open) .history-header {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-header {
|
||||||
|
display: flex;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--sidebar-muted);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.history-icon {
|
.history-icon {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
@@ -286,10 +360,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
min-width: 0;
|
||||||
|
|
||||||
.sidebar:not(.open) .history-text {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.history-empty {
|
.history-empty {
|
||||||
@@ -304,10 +375,6 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .history-empty {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.history-empty-icon {
|
.history-empty-icon {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
@@ -324,25 +391,20 @@
|
|||||||
|
|
||||||
.sidebar:not(.open) .sidebar-footer {
|
.sidebar:not(.open) .sidebar-footer {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5rem;
|
padding: 0.75rem 1rem;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .user-info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar:not(.open) .user-profile {
|
.sidebar:not(.open) .user-profile {
|
||||||
width: 56px;
|
width: 40px;
|
||||||
height: 56px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
gap: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle span {
|
/* Theme-toggle label animates with the shared transition instead of display:none. */
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-profile {
|
.user-profile {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -356,6 +418,7 @@
|
|||||||
color: var(--sidebar-text);
|
color: var(--sidebar-text);
|
||||||
text-align: start;
|
text-align: start;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-profile:hover,
|
.user-profile:hover,
|
||||||
@@ -383,10 +446,16 @@
|
|||||||
.account-menu-header {
|
.account-menu-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
/* dir="rtl" on .account-menu already lays children right→left, so the default
|
||||||
|
`row` order puts the avatar on the right and the name beside it to the left. */
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-menu-header .user-info {
|
||||||
|
text-align: start;
|
||||||
|
}
|
||||||
|
|
||||||
.account-menu-divider {
|
.account-menu-divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 0.375rem 0.5rem;
|
margin: 0.375rem 0.5rem;
|
||||||
@@ -396,6 +465,7 @@
|
|||||||
.account-menu-item {
|
.account-menu-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
/* justify-content: space-between; */
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.625rem 0.75rem;
|
padding: 0.625rem 0.75rem;
|
||||||
@@ -436,6 +506,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-name {
|
.user-name {
|
||||||
@@ -479,9 +550,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .claim-btn span {
|
/* Label collapse is handled by the shared width/opacity transition. */
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-toggle {
|
.theme-toggle {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -504,17 +573,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle {
|
.sidebar:not(.open) .theme-toggle {
|
||||||
width: 56px;
|
width: 40px;
|
||||||
height: 56px;
|
height: 40px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
gap: 0;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle svg {
|
.sidebar:not(.open) .theme-toggle svg {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar:not(.open) .theme-toggle span {
|
/* Collapsed rail: the avatar text must not stretch the 40px column. */
|
||||||
display: none;
|
.sidebar:not(.open) .user-avatar {
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
fill="none"
|
fill="none"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
|
class="nav-icon"
|
||||||
>
|
>
|
||||||
<path [attr.d]="item.icon" />
|
<path [attr.d]="item.icon" />
|
||||||
</svg>
|
</svg>
|
||||||
@@ -116,13 +117,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<ng-template #accountMenu>
|
<ng-template #accountMenu>
|
||||||
<div class="account-menu" cdkMenu aria-label="Account menu" dir="ltr">
|
<div class="account-menu" cdkMenu aria-label="Account menu" dir="rtl">
|
||||||
<div class="account-menu-header">
|
<div class="account-menu-header">
|
||||||
<div class="user-avatar">{{ userInitials() }}</div>
|
<div class="user-avatar">{{ userInitials() }}</div>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span class="user-name">{{ userName() }}</span>
|
<span class="user-name">{{ userName() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
<div class="account-menu-divider" role="separator"></div>
|
<div class="account-menu-divider" role="separator"></div>
|
||||||
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="profileClick.emit()">
|
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="profileClick.emit()">
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
@@ -132,12 +134,13 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Profile</span>
|
<span>Profile</span>
|
||||||
</button>
|
</button>
|
||||||
|
-->
|
||||||
<div class="account-menu-divider" role="separator"></div>
|
<div class="account-menu-divider" role="separator"></div>
|
||||||
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="logoutClick.emit()">
|
<button type="button" class="account-menu-item" cdkMenuItem (cdkMenuItemTriggered)="logoutClick.emit()">
|
||||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
|
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>Log out</span>
|
<span>خروج</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ export class SidebarComponent {
|
|||||||
readonly close = output<void>();
|
readonly close = output<void>();
|
||||||
readonly navClick = output<void>();
|
readonly navClick = output<void>();
|
||||||
readonly open = output<void>();
|
readonly open = output<void>();
|
||||||
readonly profileClick = output<void>();
|
// Profile page is disabled; the account-menu entry is commented out in the template.
|
||||||
|
// readonly profileClick = output<void>();
|
||||||
readonly logoutClick = output<void>();
|
readonly logoutClick = output<void>();
|
||||||
|
|
||||||
readonly userInitials = computed(() => {
|
readonly userInitials = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user