Skip to content

Commit 28011e5

Browse files
committed
✨ get websites availables added
1 parent a280ddd commit 28011e5

File tree

8 files changed

+102
-64
lines changed

8 files changed

+102
-64
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3+
import { RouterModule } from '@angular/router';
4+
35
import { WebsitesCardComponent } from './websites-card/websites-card.component';
46

57
@NgModule({
68
declarations: [
79
WebsitesCardComponent
810
],
911
imports: [
10-
CommonModule
12+
CommonModule,
13+
RouterModule
1114
],
1215
exports: [
1316
WebsitesCardComponent,

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,3 @@
6868
height: 100%;
6969
border-radius: inherit;
7070
}
71-
72-
.btn-subscribe {
73-
max-width: 95px;
74-
min-width: 90px;
75-
width: fit-content;
76-
border-radius: 30px;
77-
font-weight: 500;
78-
height: 36px;
79-
}
80-
81-
.btn-following {
82-
background: transparent;
83-
border: 1px solid transparent;
84-
color: #000;
85-
border-color: var(--primary-color);
86-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
'Following' : 'Subscribe' }}</button>
1111
</div>
1212
<div class="more">
13-
<a href="">Show more...</a>
13+
<a routerLink="/websites">Show more...</a>
1414
</div>
1515
</div>

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

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
.websites-wrapper {
2-
max-width: 70%;
1+
.websites-section {
2+
display: grid;
3+
grid-template-columns: auto 300px;
4+
gap: 0.5rem;
5+
max-width: 1000px;
36
margin: 0 auto;
47
}
58

9+
.title-wrapper {
10+
position: -webkit-sticky;
11+
position: sticky;
12+
top: 0;
13+
-webkit-backdrop-filter: blur(12px);
14+
backdrop-filter: blur(12px);
15+
z-index: 99;
16+
height: 50px;
17+
}
18+
619
.title {
720
font-size: 32px;
821
font-weight: bold;
@@ -12,17 +25,20 @@
1225
display: flex;
1326
margin: 1rem 0;
1427
transition: 0.5s;
28+
padding: 1rem;
1529
}
1630

1731
.card.card-website:hover {
18-
cursor: pointer;
32+
cursor: default;
1933
box-shadow: rgb(0 0 0 / 20%) 1px 1px 24px 1px;
2034
}
2135

2236
.card.card-website figure {
23-
width: 100%;
24-
max-width: 15rem;
25-
border-radius: 10px 0 0 10px;
37+
width: 4rem;
38+
min-width: 4rem;
39+
height: 4rem;
40+
min-height: 4rem;
41+
border-radius: 50%;
2642
}
2743

2844
.card.card-website figure img {
@@ -34,48 +50,43 @@
3450

3551
.card.card-website .card-body {
3652
display: flex;
37-
padding: 1rem;
53+
padding: 0 0.5rem 0 1rem;
3854
flex-grow: 1;
3955
flex-direction: column;
56+
gap: 10px;
4057
}
4158

42-
.card-body .w-title {
59+
.card-body .website-title {
60+
display: flex;
61+
justify-content: space-between;
62+
align-items: flex-start;
63+
}
64+
65+
.card-body .website-title .title {
4366
font-size: 26px;
4467
font-weight: bold;
4568
}
4669

70+
.card-body .website-title .btn {
71+
border-radius: 40px;
72+
max-width: 100px;
73+
}
74+
4775
.card-body .w-desc {
4876
font-size: 16px;
4977
color: var(--font-color-secondary);
5078
}
5179

52-
.card-body .bottom {
53-
display: flex;
54-
align-items: flex-end;
55-
flex-grow: 1;
56-
margin-top: 1rem;
57-
}
58-
59-
.card-body .bottom .buttons {
60-
flex-wrap: wrap;
61-
display: flex;
62-
align-items: center;
63-
justify-content: space-between;
64-
width: 100%;
65-
gap: 5px;
66-
}
67-
68-
.card-body .bottom .buttons .w-link {
69-
display: flex;
70-
align-items: flex-end;
71-
text-decoration: none;
80+
.card-body .link a.w-link {
7281
color: var(--primary-color);
7382
font-size: 16px;
83+
text-decoration: none;
84+
transition: 0.5s ease;
7485
}
7586

76-
.card-body .bottom .buttons .btn {
77-
flex-grow: 1;
78-
max-width: 10rem;
87+
.card-body .link a.w-link:hover {
88+
cursor: pointer;
89+
text-decoration: underline;
7990
}
8091

8192
@media (max-width: 768px) {
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
<div class="websites-wrapper" *ngIf="websites">
1+
<div class="websites-section" *ngIf="websites">
22

3-
<span class="title">Websites availables</span>
4-
<div class="card card-website" *ngFor="let website of websites">
5-
<figure>
6-
<img [src]="website.image" alt="website-image" onerror="this.src='/assets/images/not-found-image.jpg'">
7-
</figure>
8-
<div class="card-body">
9-
<span class="w-title">{{website.name}}</span>
10-
<p class="w-desc">{{website.description}}</p>
11-
<div class="bottom">
12-
<div class="buttons">
13-
<button class="btn btn-primary">Subscribe</button>
3+
<section class="websites-wrapper">
4+
<div class="title-wrapper">
5+
<span class="title">Websites availables</span>
6+
</div>
7+
<div class="card card-website" *ngFor="let website of websites">
8+
<figure>
9+
<img [src]="website.image" alt="website-image" onerror="this.src='/assets/images/not-found-image.jpg'">
10+
</figure>
11+
<div class="card-body">
12+
<div class="website-title">
13+
<span class="title">{{website.name}}</span>
14+
<button (click)="subscribeWebsite(website._id)" [class.btn-following]="website.inUser"
15+
class="btn btn-primary btn-subscribe">{{ (website.inUser) ?
16+
'Following' : 'Subscribe' }}</button>
17+
</div>
18+
<p class="w-desc">{{website.description}}</p>
19+
<div class="link">
1420
<a [href]="website.link" target="_blank" class="w-link">View original site</a>
1521
</div>
1622
</div>
1723
</div>
18-
</div>
24+
</section>
1925
</div>

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Component, OnInit } from '@angular/core';
33
import { WebsiteService } from '@services/website.service';
44

55
import { Website } from '@models/website.model';
6+
import { AuthService } from '@services/auth.service';
7+
import { UserService } from '@services/user.service';
68

79
@Component({
810
selector: 'app-websites',
@@ -12,9 +14,12 @@ import { Website } from '@models/website.model';
1214
export class WebsitesComponent implements OnInit {
1315

1416
public websites: Website[];
17+
private isAuthenticated: boolean;
1518

1619
constructor(
17-
private websiteService: WebsiteService
20+
private websiteService: WebsiteService,
21+
private authService: AuthService,
22+
private userService: UserService
1823
) { }
1924

2025
ngOnInit(): void {
@@ -33,4 +38,16 @@ export class WebsitesComponent implements OnInit {
3338
})
3439
}
3540

41+
subscribeWebsite(id: string){
42+
this.isAuthenticated = this.authService.isAuthenticated();
43+
if(this.isAuthenticated) {
44+
this.userService.modifyPreferences(id, 'subscription').subscribe(resp => {
45+
this.websites.map(website => {
46+
if( website._id === id)
47+
website.inUser = !website.inUser;
48+
});
49+
});
50+
}
51+
}
52+
3653
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
height: 100%;
3434
width: 100%;
3535
flex-grow: 1;
36-
padding: 10px;
36+
padding: 1rem;
3737
}
3838

3939
.card.card-new .card-body .title-wrapper {
4040
display: flex;
4141
justify-content: space-between;
4242
font-size: 24px;
43+
gap: 5px;
4344
}
4445

4546
.card.card-new .card-body .title-wrapper .new-title {

src/styles.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,19 @@ input:focus-within {
172172
.error {
173173
color: var(--secondary-color);
174174
}
175+
176+
.btn-subscribe {
177+
max-width: 95px;
178+
min-width: 90px;
179+
width: fit-content;
180+
border-radius: 30px;
181+
font-weight: 500;
182+
height: 36px;
183+
}
184+
185+
.btn-following {
186+
background: transparent !important;
187+
border: 1px solid transparent !important;
188+
color: #000 !important;
189+
border-color: var(--primary-color) !important;
190+
}

0 commit comments

Comments
 (0)