Some style updates
This commit is contained in:
1 parent
8a07431510
commit
d9489d9d6b
3 files changed
+60
-5
No files matched your search
@@ -113,3 +113,31 @@ h1 {
|
|||||||
.error-message button:hover {
|
.error-message button:hover {
|
||||||
background-color: #bf9bae;
|
background-color: #bf9bae;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border: 6px solid transparent;
|
||||||
|
border-top: 6px solid #d13d71;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="vanta-article-bg"></div>
|
<div id="vanta-article-bg"></div>
|
||||||
<div class="height-container">
|
<div class="height-container">
|
||||||
<div class="article-container" *ngIf="article; else error">
|
<div class="article-container" *ngIf="!loading && article; else error">
|
||||||
<div>
|
<div>
|
||||||
<!-- Article Title -->
|
<!-- Article Title -->
|
||||||
<h1>{{ article.title }}</h1>
|
<h1>{{ article.title }}</h1>
|
||||||
@@ -12,15 +12,19 @@
|
|||||||
<!-- Article Metadata -->
|
<!-- Article Metadata -->
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<p><strong>Author:</strong> {{ article.authorName}}</p>
|
<p><strong>Author:</strong> {{ article.authorName}}</p>
|
||||||
<p><strong>Views:</strong> {{ article.views }}</p><br>
|
<p><strong>Views:</strong> {{ article.views }}</p><br><button (click)="copyLink()" [ngStyle]="{'background-color':copied ? '#22b34b' : ''}">{{ copied ? 'Copied' : 'Share' }}</button>
|
||||||
<p><strong>Created At:</strong> {{ article.createdAt | date:'MMM dd, yyyy, HH:mm' }}</p>
|
<p><strong>Created At:</strong> {{ article.createdAt | date:'MMM dd, yyyy, HH:mm' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Loading State-->
|
||||||
|
<div *ngIf="loading" class="loading-container">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
</div>
|
||||||
<!-- Error Message -->
|
<!-- Error Message -->
|
||||||
<ng-template #error>
|
<ng-template #error>
|
||||||
<div class="error-message">
|
<div class="error-message" *ngIf="!loading && error">
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<p>Article not found!</p>
|
<p>Article not found!</p>
|
||||||
<a href="/blog"><button>Back to Overview</button></a>
|
<a href="/blog"><button>Back to Overview</button></a>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||||
import {DeviceDetectorService} from '../../services/device-detector.service'
|
import {DeviceDetectorService} from '../../services/device-detector.service'
|
||||||
import {DatePipe, isPlatformBrowser, NgIf} from '@angular/common';
|
import {DatePipe, isPlatformBrowser, NgIf, NgStyle} from '@angular/common';
|
||||||
import {VantaBackgroundService} from '../../services/vanta-background.service';
|
import {VantaBackgroundService} from '../../services/vanta-background.service';
|
||||||
import {ArticleService} from '../../services/article.service';
|
import {ArticleService} from '../../services/article.service';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
@@ -22,7 +22,8 @@ interface Article {
|
|||||||
selector: 'app-article-page',
|
selector: 'app-article-page',
|
||||||
imports: [
|
imports: [
|
||||||
NgIf,
|
NgIf,
|
||||||
DatePipe
|
DatePipe,
|
||||||
|
NgStyle
|
||||||
],
|
],
|
||||||
templateUrl: './article-page.component.html',
|
templateUrl: './article-page.component.html',
|
||||||
styleUrl: './article-page.component.css'
|
styleUrl: './article-page.component.css'
|
||||||
@@ -32,6 +33,10 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
isMobile: boolean = false;
|
isMobile: boolean = false;
|
||||||
article: Article | undefined;
|
article: Article | undefined;
|
||||||
currentArticle: any;
|
currentArticle: any;
|
||||||
|
error: boolean = false;
|
||||||
|
copied: boolean = false;
|
||||||
|
|
||||||
|
loading: boolean = true;
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private vantaService: VantaBackgroundService,
|
private vantaService: VantaBackgroundService,
|
||||||
@@ -61,20 +66,38 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.articleService.getArticleBySlug(slug).subscribe(
|
this.articleService.getArticleBySlug(slug).subscribe(
|
||||||
(article) => {
|
(article) => {
|
||||||
this.article = article;
|
this.article = article;
|
||||||
|
this.loading = false;
|
||||||
console.log('Article found!')
|
console.log('Article found!')
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.error('Error fetching article:', error);
|
console.error('Error fetching article:', error);
|
||||||
|
this.loading = false;
|
||||||
|
if (error.status === 404) {
|
||||||
|
this.error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyLink() {
|
||||||
|
const slug = this.route.snapshot.paramMap.get('slug') || '';
|
||||||
|
const shareLink: string = 'https://itzminey.dev/blog/' + slug;
|
||||||
|
this.copied = true;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.copied = false;
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(shareLink).then()
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.vantaService.initVanta(this.elementId, {
|
this.vantaService.initVanta(this.elementId, {
|
||||||
color: 0xac1f4e,
|
color: 0xac1f4e,
|
||||||
backgroundColor: 0x191522
|
backgroundColor: 0x191522
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.vantaService.destroyVanta(this.elementId);
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
|||||||
Reference in new issue
Block a user