Skip to content

Commit c77eed6

Browse files
authored
Merge pull request #21
Filtering by user tag
2 parents 6ab6426 + 5af846c commit c77eed6

36 files changed

+191
-134
lines changed

src/app/app.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
.private {
2-
padding: 1rem;
3-
container-type: inline-size;
4-
}
5-
6-
.public {
7-
display: flex;
8-
align-items: center;
9-
justify-content: center;
10-
min-height: 100vh;
11-
}
12-

src/app/app.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
@if (authStatus()?.authenticated) {
2-
<main class="private">
3-
<app-nav>
4-
<router-outlet/>
5-
</app-nav>
6-
</main>
7-
} @else {
8-
<main class="public">
9-
<router-outlet/>
10-
</main>
11-
}
1+
<ng-container *ngComponentOutlet="getOutlet()"/>

src/app/app.routes.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ export const routes: Routes = [
88
{ path: '', redirectTo: 'auth', pathMatch: 'full' },
99
{ path: 'auth', component: AuthPage, data: { title: 'Authentication' } },
1010
{
11-
path: 'home',
11+
path: 'articles',
1212
loadComponent: async () => {
13-
const c = await import('./pages/home/home-page.component')
14-
return c.HomePage
13+
const c = await import('./pages/articles-page/articles-page')
14+
return c.ArticlesPage
1515
},
1616
canMatch: [authGuard],
1717
},
1818
{
1919
path: 'bookmarks',
2020
loadComponent: async () => {
21-
const c = await import('./pages/bookmarks/bookmarks')
22-
return c.Bookmarks
21+
const c = await import('./pages/bookmarks-page/bookmarks-page')
22+
return c.BookmarksPage
2323
},
2424
canMatch: [authGuard],
2525
},
@@ -35,7 +35,7 @@ export const routes: Routes = [
3535
{
3636
path: 'subscription/:subscriptionId/article/:articleId',
3737
loadComponent: async () => {
38-
const c = await import('./pages/article-page/article-page.component')
38+
const c = await import('./pages/article-page/article-page')
3939
return c.ArticlePage
4040
},
4141
data: { title: 'Article' },
@@ -44,7 +44,7 @@ export const routes: Routes = [
4444
{
4545
path: 'tags',
4646
loadComponent: async () => {
47-
const c = await import('./pages/tags/tags-page.component')
47+
const c = await import('./pages/tags-page/tags-page')
4848
return c.TagsPage
4949
},
5050
data: { title: 'Tags' },
@@ -63,6 +63,7 @@ export const routes: Routes = [
6363
path: 'status',
6464
component: StatusPage,
6565
data: { title: 'Status' },
66+
canMatch: [authGuard],
6667
},
6768
{
6869
path: '**',

src/app/app.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import { Component, inject } from '@angular/core'
2-
import { RouterOutlet } from '@angular/router'
3-
import { NavComponent } from './components/nav/nav.component'
42
import { AuthService } from './services/auth-service'
53
import { toSignal } from '@angular/core/rxjs-interop'
4+
import { PrivateOutlet } from './outlet/private-outlet/private-outlet'
5+
import { PublicOutlet } from './outlet/public-outlet/public-outlet'
6+
import { NgComponentOutlet } from '@angular/common'
67

78
@Component({
89
selector: 'app-root',
9-
imports: [RouterOutlet, NavComponent],
10+
imports: [NgComponentOutlet],
1011
templateUrl: './app.html',
1112
styleUrl: './app.css',
1213
})
1314
export class App {
1415
private readonly authService = inject(AuthService)
15-
protected readonly authStatus = toSignal(this.authService.$authStatus)
16+
private readonly authStatus = toSignal(this.authService.$authStatus)
17+
18+
getOutlet() {
19+
return this.authStatus()?.authenticated ? PrivateOutlet : PublicOutlet
20+
}
1621
}

src/app/components/login-form/login-form.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
gap: 1rem;
55
margin: 1rem 0;
66
}
7+
8+
.description {
9+
max-width: 30ch;
10+
}

src/app/components/login-form/login-form.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<form (ngSubmit)="onSubmit()">
22
<mat-card-content class="credentials">
3+
<span class="description">
4+
Login with your existing password and login.
5+
</span>
36
<mat-form-field>
47
<mat-label>Login</mat-label>
58
<input

src/app/components/login-form/login-form.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class LoginForm {
5353
.pipe(takeUntilDestroyed(this.destroyRef))
5454
.subscribe((result) => {
5555
if (result) {
56-
this.router.navigate(['/home'])
56+
this.router.navigate(['/articles'])
5757
}
5858
})
5959
}

src/app/components/nav/nav.component.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Component,
3-
DestroyRef,
4-
inject,
5-
OnInit,
6-
signal,
7-
viewChild
8-
} from '@angular/core'
1+
import { Component, DestroyRef, inject, OnInit, signal, viewChild } from '@angular/core'
92
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'
103
import { AsyncPipe } from '@angular/common'
114
import { MatToolbarModule } from '@angular/material/toolbar'
@@ -55,7 +48,7 @@ export class NavComponent implements OnInit {
5548
private router = inject(Router)
5649

5750
menuItems: { title: string; icon?: string; url: string }[] = [
58-
{ title: 'Articles', url: '/home', icon: 'library_books' },
51+
{ title: 'Articles', url: '/articles', icon: 'library_books' },
5952
{ title: 'Bookmarks', url: '/bookmarks', icon: 'bookmark' },
6053
{ title: 'Subscriptions', url: '/subscriptions', icon: 'rss_feed' },
6154
{ title: 'Tags', url: '/tags', icon: 'tag' },
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<mat-button-toggle>
2-
<mat-icon
2+
<button
3+
matIconButton
34
[class]="(display | async) === PageDisplay.Title ? 'highlighted' : undefined"
45
(click)="toggleDisplay(PageDisplay.Title)"
5-
>view_day
6-
</mat-icon>
7-
<mat-icon
6+
>
7+
<mat-icon>view_day</mat-icon>
8+
</button>
9+
<button
10+
matIconButton
811
[class]="(display | async) === PageDisplay.Short ? 'highlighted' : undefined"
912
(click)="toggleDisplay(PageDisplay.Short)"
10-
>view_agenda
11-
</mat-icon>
13+
>
14+
<mat-icon>view_agenda</mat-icon>
15+
</button>
1216
</mat-button-toggle>

src/app/components/page-display-toggle/page-display-toggle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { MatButtonToggle } from '@angular/material/button-toggle'
44
import { MatIcon } from '@angular/material/icon'
55
import { PageDisplay } from '../../entities/page/page.enums'
66
import { AsyncPipe } from '@angular/common'
7+
import { MatIconButton } from '@angular/material/button'
78

89
@Component({
910
selector: 'app-page-display-toggle',
10-
imports: [MatButtonToggle, MatIcon, MatButtonToggle, MatIcon, AsyncPipe],
11+
imports: [MatButtonToggle, MatIcon, MatButtonToggle, MatIcon, AsyncPipe, MatIconButton],
1112
templateUrl: './page-display-toggle.html',
1213
styleUrl: './page-display-toggle.css',
1314
})

0 commit comments

Comments
 (0)