Skip to content

Commit ddd65db

Browse files
committed
dialogs follow extended, settings created
1 parent 18b93da commit ddd65db

13 files changed

+318
-125
lines changed

angular-primeng-app/src/app/components/header/header.component.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ <h1>{{ blogName }}</h1>
66
</a>
77
<div class="controls">
88
<app-search-dialog [blogId]="blogId"></app-search-dialog>
9+
<app-settings-dialog></app-settings-dialog>
910
<p-inputSwitch [(ngModel)]="checked" (click)="onThemeChange(checked ? 'dark' : 'light')" id="theme-switch"></p-inputSwitch>
1011
</div>
1112
</div>
@@ -27,7 +28,7 @@ <h1>{{ blogName }}</h1>
2728
</div>
2829
</div>
2930
<div class="follow">
30-
<p-button (click)="showDialog()" label="Follow" [raised]="true"></p-button>
31+
<app-follow-dialog></app-follow-dialog>
3132
</div>
3233
</div>
3334
<div class="toolbar-row">
@@ -38,12 +39,3 @@ <h1>{{ blogName }}</h1>
3839
</div>
3940
</div>
4041
</p-toolbar>
41-
42-
<p-dialog [(visible)]="visible" [style]="{width: '27vw'}">
43-
<div class="logo-wrapper">
44-
<img class="logo" src="/assets/images/anguhashblog-logo-purple-bgr.jpg" alt="">
45-
</div>
46-
<h3>Hey, 👋 sign up or sign in to interact.</h3>
47-
<a class="button" href="https://hashnode.com/" target="_blank" rel="noopener noreferrer"><img src="/assets/images/hashnode-logo-white.png" alt="Sign in">Sign in with Hashnode</a>
48-
<p>This blog is powered by <a class="link" href="https://hashnode.com/" target="_blank" rel="noopener noreferrer">Hashnode</a>. To interact with the content on this blog, please log in through Hashnode.</p>
49-
</p-dialog>

angular-primeng-app/src/app/components/header/header.component.scss

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -64,59 +64,8 @@ p-toolbar {
6464
}
6565
}
6666

67-
p-dialog {
68-
h3 {
69-
font-size: 1.1rem;
70-
font-weight: 400;
71-
text-align: center;
72-
}
73-
74-
.logo-wrapper {
75-
display: flex;
76-
align-items: center;
77-
justify-content: center;
78-
79-
.logo {
80-
width: 5rem;
81-
height: 5rem;
82-
margin: 1rem;
83-
border-radius: 50%;
84-
}
85-
}
86-
87-
.button {
88-
display: flex;
89-
align-items: center;
90-
justify-content: center;
91-
background-color: #2563eb;
92-
color: #fff;
93-
font-size: 1.1rem;
94-
padding: 0.7rem 3rem;
95-
margin: 2rem 1rem;
96-
border: none;
97-
border-radius: 3rem;
98-
99-
img {
100-
width: 1.5rem;
101-
height: 1.5rem;
102-
margin-right: 0.5rem;
103-
}
104-
}
105-
106-
.link {
107-
color: #2563eb;
108-
font-size: 0.8.5rem;
109-
margin: 0;
110-
}
111-
112-
p {
113-
font-size: 0.8rem;
114-
text-align: center;
115-
}
116-
}
117-
11867
.controls {
11968
display: flex;
12069
align-items: center;
121-
gap: 10px;
70+
gap: 0.5rem;
12271
}

angular-primeng-app/src/app/components/header/header.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ import { ToolbarModule } from "primeng/toolbar";
1313
import { ButtonModule } from "primeng/button";
1414
import { InputSwitchModule } from "primeng/inputswitch";
1515
import { DialogModule } from "primeng/dialog";
16+
import { SettingsDialogComponent } from "../../partials/settings-dialog/settings-dialog.component";
17+
import { FollowDialogComponent } from "../../partials/follow-dialog/follow-dialog.component";
1618

