Skip to content

Commit 78aa99e

Browse files
committed
💄 card recent new style changed
1 parent d20e0f5 commit 78aa99e

14 files changed

+122
-9
lines changed

src/app/core/guards/is-auth.guard.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class IsAuthGuard implements CanActivate {
1515
route: ActivatedRouteSnapshot,
1616
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
1717
return this.authService.validateToken().pipe(tap(isAuthenticated => {
18-
console.log({isAuthenticated});
1918
if (!isAuthenticated) {
2019
this.router.navigateByUrl('/').then(() => {
2120
this.authService.showModalAuth();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
max-width: inherit;
2424
display: flex;
2525
flex-direction: column;
26-
transform: translate(0, 8px);
26+
transform: translate(0, 1rem);
2727
}
2828

2929
.banner {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<span class="title">{{recentFeed.title | slice:0:35}}{{(recentFeed.title.length > 20)?'...':'' }}</span>
2727
<span class="writer">{{recentFeed.writer}}</span>
2828
</div>
29-
<figure>
29+
<figure *ngIf="recentFeed.image">
3030
<img [src]="recentFeed.image" alt="new title">
3131
</figure>
3232
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class FeedComponent implements OnInit {
5757
}
5858

5959
saveFeed(id: string) {
60-
if(!this.authService.isAuthenticated) {
60+
if(!this.authService.isAuthenticated()) {
6161
return this.authService.showModalAuth();
6262
}
6363
this.saveFeedSub.next(id);

src/app/features/home/components/components.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { WebsitesCardComponent } from './websites-card/websites-card.component';
66

77
@NgModule({
88
declarations: [
9-
WebsitesCardComponent
9+
WebsitesCardComponent,
1010
],
1111
imports: [
1212
CommonModule,
13-
RouterModule
13+
RouterModule,
1414
],
1515
exports: [
1616
WebsitesCardComponent,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ export class WebsitesCardComponent implements OnInit {
3636
});
3737
}
3838

39+
public handleMissingImage(event: Event) {
40+
(event.target as HTMLImageElement).style.display = 'none';
41+
}
42+
3943
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
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-news-container [recentFeed]="recentFeed" *ngIf="!isLoading" [feeds]="feeds" (moreItems)="onScroll()">
16+
</app-news-container>
1617
</div>
1718
</section>
1819
<section class="websites">

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class HomeComponent implements OnInit, OnDestroy {
2323

2424
public websites: Website[] = [];
2525
public feeds: Feed[] = [];
26+
public recentFeed: Feed;
2627

2728
private isAuthenticatedSub: Subscription;
2829

@@ -67,13 +68,25 @@ export class HomeComponent implements OnInit, OnDestroy {
6768
next: ({ feeds, websites }) => {
6869
this.feeds = feeds;
6970
this.websites = websites;
71+
this.setRecentFeed(0);
7072
},
7173
complete: () => {
7274
this.isLoading = false;
7375
}
7476
})
7577
}
7678

79+
private setRecentFeed(index: number): void {
80+
if(index < this.feeds.length) {
81+
const item = this.feeds[index];
82+
if(!item.image || item.image === '') {
83+
return this.setRecentFeed(index + 1);
84+
} else {
85+
this.recentFeed = item;
86+
}
87+
}
88+
}
89+
7790
getFeeds(): Observable<Feed[]> {
7891
return this.feedService.getFeeds(this.skip, this.limit, this.isAuthenticated).pipe(map(feeds => feeds));
7992
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.card-recent {
2+
width: 100%;
3+
height: 20rem;
4+
max-height: 20rem;
5+
position: relative;
6+
}
7+
8+
.card-recent img {
9+
transition: 0.5s;
10+
/* transition-delay: 0.4s; */
11+
/* position: absolute; */
12+
width: 100%;
13+
height: 100%;
14+
object-fit: cover;
15+
border-radius: inherit;
16+
filter: brightness(0.9);
17+
}
18+
19+
.card-recent:hover img {
20+
filter: brightness(0.7);
21+
}
22+
23+
.card-recent .title-new {
24+
position: absolute;
25+
bottom: 16px;
26+
left: 16px;
27+
font-weight: 600;
28+
text-overflow: ellipsis;
29+
overflow: hidden;
30+
display: -webkit-box !important;
31+
-webkit-line-clamp: 3;
32+
-webkit-box-orient: vertical;
33+
white-space: normal;
34+
min-height: 80px;
35+
max-height: 125px;
36+
max-width: 40rem;
37+
text-decoration: none;
38+
color: inherit;
39+
text-shadow: rgb(230, 230, 230) 2px 0px 0px,
40+
rgb(230, 230, 230) 1.75517px 0.958851px 0px,
41+
rgb(230, 230, 230) 1.0806px 1.68294px 0px,
42+
rgb(230, 230, 230) 0.141474px 1.99499px 0px,
43+
rgb(230, 230, 230) -0.832294px 1.81859px 0px,
44+
rgb(230, 230, 230) -1.60229px 1.19694px 0px,
45+
rgb(230, 230, 230) -1.97998px 0.28224px 0px,
46+
rgb(230, 230, 230) -1.87291px -0.701566px 0px,
47+
rgb(230, 230, 230) -1.30729px -1.5136px 0px,
48+
rgb(230, 230, 230) -0.421592px -1.95506px 0px,
49+
rgb(230, 230, 230) 0.567324px -1.91785px 0px,
50+
rgb(230, 230, 230) 1.41734px -1.41108px 0px,
51+
rgb(230, 230, 230) 1.92034px -0.558831px 0px;
52+
font-size: 28px;
53+
cursor: pointer;
54+
}
55+
56+
.card-recent .title-new:visited {
57+
color: inherit;
58+
}
59+
60+
.card-recent .title-new:hover {
61+
text-decoration: underline;
62+
}
63+
64+
@media (max-width: 480px) {
65+
.card-recent .title-new {
66+
font-size: 24px;
67+
}
68+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="card card-recent">
2+
<img [src]="feed.image" alt="new-image-recent">
3+
<a class="title-new" [routerLink]="['feed', feed._id]">{{feed.title}}</a>
4+
</div>

0 commit comments

Comments
 (0)