Skip to content

Commit 2784044

Browse files
committed
💄 home section styles changed
1 parent 28011e5 commit 2784044

32 files changed

+434
-141
lines changed

src/app/auth/auth.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class AuthComponent implements OnInit, OnDestroy {
1515
private bodyElement = document.body as HTMLBodyElement;
1616
public showLogin: boolean = true;
1717

18-
constructor(private authService: AuthService) { }
18+
constructor(private authService: AuthService) {}
1919

2020
ngOnDestroy(): void {
2121
this.authSubscription.unsubscribe();
@@ -35,8 +35,8 @@ export class AuthComponent implements OnInit, OnDestroy {
3535
this.modalAuth.nativeElement.classList.remove('modal-open');
3636
}
3737

38-
changePage(value: boolean) {
39-
this.showLogin = value;
38+
changePage(show: boolean) {
39+
this.showLogin = show;
4040
}
4141

4242
}

src/app/core/components/sidebar/sidebar.component.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ nav li a {
110110
text-decoration: none;
111111
transition: 0.5s ease;
112112
background: transparent;
113+
cursor: pointer;
113114
}
114115

115116
nav li a:hover,

src/app/core/components/sidebar/sidebar.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
</div>
66
<ul class="nav-list">
77
<li>
8-
<a (click)="changeExplore(true)">
8+
<a routerLink="/">
99
<i class='bx bx-news'></i>
1010
<span class="links_name">News</span>
1111
</a>
1212
<span class="tooltip">News</span>
1313
</li>
1414
<li>
15-
<a (click)="changeExplore(false)">
15+
<a (click)="navigate('/explore')">
1616
<i class='bx bx-world'></i>
1717
<span class="links_name">Explore</span>
1818
</a>
1919
<span class="tooltip">Explore</span>
2020
</li>
2121
<li>
22-
<a routerLink="/feed/saved">
22+
<a (click)="navigate('/feed/saved')">
2323
<i class='bx bx-bookmark'></i>
2424
<span class="links_name">Saved</span>
2525
</a>

src/app/core/components/sidebar/sidebar.component.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export class SidebarComponent implements OnInit, AfterViewInit, OnDestroy {
1616
private wrapper: any;
1717
public userActive: User;
1818
private userActiveSubscription: Subscription;
19+
20+
public isAuthenticated: boolean = false;
21+
1922
constructor(
2023
private authService: AuthService,
2124
private feedService: FeedService,
@@ -34,10 +37,9 @@ export class SidebarComponent implements OnInit, AfterViewInit, OnDestroy {
3437
}
3538

3639
ngOnInit(): void {
40+
this.isAuthenticated = this.authService.isAuthenticated();
3741
this.userActiveSubscription = this.authService.isAuthenticatedEmitter.subscribe(resp => {
38-
if(resp) {
39-
this.setUserInfoActive();
40-
}
42+
if(resp) this.setUserInfoActive();
4143
});
4244
}
4345

@@ -46,25 +48,15 @@ export class SidebarComponent implements OnInit, AfterViewInit, OnDestroy {
4648
}
4749

4850
changeExplore(value: boolean): void {
49-
if(!value) {
50-
if(!this.authService.isAuthenticated()) {
51-
return;
52-
}
53-
}
5451
this.router.navigate(['/']);
5552
this.feedService.changeToExplore(value);
5653
}
5754

58-
// toggled(element: any) {
59-
// console.log(this.userActive);
60-
// this.sidebar?.classList.toggle('open');
61-
// this.wrapper.classList.toggle('open');
62-
// console.log(this.sidebar);
63-
// if(this.sidebar?.classList.contains('open')) {
64-
// element.classList.replace('bx-menu', 'bx-menu-alt-right');//replacing the iocns class
65-
// } else {
66-
// element.classList.replace('bx-menu-alt-right','bx-menu');//replacing the iocns class
67-
// }
68-
// }
55+
navigate(route: string): void {
56+
if(!this.isAuthenticated) {
57+
return this.authService.showModalAuth();
58+
}
59+
this.router.navigate([route]);
60+
}
6961

7062
}

src/app/core/services/auth.service.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const base_url = environment.base_url;
1616
export class AuthService {
1717

1818
private userActive: User;
19-
public isAuthenticatedEmitter: Subject<boolean> = new Subject();
19+
public isAuthenticatedEmitter: EventEmitter<boolean> = new EventEmitter();
2020

2121
constructor(
2222
private http: HttpClient,
@@ -31,13 +31,12 @@ export class AuthService {
3131
}
3232

3333
isAuthenticated(): boolean {
34-
const isAuth = (this.userActive) ? true : false;
35-
this.emitUserAuthenticated(isAuth);
36-
return isAuth;
34+
return (this.userActive) ? true : false;
3735
}
3836

39-
emitUserAuthenticated(isAuth: boolean): void {
40-
this.isAuthenticatedEmitter.next(isAuth);
37+
showModalAuth(): void {
38+
const isAuth: boolean = this.userActive ? true : false;
39+
this.isAuthenticatedEmitter.emit(isAuth);
4140
}
4241

4342
get getUserActive(): User {
@@ -48,6 +47,7 @@ export class AuthService {
4847
const url = `${base_url}/auth/login`;
4948
return this.http.post<IResponseLogin>(url, data).pipe(map(resp => {
5049
this.setUserActiveInfo(resp);
50+
this.isAuthenticatedEmitter.emit(true);
5151
return resp;
5252
}));
5353
}
@@ -56,7 +56,6 @@ export class AuthService {
5656
const url = `${base_url}/auth/renew`;
5757
return this.http.get<IResponseLogin>(url, this.headers).pipe(map(resp => {
5858
this.setUserActiveInfo(resp);
59-
console.log(resp);
6059
return true;
6160
}), catchError(err => of(false)));
6261
}
@@ -65,7 +64,7 @@ export class AuthService {
6564
Storage.deleteSessionStorage('x-token');
6665
Storage.saveSessionStorage('x-token', resp.token);
6766
this.userActive = resp.user;
68-
this.emitUserAuthenticated(true);
67+
this.showModalAuth();
6968
}
7069

7170
}

src/app/features/features.component.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
}
99

1010
.wrapper .container {
11-
padding: 0.8rem 1rem;
1211
min-height: 100vh;
13-
width: 100%;
1412
margin-left: 250px;
1513
width: auto;
1614
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<div class="wrapper">
1+
<div class="wrapper" *ngIf="!isLoading">
22
<app-sidebar></app-sidebar>
33
<div class="container">
44
<router-outlet></router-outlet>
55
</div>
66
</div>
77

8-
<app-auth></app-auth>
8+
<app-auth></app-auth>
9+
<app-button-top></app-button-top>

src/app/features/features.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { AuthService } from '@services/auth.service';
23

34
@Component({
45
selector: 'app-features',
@@ -7,6 +8,14 @@ import { Component, OnInit } from '@angular/core';
78
})
89
export class FeaturesComponent implements OnInit {
910

11+
public isLoading: boolean = true;
12+
13+
constructor(authService: AuthService) {
14+
authService.validateToken().subscribe(() => {
15+
this.isLoading = false;
16+
});
17+
}
18+
1019
ngOnInit() {}
1120

1221
}

src/app/features/feed/feed.routing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ const routes: Routes = [
2323
],
2424
exports: [
2525
RouterModule
26-
]
26+
],
2727
})
2828
export class UsersRoutingModule {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.saved {
2+
max-width: calc(100% - 300px);
3+
}
4+
5+
@media (max-width: 900px) {
6+
.saved {
7+
max-width: 100%;
8+
}
9+
}

0 commit comments

Comments
 (0)