1719
@Component({
1820
selector: "app-header",
1921
standalone: true,
2022
imports: [
2123
AsyncPipe,
2224
SearchDialogComponent,
25+
SettingsDialogComponent,
26+
FollowDialogComponent,
2327
ButtonModule,
2428
FormsModule,
2529
InputSwitchModule,
@@ -87,10 +91,6 @@ export class HeaderComponent implements OnInit, OnDestroy {
8791
this.themeService.setTheme(theme);
8892
}
8993

90-
showDialog() {
91-
this.visible = true;
92-
}
93-
9494
ngOnDestroy(): void {
9595
this.querySubscription?.unsubscribe();
9696
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p-button (click)="showDialog()" label="Follow" [raised]="true"></p-button>
2+
3+
<p-dialog [(visible)]="visible" [style]="{width: '27vw'}">
4+
<div class="logo-wrapper">
5+
<img class="logo" src="/assets/images/anguhashblog-logo-purple-bgr.jpg" alt="">
6+
</div>
7+
<h3>Hey, 👋 sign up or sign in to interact.</h3>
8+
<a class="button" href="https://hashnode.com/" target="_blank" rel="noopener noreferrer"><img src="/assets/images/hashnode-logo-white.png" alt="Sign in">Sign in with Hashnode</a>
9+
<p>This blog is powered by <a class="link" href="https://hashnode.com/" target="_blank" rel="noopener noreferrer">Hashnode</a>. To interact with the content on this blog, please log in through Hashnode.</p>
10+
</p-dialog>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
p-dialog {
2+
h3 {
3+
font-size: 1.1rem;
4+
font-weight: 400;
5+
text-align: center;
6+
}
7+
8+
.logo-wrapper {
9+
display: flex;
10+
align-items: center;
11+
justify-content: center;
12+
13+
.logo {
14+
width: 5rem;
15+
height: 5rem;
16+
margin: 1rem;
17+
border-radius: 50%;
18+
}
19+
}
20+
21+
.button {
22+
display: flex;
23+
align-items: center;
24+
justify-content: center;
25+
background-color: #2563eb;
26+
color: #fff;
27+
font-size: 1.1rem;
28+
padding: 0.7rem 3rem;
29+
margin: 2rem 1rem;
30+
border: none;
31+
border-radius: 3rem;
32+
33+
img {
34+
width: 1.5rem;
35+
height: 1.5rem;
36+
margin-right: 0.5rem;
37+
}
38+
}
39+
40+
.link {
41+
color: #2563eb;
42+
font-size: 0.8.5rem;
43+
margin: 0;
44+
}
45+
46+
p {
47+
font-size: 0.8rem;
48+
text-align: center;
49+
}
50+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { FollowDialogComponent } from './follow-dialog.component';
4+
5+
describe('FollowDialogComponent', () => {
6+
let component: FollowDialogComponent;
7+
let fixture: ComponentFixture<FollowDialogComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [FollowDialogComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(FollowDialogComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component } from '@angular/core';
2+
import { ButtonModule } from 'primeng/button';
3+
import { DialogModule } from 'primeng/dialog';
4+
5+
@Component({
6+
selector: 'app-follow-dialog',
7+
standalone: true,
8+
imports: [DialogModule, ButtonModule],
9+
templateUrl: './follow-dialog.component.html',
10+
styleUrl: './follow-dialog.component.scss'
11+
})
12+
export class FollowDialogComponent {
13+
visible: boolean = false;
14+
15+
showDialog() {
16+
this.visible = true;
17+
}
18+
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
<p-button class="transparent-button search-button" icon="pi pi-search"
2-
[text]="true" [rounded]="true" (click)="showDialog()"></p-button>
1+
<p-button class="transparent-button search-button" icon="pi pi-search" [rounded]="true" [text]="true" [raised]="true"
2+
(click)="showDialog()"></p-button>
33

44
<p-dialog [(visible)]="visible" position="top" [modal]="true"
5-
[style]="{ width: '60%', marginTop: '150px', maxHeight: '70%' }" [draggable]="false"
6-
[dismissableMask]="true" header="Search posts">
5+
[style]="{ width: '60%', marginTop: '150px', maxHeight: '70%' }" [draggable]="false" [dismissableMask]="true"
6+
header="Search posts">
77

88
<span class="search-input-container p-input-icon-right">
99
@if (queryFormControl.value) {
10-
<i class="pi pi-times input-clear-icon" (click)="clearQuery()"></i>
10+
<i class="pi pi-times input-clear-icon" (click)="clearQuery()"></i>
1111
}
1212
<input class="search-input" type="text" pInputText placeholder="Start typing to search..."
13-
[formControl]="queryFormControl">
13+
[formControl]="queryFormControl">
1414
</span>
1515

1616

1717
@if (queryFormControl.value && posts.length !== 0) {
18-
@for (post of posts; track post.id) {
19-
<div class="search-result" (click)="navigateToPost(post.slug)">
20-
<div class="info-section">
21-
<h3 class="post-title">{{ post.title }}</h3>
22-
<p class="author-name post-info">{{ post.author.name }}</p>
23-
<p class="post-info">{{ post.publishedAt | date }}</p>
24-
</div>
18+
@for (post of posts; track post.id) {
19+
<div class="search-result" (click)="navigateToPost(post.slug)">
20+
<div class="info-section">
21+
<h3 class="post-title">{{ post.title }}</h3>
22+
<p class="author-name post-info">{{ post.author.name }}</p>
23+
<p class="post-info">{{ post.publishedAt | date }}</p>
24+
</div>
2525

26-
<img [src]="post.coverImage.url" [alt]="post.title + ' cover image'">
27-
</div>
28-
}
26+
<img [src]="post.coverImage.url" [alt]="post.title + ' cover image'">
27+
</div>
28+
}
2929
} @else {
30-
@if (queryFormControl.value) {
31-
<p class="no-result-text"><i class="pi pi-search search-icon"></i>No matching articles found. Try another search</p>
32-
} @else {
33-
<p class="no-result-text"><i class="pi pi-search search-icon"></i>Search articles from this blog</p>
34-
}
30+
@if (queryFormControl.value) {
31+
<p class="no-result-text"><i class="pi pi-search search-icon"></i>No matching articles found. Try another search</p>
32+
} @else {
33+
<p class="no-result-text"><i class="pi pi-search search-icon"></i>Search articles from this blog</p>
34+
}
3535
}
3636
</p-dialog>
Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, inject, Input, OnInit } from '@angular/core';
1+
import { Component, inject, Input, OnInit } from "@angular/core";
22
import { DialogModule } from "primeng/dialog";
33
import { InputTextModule } from "primeng/inputtext";
44
import { ButtonModule } from "primeng/button";
@@ -9,49 +9,50 @@ import { DatePipe } from "@angular/common";
99
import { Router } from "@angular/router";
1010

1111
@Component({
12-
selector: 'app-search-dialog',
13-
standalone: true,
14-
imports: [
15-
DialogModule,
16-
InputTextModule,
17-
ButtonModule,
18-
FormsModule,
19-
DatePipe,
20-
ReactiveFormsModule
21-
],
22-
templateUrl: './search-dialog.component.html',
23-
styleUrl: './search-dialog.component.scss'
12+
selector: "app-search-dialog",
13+
standalone: true,
14+
imports: [
15+
DialogModule,
16+
InputTextModule,
17+
ButtonModule,
18+
FormsModule,
19+
DatePipe,
20+
ReactiveFormsModule,
21+
],
22+
templateUrl: "./search-dialog.component.html",
23+
styleUrl: "./search-dialog.component.scss",
2424
})
2525
export class SearchDialogComponent implements OnInit {
26-
@Input({required: true}) blogId!: string;
26+
@Input({ required: true }) blogId!: string;
2727

28-
visible = false;
29-
posts: Post[] = [];
30-
queryFormControl = new FormControl('');
31-
blogService: BlogService = inject(BlogService);
32-
router: Router = inject(Router);
28+
visible = false;
29+
posts: Post[] = [];
30+
queryFormControl = new FormControl("");
31+
blogService: BlogService = inject(BlogService);
32+
router: Router = inject(Router);
3333

34-
ngOnInit() {
35-
this.queryFormControl.valueChanges.subscribe(query => this.searchPosts(query));
36-
}
34+
ngOnInit() {
35+
this.queryFormControl.valueChanges.subscribe((query) =>
36+
this.searchPosts(query)
37+
);
38+
}
3739

38-
showDialog() {
39-
this.visible = true;
40-
}
40+
showDialog() {
41+
this.visible = true;
42+
}
4143

42-
searchPosts(query: string | null) {
43-
this.blogService.searchPosts(this.blogId, query)
44-
.subscribe(response => {
45-
this.posts = response;
46-
});
47-
}
44+
searchPosts(query: string | null) {
45+
this.blogService.searchPosts(this.blogId, query).subscribe((response) => {
46+
this.posts = response;
47+
});
48+
}
4849

49-
navigateToPost(slug: string) {
50-
this.visible = false;
51-
this.router.navigate(['/post', slug]);
52-
}
50+
navigateToPost(slug: string) {
51+
this.visible = false;
52+
this.router.navigate(["/post", slug]);
53+
}
5354

54-
clearQuery() {
55-
this.queryFormControl.reset();
56-
}
55+
clearQuery() {
56+
this.queryFormControl.reset();
57+
}
5758
}

0 commit comments

Comments
 (0)