Skip to content

Commit a207afb

Browse files
committed
✨ search news added
1 parent ba56ae5 commit a207afb

23 files changed

+321
-19
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ nav .logo-details {
2121
position: relative;
2222
opacity: 1;
2323
gap: 5px;
24+
cursor: pointer;
2425
}
2526

2627
nav .logo-details img {
@@ -71,6 +72,10 @@ nav li {
7172
height: 55px;
7273
}
7374

75+
nav li.mobile {
76+
display: none;
77+
}
78+
7479
nav li .tooltip {
7580
position: absolute;
7681
top: -20px;
@@ -221,6 +226,10 @@ nav .profile {
221226
display: block;
222227
}
223228

229+
nav li.mobile {
230+
display: block;
231+
}
232+
224233
nav .logo-details {
225234
gap: 0;
226235
justify-content: center;
@@ -286,6 +295,11 @@ nav .profile {
286295
bottom: 0;
287296
justify-content: space-evenly;
288297
}
298+
299+
/* nav li {
300+
padding: 10px 0;
301+
} */
302+
289303
nav li .tooltip {
290304
display: none;
291305
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<nav class="sidebar">
2-
<div class="logo-details">
2+
<div class="logo-details " (click)="goToHome()">
33
<img src="/assets/logo.png" alt="logo" srcset="">
44
<!-- <i class='bx bx-news icon'></i> -->
55
<span class="logo_name">InfoReader</span>
@@ -19,6 +19,13 @@
1919
</a>
2020
<span class="tooltip">Explore</span>
2121
</li>
22+
<li class="mobile">
23+
<a routerLink="/search" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
24+
<i class='bx bx-search'></i>
25+
<span class="links_name">Search</span>
26+
</a>
27+
<span class="tooltip">Search</span>
28+
</li>
2229
<li>
2330
<a routerLink="/feed/saved" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
2431
<i class='bx bx-bookmark'></i>
@@ -27,7 +34,7 @@
2734
<span class="tooltip">Saved</span>
2835
</li>
2936
<li>
30-
<a routerLink="/settings" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
37+
<a routerLink="/settings" routerLinkActive="active">
3138
<i class='bx bx-cog'></i>
3239
<span class="links_name">Settings</span>
3340
</a>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
2+
import { Router } from '@angular/router';
23
import { Subscription } from 'rxjs';
34

45
import { User } from '@models/user.model';
@@ -20,6 +21,7 @@ export class SidebarComponent implements OnInit, AfterViewInit, OnDestroy {
2021

2122
constructor(
2223
private authService: AuthService,
24+
private router: Router
2325
) {
2426
this.userActive = authService.getUserActive;
2527
}
@@ -58,4 +60,8 @@ export class SidebarComponent implements OnInit, AfterViewInit, OnDestroy {
5860
this.authService.showModalAuth(to);
5961
}
6062

63+
goToHome(): void {
64+
this.router.navigate(['/']);
65+
}
66+
6167
}

src/app/core/constants/messages.constant.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ export const messages: IMessage[] = [
1111
message: 'Here you can find your news saved',
1212
imagePath: `${pathRelative}/saved.svg`,
1313
},
14+
{
15+
message: 'Sorry, we could not find any results',
16+
imagePath: `${pathRelative}/no-data.svg`
17+
}
1418
];

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class FeedService {
4242
const headers = !isAuthenticated ? {} : this.headers;
4343
return this.http.get<IResponseFeed>(url, headers)
4444
.pipe(map(resp => this.mapInUserResource(resp.feeds) as Feed[]));
45-
4645
}
4746

4847
getFeed(id: string): Observable<Feed> {
@@ -57,6 +56,11 @@ export class FeedService {
5756
.pipe(map((resp) => this.mapInUserResource(resp.feeds) as Feed[]));
5857
}
5958

59+
searchFeeds(skip = 0, limit = 10, query: string): Observable<Feed[]> {
60+
const url = `${base_url}/feed/search?skip=${skip}&limit=${limit}&q=${query}`;
61+
return this.http.get<IResponseFeed>(url).pipe(map(resp => resp.feeds));
62+
}
63+
6064
private mapInUserResource(feeds: Feed[] | Feed): Feed[] | Feed {
6165
const userActive = this.authService.getUserActive;
6266
if(userActive) {

src/app/features/features.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { WebsiteModule } from './website/website.module';
1010
import { AuthModule } from 'app/auth/auth.module';
1111
import { SharedModule } from 'app/shared/shared.module';
1212
import { HomeModule } from './home/home.module';
13+
import { SearchModule } from './search/search.module';
1314
import { SettingsModule } from './settings/settings.module';
1415

1516
@NgModule({
@@ -25,7 +26,8 @@ import { SettingsModule } from './settings/settings.module';
2526
AuthModule,
2627
HomeModule,
2728
SharedModule,
28-
SettingsModule
29+
SettingsModule,
30+
SearchModule
2931
]
3032
})
3133
export class FeaturesModule { }

src/app/features/features.routing.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const routes: Routes = [
2222
path: 'settings',
2323
component: FeaturesComponent,
2424
loadChildren: () => import('./settings/settings.routing').then(m => m.SettingsRoutingModule),
25+
},
26+
{
27+
path: 'search',
28+
component: FeaturesComponent,
29+
loadChildren: () => import('./search/search.routing').then(m => m.SearchRoutingModule),
2530
}
2631
];
2732

src/app/features/feed/pages/feed/feed.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export class FeedComponent implements OnInit {
3131
this.saveFeedSub.pipe(
3232
debounceTime(250))
3333
.subscribe((idFeed) => this.updatePreferences(idFeed)
34-
);
35-
}
34+
);
35+
}
3636

37-
ngOnInit(): void {
37+
ngOnInit(): void {
3838
this.activatedRoute.params.subscribe(({ feedID }) => this.loadData(feedID));
3939
}
4040

src/app/features/home/home.component.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
margin-top: 0.5rem;
1414
}
1515

16+
.top-search {
17+
display: flex;
18+
align-items: center;
19+
position: fixed;
20+
width: inherit;
21+
min-height: 70px;
22+
}
23+
24+
.top-search app-search-input {
25+
width: 100%;
26+
}
27+
1628
@media (max-width: 1200px) {
1729
.home-section .recently .news {
1830
grid-template-columns: repeat(1, 100%);

src/app/features/home/home.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
</div>
2020
</section>
2121
<section class="websites">
22+
<div class="top-search">
23+
<app-search-input (search)="search($event)"></app-search-input>
24+
</div>
2225
<app-card-websites-a *ngIf="isLoading"></app-card-websites-a>
2326
<app-websites-card *ngIf="!isLoading" [websites]="websites"></app-websites-card>
2427
</section>

0 commit comments

Comments
 (0)