Skip to content

Commit 99e8415

Browse files
authored
Merge pull request #28 from marcode24/dev
✨ Update models and components with additional properties for feeds a…
2 parents a4ba228 + dbb5104 commit 99e8415

17 files changed

+130
-107
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ nav {
88
display: flex;
99
flex-direction: column;
1010
align-items: flex-start;
11+
max-width: 260px;
1112
}
1213

1314
nav .logo-details {
@@ -138,7 +139,7 @@ nav li i {
138139
}
139140

140141
nav .profile {
141-
width: 100%;
142+
width: -webkit-fill-available;
142143
padding: 0.2rem;
143144
display: flex;
144145
flex-grow: 1;
@@ -274,6 +275,7 @@ nav .profile {
274275

275276
@media (max-width: 768px) {
276277
nav {
278+
max-width: 100%;
277279
width: 100vw !important;
278280
height: auto;
279281
bottom: 0;

src/app/core/models/feed.model.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export class Feed {
1313
public likes: number,
1414
public inUser?: boolean,
1515
public liked?: boolean,
16+
public readingTime?: number,
1617
) {}
1718
}

src/app/core/models/website.model.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export class Website {
77
public linkFeed: string,
88
public _id: string,
99
public inUser?: boolean,
10+
public feedCount?: number,
1011
) {}
1112
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export class WebsiteService {
2020
constructor(private http: HttpClient,
2121
private authService: AuthService) { }
2222

23-
getWebsites(all = false, skip = 0, limit = 5): Observable<Website[]> {
24-
const url = `${base_url}/website?all=${all}&limit=${limit}&skip=${skip}`;
23+
getWebsites({count = false, all = false, skip = 0, limit = 5}): Observable<Website[]> {
24+
const url =
25+
`${base_url}/website?all=${all}&limit=${limit}&skip=${skip}&count=${count}`;
2526
return this.http.get<IResponseWebsite>(url).pipe(map(resp => {
2627
const { websites } = resp;
2728
const userActive = this.authService.getUserActive();

src/app/features/features.component.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
max-width: 1280px;
33
margin: 0 auto;
44
display: grid;
5-
grid-template-columns: minmax(80px, 20%) 1fr;
5+
grid-template-columns: minmax(80px, 260px) 1fr;
66
}
77

88
.wrapper .container {

src/app/features/home/components/websites-card/websites-card.component.css

+32-11
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,32 @@
99
flex-direction: column;
1010
}
1111

12-
.card.card-websites .card-title {
12+
.card-title,
13+
.card.card-websites .item {
14+
padding: 0.6rem 1rem;
15+
}
16+
17+
.card-title {
1318
font-size: 20px;
1419
font-weight: bold;
15-
padding: 0.6rem 0.8rem;
1620
}
1721

1822
.card.card-websites .item {
1923
display: flex;
20-
padding: 0.5rem 0.8rem;
2124
gap: 10px;
2225
transition: 0.4s;
23-
min-height: 65px;
26+
min-height: 60px;
2427
align-items: center;
28+
justify-content: space-between;
2529
}
2630

2731
.card.card-websites a.item {
2832
text-decoration: none;
29-
font-size: 14px;
33+
font-size: 18px;
3034
font-weight: 500;
3135
color: var(--secondary-color);
36+
border-top: var(--border);
37+
justify-content: center;
3238
}
3339

3440
.card.card-websites .item:last-child {
@@ -38,23 +44,32 @@
3844
.card.card-websites .item:hover,
3945
.card.card-websites .more:hover {
4046
background-color: var(--bg-hover);
41-
cursor: pointer;
4247
}
4348

44-
.card.card-websites .item .website-name {
49+
.website-name {
4550
flex-grow: 1;
4651
font-size: 16px;
4752
font-weight: bold;
4853
white-space: nowrap;
4954
overflow: hidden;
5055
text-overflow: ellipsis;
56+
max-width: 120px;
57+
}
58+
59+
.total-feeds {
60+
font-size: 14px;
61+
color: var(--font-color-secondary);
62+
white-space: nowrap;
63+
overflow: hidden;
64+
text-overflow: ellipsis;
65+
max-width: 120px;
5166
}
5267

5368
.card.card-websites .item figure {
54-
width: 3.5rem;
55-
height: 3.5rem;
56-
min-width: 3.5rem;
57-
min-height: 3.5rem;
69+
width: 2rem;
70+
height: 2rem;
71+
min-width: 2rem;
72+
min-height: 2rem;
5873
border-radius: 50%;
5974
}
6075

@@ -64,3 +79,9 @@
6479
height: 100%;
6580
border-radius: inherit;
6681
}
82+
83+
.name-wrapper {
84+
display: flex;
85+
flex-direction: column;
86+
flex: 1;
87+
}

src/app/features/home/components/websites-card/websites-card.component.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<figure *ngIf="website.image && website.image.length > 0">
55
<img [src]="website.image" alt="website-image" onerror="this.src='/assets/images/not-found-image.jpg'">
66
</figure>
7-
<span class="website-name">{{website.name}}</span>
7+
<div class="name-wrapper">
8+
<span class="website-name">{{website.name}}</span>
9+
<span class="total-feeds">{{website.feedCount}} {{ (website.feedCount && website.feedCount > 1) ? 'feeds' : 'feed' }}</span>
10+
</div>
811
<button [class.btn-following]="website.inUser" (click)="subscribeWebsite(website._id)"
912
class="btn btn-primary btn-subscribe">{{ (website.inUser) ?
1013
'Following' : 'Subscribe' }}</button>

src/app/features/home/components/websites-card/websites-card.component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export class WebsitesCardComponent implements OnInit {
2929
}
3030
this.userService.modifyPreferences(id, 'subscription').subscribe(() => {
3131
this.websites.map(website => {
32-
if( website._id === id)
33-
website.inUser = !website.inUser;
32+
if( website._id === id) website.inUser = !website.inUser;
3433
});
3534
});
3635
}
-53
Original file line numberDiff line numberDiff line change
@@ -1,53 +0,0 @@
1-
.home-section {
2-
display: grid;
3-
grid-template-columns: 1fr minmax(300px, 20%);
4-
}
5-
6-
.home-section .websites {
7-
width: 300px;
8-
opacity: 1;
9-
}
10-
11-
.skeletons {
12-
display: flex;
13-
flex-direction: column;
14-
gap: 1rem;
15-
}
16-
17-
.news-container {
18-
margin: 1rem;
19-
}
20-
21-
.top-search {
22-
display: flex;
23-
align-items: center;
24-
width: inherit;
25-
min-height: 70px;
26-
}
27-
28-
.top-search app-search-input {
29-
width: 100%;
30-
}
31-
32-
.websites-wrapper {
33-
position: sticky;
34-
top: 0;
35-
display: flex;
36-
flex-direction: column;
37-
gap: 1rem;
38-
}
39-
40-
@media (max-width: 1200px) {
41-
.home-section .recently .news {
42-
grid-template-columns: repeat(1, 100%);
43-
}
44-
}
45-
46-
@media (max-width: 768px) {
47-
.home-section {
48-
grid-template-columns: 100%;
49-
}
50-
.home-section .websites {
51-
opacity: 0;
52-
}
53-
}

src/app/features/home/home.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class HomeComponent implements OnInit, OnDestroy {
6363
this.isLoading = true;
6464
forkJoin({
6565
feeds: this.getFeeds(),
66-
websites: this.websiteService.getWebsites(),
66+
websites: this.websiteService.getWebsites({ count: true })
6767
}).subscribe({
6868
next: ({ feeds, websites }) => {
6969
this.feeds = feeds;
Original file line numberDiff line numberDiff line change
@@ -1,25 +0,0 @@
1-
.home-section {
2-
display: grid;
3-
grid-template-columns: auto 300px;
4-
gap: 0.5rem;
5-
}
6-
7-
.home-section .websites {
8-
width: 300px;
9-
opacity: 1;
10-
}
11-
12-
@media (max-width: 1200px) {
13-
.home-section .recently .news {
14-
grid-template-columns: repeat(1, 100%);
15-
}
16-
}
17-
18-
@media (max-width: 768px) {
19-
.home-section {
20-
grid-template-columns: 100%;
21-
}
22-
.home-section .websites {
23-
opacity: 0;
24-
}
25-
}

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<section class="recently">
33
<div class="title-wrapper">
44
<span class="title-section">Explore news</span>
5-
<a class="refresh" [class.loading]="isLoading" *ngIf="getSkip >= 10" (click)="reloadData()">
5+
<a class="refresh" [class.loading]="isLoading" *ngIf="getSkip >= 10 || feeds.length < 1" (click)="reloadData()">
66
<i class="bx bx-refresh"></i>
77
</a>
88
</div>
@@ -12,11 +12,19 @@
1212
<app-card-new></app-card-new>
1313
<app-card-new></app-card-new>
1414
</div>
15-
<app-news-container *ngIf="!isLoading" [feeds]="feeds" (moreItems)="onScroll()"></app-news-container>
15+
<app-no-feeds *ngIf="!isLoading && feeds.length < 1" [messageIndex]="0"></app-no-feeds>
16+
<app-news-container *ngIf="!isLoading && feeds.length > 0" [feeds]="feeds"
17+
(moreItems)="onScroll()">
18+
</app-news-container>
1619
</div>
1720
</section>
1821
<section class="websites">
19-
<app-card-websites-a *ngIf="isLoading"></app-card-websites-a>
20-
<app-websites-card *ngIf="!isLoading" [websites]="websites"></app-websites-card>
22+
<div class="websites-wrapper">
23+
<div class="top-search">
24+
<app-search-input (search)="search($event)"></app-search-input>
25+
</div>
26+
<app-card-websites-a *ngIf="isLoading"></app-card-websites-a>
27+
<app-websites-card *ngIf="!isLoading" [websites]="websites"></app-websites-card>
28+
</div>
2129
</section>
22-
</div>
30+
</div>

src/app/features/home/pages/explore/explore.component.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { Router } from '@angular/router';
23

34
import { Observable, Subject, debounceTime, forkJoin, map } from 'rxjs';
45

@@ -25,7 +26,8 @@ export class ExploreComponent implements OnInit {
2526

2627
constructor(
2728
private websiteService: WebsiteService,
28-
private feedService: FeedService
29+
private feedService: FeedService,
30+
private router: Router
2931
) {
3032
this.loadingNews.pipe(debounceTime(2000)).subscribe(() => this.getDataInitial());
3133
}
@@ -41,7 +43,7 @@ export class ExploreComponent implements OnInit {
4143
this.isLoading = true;
4244
forkJoin({
4345
feeds: this.getFeeds(),
44-
websites: this.websiteService.getWebsites(),
46+
websites: this.websiteService.getWebsites({}),
4547
}).subscribe({
4648
next: ({ feeds, websites }) => {
4749
this.feeds = feeds;
@@ -72,4 +74,8 @@ export class ExploreComponent implements OnInit {
7274
return this.skip;
7375
}
7476

77+
search(value: string): void {
78+
this.router.navigate(['/search'], { queryParams: { q: value } });
79+
}
80+
7581
}

src/app/features/website/pages/websites/websites.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class WebsitesComponent implements OnInit, OnDestroy {
4444
}
4545

4646
getWebsites(): void {
47-
this.websiteService.getWebsites(true).subscribe({
47+
this.websiteService.getWebsites({ all: true }).subscribe({
4848
next: (websites) => {
4949
this.websites = websites;
5050
},

src/app/shared/news-container/news-container.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="details">
1515
<p class="date"> {{ feed.pubDate | date: 'dd-MM-yyyy' }} </p>
1616
<p class="bull">&bull;</p>
17-
<p class="read"> {{ 10 }} min </p>
17+
<p class="read"> {{ feed.readingTime! <= 0 ? 1 : feed.readingTime }} min read</p>
1818
</div>
1919
<div class="options">
2020
<div class="option default">

src/app/shared/search-input/search-input.component.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ input.icon {
1616
}
1717

1818
input.icon ~ i {
19-
top: 15px;
19+
top: 12px;
2020
left: 20px;
2121
position: absolute;
2222
color: #71767b;
2323
transition: 0.2s;
24+
font-size: 22px;
2425
}
2526

2627
input.icon:focus ~ i {

0 commit comments

Comments
 (0)