Skip to content

Commit

Permalink
feat: icon glow based on route
Browse files Browse the repository at this point in the history
  • Loading branch information
gutche committed Apr 6, 2023
1 parent 36252d4 commit a257b12
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 20 deletions.
7 changes: 0 additions & 7 deletions front/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ const routes: Routes = [
path: '',
component: FeedComponent,
},
{
path: 'followed',
component: FeedComponent,
title: 'Alist | Followed',
canActivate: [AuthGuard],
data: { role: 'user' },
},
{
path: 'sign-in',
component: SignInComponent,
Expand Down
24 changes: 12 additions & 12 deletions front/src/app/shared/components/nav/nav.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
<nav class="navbar navbar-expand-lg bg-black">
<div class="d-none d-md-block container-fluid">
<div class="d-flex justify-content-evenly align-items-center m-auto">
<a class="navbar-brand" [routerLink]="['/']">
<a class="navbar-brand" [routerLink]="['/']" (click)="toggleOff()">
<img src="assets/images/alistLogo.svg" alt="Alist logo" width="80" height="30">
</a>
<a class="compassNavIcon" [routerLink]="['/']">
<i class="fa-regular fa-compass fa-xl"></i>
<a class="compassNavIcon" [routerLink]="['/explore']">
<i class="fa-compass fa-xl" [ngClass]="compassIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
<app-search></app-search>
<a class="heartNavIcon" [routerLink]="['/followed']">
<i class="fa-regular fa-heart fa-xl"></i>
<a class="heartNavIcon" (click)="toggleHeartIcon()">
<i class="fa-heart fa-xl" [ngClass]="heartIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
<a class="profileNavIcon" [routerLink]="['/profile']">
<i class="fa-regular fa-user fa-xl"></i>
<i class="fa-user fa-xl" [ngClass]="profileIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
</div>
</div>

<div class="hamburger-container d-sm-block d-md-none">
<div class="d-flex justify-content-end align-items-center">
<a class="navbar-brand ps-2 m-auto flex-grow-1" [routerLink]="['/']">
<a class="navbar-brand ps-2 m-auto flex-grow-1" [routerLink]="['/']" (click)="toggleOff()">
<img src="assets/images/alistLogo.svg" alt="Alist logo" width="101.33 " height="38">
</a>
<div class="collapse no-transition" id="collapseNav">
<div class="icon-container d-flex justify-content-evenly align-items-center ps-2 pe-2 gap-3">
<a class="compassNavIcon" [routerLink]="['/']">
<i class="fa-regular fa-compass fa-xl"></i>
<a class="compassNavIcon" [routerLink]="['/explore']">
<i class="fa-compass fa-xl" [ngClass]="compassIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
<a class="heartNavIcon" [routerLink]="['/followed']">
<i class="fa-regular fa-heart fa-xl"></i>
<a class="heartNavIcon" (click)="toggleHeartIcon()">
<i class="fa-heart fa-xl" [ngClass]="heartIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
<a class="profileNavIcon" [routerLink]="['/profile']">
<i class="fa-regular fa-user fa-xl"></i>
<i class="fa-user fa-xl" [ngClass]="profileIconGlow ? 'fa-solid' : 'fa-regular'"></i>
</a>
</div>
</div>
Expand Down
47 changes: 46 additions & 1 deletion front/src/app/shared/components/nav/nav.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
import { Component } from '@angular/core';
import { NavigationEnd, Router, Event } from '@angular/router';
import { filter } from 'rxjs';

@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.css'],
})
export class NavComponent {}
export class NavComponent {
compassIconGlow: boolean;
heartIconGlow: boolean;
profileIconGlow: boolean;
currentRoute: string;
filtered: boolean;

constructor(private router: Router) {
this.filtered = false;
this.currentRoute = '';
this.compassIconGlow = false;
this.heartIconGlow = false;
this.profileIconGlow = false;
this.router.events
.pipe(
filter((e: Event): e is NavigationEnd => e instanceof NavigationEnd)
)
.subscribe(e => {
this.currentRoute = e.url;
this.toggleOff();
if (this.currentRoute === '/profile') {
this.profileIconGlow = true;
} else if (this.currentRoute === '/explore') {
this.compassIconGlow = true;
}
});
}

toggleHeartIcon = () => {
this.toggleOff();
this.filtered = true;
this.heartIconGlow = true;
};

toggleOff = () => {
this.compassIconGlow = false;
this.heartIconGlow = false;
this.profileIconGlow = false;
this.heartIconGlow = false;
this.filtered = false;
};

ngOnInit() {}
}

0 comments on commit a257b12

Please sign in to comment.