Added image fullscreen modals and style updates
This commit is contained in:
1 parent
659ab2a975
commit
5bbadfef1c
7 files changed
+240
-67
No files matched your search
@@ -133,6 +133,62 @@ h1 {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
::ng-deep img {
|
||||
max-width: 900px;
|
||||
padding: 15px;
|
||||
border-radius: 35px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
::ng-deep .gallery {
|
||||
display: grid;
|
||||
max-width: 900px;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 15px;
|
||||
margin: auto;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
::ng-deep .gallery img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: 20px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
::ng-deep .modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0,0,0,0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
animation: fadeIn 0.3s ease forwards;
|
||||
z-index: 1000;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
::ng-deep .modal img {
|
||||
max-width: 80%;
|
||||
max-height: 80%;
|
||||
border-radius: 20px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scale(0.95); /* optional: slight zoom effect */
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
@@ -141,3 +197,15 @@ h1 {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
::ng-deep .gallery img {
|
||||
flex: 1 1 calc(50% - 15px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
::ng-deep .gallery img {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<h1>{{ article.title }}</h1>
|
||||
<div class="content-container">
|
||||
<!-- Article Content -->
|
||||
<div class="article-content" [innerHTML]="article.content"></div>
|
||||
<div #articleContent class="article-content" [innerHTML]="article.content"></div>
|
||||
|
||||
<a href="/blog"><button>{{ 'ARTICLE_BACK' | translate }}</button></a>
|
||||
<!-- Article Metadata -->
|
||||
@@ -17,6 +17,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal" *ngIf="selectedImage" (click)="closePreview()">
|
||||
<img [src]="selectedImage" alt="Full Preview" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Loading State-->
|
||||
<div *ngIf="loading" class="loading-container">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||
import {AfterViewInit, Component, ElementRef, Inject, OnDestroy, OnInit, PLATFORM_ID, ViewChild} from '@angular/core';
|
||||
import {DeviceDetectorService} from '../../shared/services/device-detector.service'
|
||||
import {DatePipe, isPlatformBrowser, NgIf, NgStyle} from '@angular/common';
|
||||
import {VantaBackgroundService} from '../../shared/services/vanta-background.service';
|
||||
@@ -31,6 +31,9 @@ interface Article {
|
||||
styleUrl: './article-page.component.css'
|
||||
})
|
||||
export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
@ViewChild('articleContent') articleContent!: ElementRef<HTMLDivElement>;
|
||||
selectedImage: string | null = null;
|
||||
private imagesProcessed = false;
|
||||
private readonly elementId = 'vanta-article-bg';
|
||||
isMobile: boolean = false;
|
||||
article: Article | undefined;
|
||||
@@ -98,6 +101,27 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
color: 0xac1f4e,
|
||||
backgroundColor: 0x191522
|
||||
});
|
||||
this.makeImagesClickable();
|
||||
this.imagesProcessed = true;
|
||||
}
|
||||
|
||||
private makeImagesClickable() {
|
||||
const imgs: NodeListOf<HTMLImageElement> = this.articleContent.nativeElement.querySelectorAll('img');
|
||||
imgs.forEach(img => {
|
||||
img.style.cursor = 'pointer';
|
||||
if (!img.dataset['clickable']) {
|
||||
img.addEventListener('click', () => this.openPreview(img.src));
|
||||
img.dataset['clickable'] = 'true';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openPreview(src: string) {
|
||||
this.selectedImage = src;
|
||||
}
|
||||
|
||||
closePreview() {
|
||||
this.selectedImage = null;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -114,17 +138,19 @@ export class ArticlePageComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
loadTitleBySlug(slug: string) {
|
||||
this.articleService.getArticleBySlug(slug).subscribe(
|
||||
(article) => {
|
||||
if (article) {
|
||||
this.currentArticle = article;
|
||||
this.titleService.setTitle( article.title );
|
||||
} else {
|
||||
console.warn('Article not found for slug:', slug);
|
||||
this.titleService.setTitle('Article Not Found');
|
||||
}
|
||||
this.article = article;
|
||||
this.loading = false;
|
||||
|
||||
setTimeout(() => this.makeImagesClickable(), 0);
|
||||
|
||||
console.log('Article found!')
|
||||
},
|
||||
(error) => {
|
||||
console.error('Failed to load article title', error);
|
||||
this.titleService.setTitle('Error loading Article');
|
||||
console.error('Error fetching article:', error);
|
||||
this.loading = false;
|
||||
if (error.status === 404) {
|
||||
this.error = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user