From d9489d9d6bdc42165690c75509e8cba27fc7270b Mon Sep 17 00:00:00 2001 From: itzMiney Date: Sat, 4 Jan 2025 21:45:51 +0100 Subject: [PATCH] Some style updates --- .../article-page/article-page.component.css | 28 +++++++++++++++++++ .../article-page/article-page.component.html | 10 +++++-- .../article-page/article-page.component.ts | 27 ++++++++++++++++-- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/app/blog/article-page/article-page.component.css b/src/app/blog/article-page/article-page.component.css index 4b5e398..d641e2f 100644 --- a/src/app/blog/article-page/article-page.component.css +++ b/src/app/blog/article-page/article-page.component.css @@ -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); + } +} diff --git a/src/app/blog/article-page/article-page.component.html b/src/app/blog/article-page/article-page.component.html index 9cafe53..9fee964 100644 --- a/src/app/blog/article-page/article-page.component.html +++ b/src/app/blog/article-page/article-page.component.html @@ -1,6 +1,6 @@
-
+

{{ article.title }}

@@ -12,15 +12,19 @@
+ +
+
+
-
+

404

Article not found!

diff --git a/src/app/blog/article-page/article-page.component.ts b/src/app/blog/article-page/article-page.component.ts index 774013d..26f0bc5 100644 --- a/src/app/blog/article-page/article-page.component.ts +++ b/src/app/blog/article-page/article-page.component.ts @@ -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)) {