feat: highlight active links in SidebarComponent

This commit is contained in:
Chneemann 2025-04-05 13:21:07 +02:00
parent 4fb3ff25d9
commit 6286743507
4 changed files with 33 additions and 22 deletions

View file

@ -7,8 +7,7 @@
class="nav-links-inner" class="nav-links-inner"
routerLink="summary" routerLink="summary"
[ngClass]="{ [ngClass]="{
active: currentPath == 'summary', 'active-nav': currentPath == 'summary',
'switch-language': languageService.currentLang == 'de'
}" }"
> >
<img src="./assets/img/sidebar/summary.svg" alt="summary" /><span>{{ <img src="./assets/img/sidebar/summary.svg" alt="summary" /><span>{{
@ -20,8 +19,7 @@
class="nav-links-inner" class="nav-links-inner"
routerLink="add-task" routerLink="add-task"
[ngClass]="{ [ngClass]="{
active: currentPath == 'add-task', 'active-nav': currentPath == 'add-task',
'switch-language': languageService.currentLang == 'de'
}" }"
> >
<img src="./assets/img/sidebar/add-task.svg" alt="addtask" /><span>{{ <img src="./assets/img/sidebar/add-task.svg" alt="addtask" /><span>{{
@ -33,8 +31,7 @@
class="nav-links-inner" class="nav-links-inner"
routerLink="board" routerLink="board"
[ngClass]="{ [ngClass]="{
active: currentPath == 'board', 'active-nav': currentPath == 'board',
'switch-language': languageService.currentLang == 'de'
}" }"
> >
<img src="./assets/img/sidebar/board.svg" alt="board" /><span>{{ <img src="./assets/img/sidebar/board.svg" alt="board" /><span>{{
@ -46,8 +43,7 @@
class="nav-links-inner" class="nav-links-inner"
routerLink="contacts" routerLink="contacts"
[ngClass]="{ [ngClass]="{
active: currentPath == 'contacts', 'active-nav': currentPath == 'contacts',
'switch-language': languageService.currentLang == 'de'
}" }"
> >
<img src="./assets/img/sidebar/contacts.svg" alt="contacts" /><span>{{ <img src="./assets/img/sidebar/contacts.svg" alt="contacts" /><span>{{
@ -57,10 +53,22 @@
</nav> </nav>
<div class="reference"> <div class="reference">
<p routerLink="privacy-policy"> <a
routerLink="privacy-policy"
[ngClass]="{
'active-link': currentPath === 'privacy-policy'
}"
>
{{ "sidebar.privacyPolicy" | translate }} {{ "sidebar.privacyPolicy" | translate }}
</p> </a>
<p routerLink="imprint">{{ "sidebar.legalNotice" | translate }}</p> <a
<p (click)="logout()">{{ "sidebar.logout" | translate }}</p> routerLink="imprint"
[ngClass]="{
'active-link': currentPath === 'imprint'
}"
>
{{ "sidebar.legalNotice" | translate }}
</a>
<a (click)="logout()">{{ "sidebar.logout" | translate }}</a>
</div> </div>
</section> </section>

View file

@ -45,11 +45,7 @@ nav {
} }
} }
.active { .language-de {
background-color: var(--very-dark-blue);
}
.switch-language {
padding-left: 43px; padding-left: 43px;
} }
@ -58,13 +54,14 @@ nav {
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
margin-bottom: 30px; margin-bottom: 30px;
p { a {
justify-content: center;
width: fit-content; width: fit-content;
padding: 8px; padding: 8px;
margin: 12px 0; margin: 12px 0;
display: flex; display: flex;
text-align: center; text-align: center;
justify-content: center; text-decoration: none;
color: var(--light-gray); color: var(--light-gray);
cursor: pointer; cursor: pointer;
&:hover { &:hover {
@ -72,3 +69,11 @@ nav {
} }
} }
} }
.active-nav {
background-color: var(--very-dark-blue);
}
.active-link {
color: var(--light-blue) !important;
}

View file

@ -22,8 +22,6 @@ export class SidebarComponent implements OnInit {
) {} ) {}
/** /**
* Lifecycle hook that is called after the component has been initialized.
*
* Calls the getCurrentPath method to set the currentPath property to the current route's url. * Calls the getCurrentPath method to set the currentPath property to the current route's url.
*/ */
ngOnInit(): void { ngOnInit(): void {

View file

@ -66,7 +66,7 @@
}, },
"sidebar": { "sidebar": {
"summary": "Übersicht", "summary": "Übersicht",
"addTask": "Neue Aufgabe", "addTask": "Aufgabe",
"addTaskMobile": "Aufgabe", "addTaskMobile": "Aufgabe",
"board": "Tafel", "board": "Tafel",
"contacts": "Kontakte", "contacts": "Kontakte",