Some style updates

This commit is contained in:
itzMiney committed 2025-01-04 21:45:51 +01:00
1 parent 8a07431510
commit d9489d9d6b
3 files changed
+60 -5

No files matched your search

@@ -113,3 +113,31 @@ h1 {
.error-message button:hover {
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 class="height-container">
<div class="article-container" *ngIf="article; else error">
<div class="article-container" *ngIf="!loading && article; else error">
<div>
<!-- Article Title -->
<h1>{{ article.title }}</h1>
@@ -12,15 +12,19 @@
<!-- Article Metadata -->
<div class="article-meta">
<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>
</div>
</div>
</div>
</div>
<!-- Loading State-->
<div *ngIf="loading" class="loading-container">
<div class="spinner"></div>
</div>
<!-- Error Message -->
<ng-template #error>
<div class="error-message">
<div class="error-message" *ngIf="!loading && error">
<h1>404</h1>
<p>Article not found!</p>
<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 {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 {ArticleService} from '../../services/article.service';
import {ActivatedRoute} from '@angular/router';
@@ -22,7 +22,8 @@ interface Article {
selector: 'app-article-page',
imports: [
NgIf,
DatePipe
DatePipe,
NgStyle
],
templateUrl: './article-page.component.html',
styleUrl: './article-page.component.css'
@@ -32,6 +33,10 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
isMobile: boolean = false;
article: Article | undefined;
currentArticle: any;
error: boolean = false;
copied: boolean = false;
loading: boolean = true;
constructor(
private deviceService: DeviceDetectorService,
private vantaService: VantaBackgroundService,
@@ -61,20 +66,38 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
this.articleService.getArticleBySlug(slug).subscribe(
(article) => {
this.article = article;
this.loading = false;
console.log('Article found!')
},
(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() {
this.vantaService.initVanta(this.elementId, {
color: 0xac1f4e,
backgroundColor: 0x191522
});
}
ngOnDestroy() {
this.vantaService.destroyVanta(this.elementId);
if (isPlatformBrowser(this.platformId)) {