From 5bbadfef1c843238eed0bd5edb7622aae0e95e9b Mon Sep 17 00:00:00 2001 From: itzMiney Date: Mon, 18 Aug 2025 21:40:34 +0200 Subject: [PATCH] Added image fullscreen modals and style updates --- src/app/app.component.ts | 4 +- .../article-page/article-page.component.css | 68 +++++++++++++++++ .../article-page/article-page.component.html | 6 +- .../article-page/article-page.component.ts | 46 +++++++++--- src/app/portfolio/portfolio.component.css | 55 ++++++++++++++ src/app/portfolio/portfolio.component.html | 74 ++++++------------- src/app/portfolio/portfolio.component.ts | 54 +++++++++++++- 7 files changed, 240 insertions(+), 67 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6ec4847..aa583b1 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit} from '@angular/core'; -import {NgIf} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {ActivatedRoute, Router, RouterOutlet} from '@angular/router'; import {NavbarComponent} from './shared/navbar/navbar.component'; import {MobileNavbarComponent} from './shared/mobile-navbar/mobile-navbar.component'; @@ -9,7 +9,7 @@ import {TranslateService} from '@ngx-translate/core'; @Component({ selector: 'app-root', - imports: [RouterOutlet, NavbarComponent, FooterComponent, MobileNavbarComponent, NgIf], + imports: [RouterOutlet, NavbarComponent, FooterComponent, MobileNavbarComponent, CommonModule], templateUrl: './app.component.html', styleUrl: './app.component.css', }) diff --git a/src/app/blog/article-page/article-page.component.css b/src/app/blog/article-page/article-page.component.css index d641e2f..d1fa384 100644 --- a/src/app/blog/article-page/article-page.component.css +++ b/src/app/blog/article-page/article-page.component.css @@ -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%; + } +} diff --git a/src/app/blog/article-page/article-page.component.html b/src/app/blog/article-page/article-page.component.html index ef626be..b9a3793 100644 --- a/src/app/blog/article-page/article-page.component.html +++ b/src/app/blog/article-page/article-page.component.html @@ -6,7 +6,7 @@

{{ article.title }}

-
+
@@ -17,6 +17,10 @@
+ +
diff --git a/src/app/blog/article-page/article-page.component.ts b/src/app/blog/article-page/article-page.component.ts index f0c7149..9b8ad40 100644 --- a/src/app/blog/article-page/article-page.component.ts +++ b/src/app/blog/article-page/article-page.component.ts @@ -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; + 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 = 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; + } } ); } diff --git a/src/app/portfolio/portfolio.component.css b/src/app/portfolio/portfolio.component.css index d0fcb2c..a39e7c3 100644 --- a/src/app/portfolio/portfolio.component.css +++ b/src/app/portfolio/portfolio.component.css @@ -74,6 +74,7 @@ width: 100%; border-radius: 8px; margin-bottom: 2px; + cursor: pointer; } .gallery-item:hover { @@ -117,6 +118,60 @@ color: cornflowerblue; } +.modal-backdrop { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0,0,0,0.7); + color: white; + display: flex; + justify-content: center; + align-items: center; + z-index: 9999; +} + +.modal-content { + background: transparent; + padding: 1rem; + border-radius: 8px; + max-width: 80vw; + max-height: 80vh; + text-align: center; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.modal-content img { + max-width: 100%; + max-height: 80vh; + object-fit: contain; + border-radius: 8px; +} + +.modal-content button { + background-color: #FF5C8D; + border: none; + padding: 10px 20px; + border-radius: 25px; + cursor: pointer; + color: white; + font-size: 1.1rem; + font-weight: bold; + font-family: Roboto, serif; +} + +.modal-content button:hover { + background-color: #FF3C75; +} + +.modal-content button:active { + background-color: #ef85a4; +} + hr.rounded { border: 2px solid white; width: 40px; diff --git a/src/app/portfolio/portfolio.component.html b/src/app/portfolio/portfolio.component.html index fa02d06..da6b196 100644 --- a/src/app/portfolio/portfolio.component.html +++ b/src/app/portfolio/portfolio.component.html @@ -1,61 +1,33 @@
-
-
-

{{ 'PORTF_TITLE' | translate }}

-

{{ 'PORTF_SUB' | translate }}

-
-
-
-

-
- -