first commit
This commit is contained in:
@@ -0,0 +1,519 @@
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 260px;
|
||||
background: var(--sidebar-bg);
|
||||
color: var(--sidebar-text);
|
||||
transform: translateX(0);
|
||||
transition: width 0.3s ease;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-left: 1px solid var(--sidebar-border);
|
||||
}
|
||||
|
||||
.sidebar.open {
|
||||
width: 260px;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) {
|
||||
width: 72px;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-top {
|
||||
padding: 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem;
|
||||
min-height: 48px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
height: 32px;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.sidebar-logo-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-logo-link:hover .sidebar-logo {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-logo-link {
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-logo {
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-header {
|
||||
justify-content: center;
|
||||
padding: 0.5rem 0.25rem;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .close-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.sidebar-open-icon {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 0.5rem;
|
||||
background: var(--surface-bg);
|
||||
color: var(--sidebar-text);
|
||||
border: 1px solid var(--sidebar-border);
|
||||
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.2s, visibility 0.2s;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-logo-link:hover .sidebar-logo {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-logo-link:hover .sidebar-open-icon {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: var(--sidebar-text);
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--sidebar-muted);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .close-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.new-chat-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--sidebar-border);
|
||||
background: transparent;
|
||||
color: var(--sidebar-text);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
transition: background 0.2s;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.new-chat-btn:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem;
|
||||
border-radius: 0.5rem;
|
||||
color: var(--sidebar-muted);
|
||||
text-decoration: none;
|
||||
font-size: 0.875rem;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
background: var(--sidebar-hover);
|
||||
color: var(--sidebar-text);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .nav-item {
|
||||
justify-content: center;
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .nav-item svg {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .nav-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar-divider {
|
||||
height: 1px;
|
||||
background: var(--sidebar-border);
|
||||
margin: 0 0.75rem;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-divider {
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar-bottom {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-bottom {
|
||||
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 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.history-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--sidebar-muted);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
text-align: start;
|
||||
transition: background 0.2s;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.history-item:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .history-item {
|
||||
justify-content: center;
|
||||
padding: 0.75rem 0;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .history-item svg {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.history-icon {
|
||||
flex-shrink: 0;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.history-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .history-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.history-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
padding: 1.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--sidebar-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .history-empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.history-empty-icon {
|
||||
opacity: 0.5;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 0.75rem;
|
||||
border-top: 1px solid var(--sidebar-border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .sidebar-footer {
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .user-info {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .user-profile {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .theme-toggle span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.user-profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
border: none;
|
||||
border-radius: 0.75rem;
|
||||
background: transparent;
|
||||
color: var(--sidebar-text);
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.user-profile:hover,
|
||||
.user-profile.menu-open {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.user-profile:focus-visible,
|
||||
.account-menu-item:focus-visible {
|
||||
outline: 2px solid var(--sidebar-muted);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.account-menu {
|
||||
width: 236px;
|
||||
max-width: calc(100vw - 24px);
|
||||
padding: 0.5rem;
|
||||
border: 1px solid var(--sidebar-border);
|
||||
border-radius: 1.25rem;
|
||||
background: var(--surface-bg);
|
||||
color: var(--sidebar-text);
|
||||
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
||||
}
|
||||
|
||||
.account-menu-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.account-menu-divider {
|
||||
height: 1px;
|
||||
margin: 0.375rem 0.5rem;
|
||||
background: var(--sidebar-border);
|
||||
}
|
||||
|
||||
.account-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
padding: 0.625rem 0.75rem;
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 0.875rem;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.account-menu-item:hover,
|
||||
.account-menu-item:focus {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.account-menu-item svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background: var(--sidebar-hover);
|
||||
color: var(--sidebar-text);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.125rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--sidebar-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.claim-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.625rem;
|
||||
border: 1px solid var(--sidebar-border);
|
||||
background: transparent;
|
||||
color: var(--sidebar-text);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.claim-btn:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .claim-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 0;
|
||||
border-radius: 0.5rem;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .claim-btn svg {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .claim-btn span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.theme-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.625rem;
|
||||
border: 1px solid var(--sidebar-border);
|
||||
background: transparent;
|
||||
color: var(--sidebar-text);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
background: var(--sidebar-hover);
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .theme-toggle {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
padding: 0;
|
||||
border-radius: 0.5rem;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .theme-toggle svg {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar:not(.open) .theme-toggle span {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
<aside class="sidebar" [class.open]="isOpen()">
|
||||
<div class="sidebar-inner">
|
||||
<div class="sidebar-top">
|
||||
<div class="sidebar-header">
|
||||
<a
|
||||
class="sidebar-logo-link"
|
||||
[routerLink]="isOpen() ? '/' : null"
|
||||
(click)="onLogoClick()"
|
||||
>
|
||||
<img class="sidebar-logo" [src]="isDarkMode() ? 'assets/images/RaymandLogo.png' : 'assets/images/login.png'" alt="Raymand" />
|
||||
<span class="sidebar-open-icon" aria-hidden="true">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 6h16M4 12h16M4 18h16" />
|
||||
</svg>
|
||||
</span>
|
||||
</a>
|
||||
<button type="button" class="close-btn" (click)="close.emit()" aria-label="Close sidebar">
|
||||
<svg
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path d="M18 6L6 18M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<nav class="nav-menu">
|
||||
@for (item of navItems(); track item.label) {
|
||||
<a
|
||||
[routerLink]="item.route"
|
||||
class="nav-item"
|
||||
routerLinkActive="active"
|
||||
(click)="onNavClick()"
|
||||
>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path [attr.d]="item.icon" />
|
||||
</svg>
|
||||
<span class="nav-label">{{ item.label }}</span>
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-divider"></div>
|
||||
|
||||
<div class="sidebar-bottom">
|
||||
<div class="history-header">
|
||||
<span class="history-title">گفتگوهای اخیر</span>
|
||||
</div>
|
||||
|
||||
<div class="history-list">
|
||||
@for (item of chatHistory(); track item.id) {
|
||||
<button type="button" class="history-item">
|
||||
<svg
|
||||
class="history-icon"
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z" />
|
||||
</svg>
|
||||
<span class="history-text">{{ item.title }}</span>
|
||||
</button>
|
||||
} @empty {
|
||||
<div class="history-empty">
|
||||
<svg
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
class="history-empty-icon"
|
||||
>
|
||||
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z" />
|
||||
</svg>
|
||||
<span>گفتگویی ثبت نشده است</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="user-profile"
|
||||
[cdkMenuTriggerFor]="accountMenu"
|
||||
[cdkMenuPosition]="[
|
||||
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -8 },
|
||||
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 8 }
|
||||
]"
|
||||
#accountMenuTrigger="cdkMenuTriggerFor"
|
||||
[class.menu-open]="accountMenuTrigger.isOpen()"
|
||||
aria-label="Open account menu"
|
||||
>
|
||||
<div class="user-avatar">
|
||||
{{ userInitials() }}
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<span class="user-name">{{ userName() }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<ng-template #accountMenu>
|
||||
<div class="account-menu" cdkMenu aria-label="Account menu" dir="ltr">
|
||||
<div class="account-menu-header">
|
||||
<div class="user-avatar">{{ userInitials() }}</div>
|
||||
<div class="user-info">
|
||||
<span class="user-name">{{ userName() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="account-menu-divider" role="separator"></div>
|
||||
<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">
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
<circle cx="12" cy="9" r="3" />
|
||||
<path d="M6 18a6 6 0 0 1 12 0" />
|
||||
</svg>
|
||||
<span>Profile</span>
|
||||
</button>
|
||||
<div class="account-menu-divider" role="separator"></div>
|
||||
<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">
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" />
|
||||
</svg>
|
||||
<span>Log out</span>
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
<button
|
||||
type="button"
|
||||
class="theme-toggle"
|
||||
(click)="toggleTheme()"
|
||||
aria-label="Toggle dark mode"
|
||||
>
|
||||
@if (isDarkMode()) {
|
||||
<svg
|
||||
width="18"
|
||||
height="18"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="12" cy="12" r="5" />
|
||||
<line x1="12" y1="1" x2="12" y2="3" />
|
||||
<line x1="12" y1="21" x2="12" y2="23" />
|
||||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64" />
|
||||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78" />
|
||||
<line x1="1" y1="12" x2="3" y2="12" />
|
||||
<line x1="21" y1="12" x2="23" y2="12" />
|
||||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36" />
|
||||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22" />
|
||||
</svg>
|
||||
<span>حالت روشن</span>
|
||||
} @else {
|
||||
<svg
|
||||
width="18"
|
||||
height="18"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
||||
</svg>
|
||||
<span>حالت تاریک</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -0,0 +1,74 @@
|
||||
import { ChangeDetectionStrategy, Component, input, output, computed, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CdkMenuModule } from '@angular/cdk/menu';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { ThemeService } from '../../../services/theme/theme.service';
|
||||
|
||||
export interface NavItem {
|
||||
icon: string;
|
||||
label: string;
|
||||
route?: string;
|
||||
}
|
||||
|
||||
export interface ChatHistoryItem {
|
||||
id: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterModule, CdkMenuModule],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrl: './sidebar.component.css'
|
||||
})
|
||||
export class SidebarComponent {
|
||||
private readonly themeService = inject(ThemeService);
|
||||
|
||||
readonly isOpen = input<boolean>(false);
|
||||
readonly userName = input<string>('Peyman Honarjoo');
|
||||
readonly navItems = input<NavItem[]>([
|
||||
{
|
||||
icon: 'M12 5v14M5 12h14',
|
||||
label: 'چت جدید',
|
||||
},
|
||||
{
|
||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
|
||||
label: 'تنظیمات',
|
||||
route: '/settings',
|
||||
},
|
||||
]);
|
||||
readonly chatHistory = input<ChatHistoryItem[]>([]);
|
||||
readonly close = output<void>();
|
||||
readonly navClick = output<void>();
|
||||
readonly open = output<void>();
|
||||
readonly profileClick = output<void>();
|
||||
readonly logoutClick = output<void>();
|
||||
|
||||
readonly userInitials = computed(() => {
|
||||
const name = this.userName();
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.slice(0, 2)
|
||||
.toUpperCase();
|
||||
});
|
||||
|
||||
readonly isDarkMode = this.themeService.isDarkMode;
|
||||
|
||||
toggleTheme(): void {
|
||||
this.themeService.toggleDarkMode();
|
||||
}
|
||||
|
||||
onNavClick(): void {
|
||||
this.navClick.emit();
|
||||
}
|
||||
|
||||
onLogoClick(): void {
|
||||
if (!this.isOpen()) {
|
||||
this.open.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user