Added image fullscreen modals and style updates
This commit is contained in:
1 parent
659ab2a975
commit
5bbadfef1c
7 files changed
+227
-54
No files matched your search
@@ -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',
|
||||
})
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,47 +14,19 @@
|
||||
<button class="ko-fi-btn">Commission me on Ko-Fi</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="portfolio-gallery">
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design1.png" alt="Design 1">
|
||||
<p>Abstract Background</p>
|
||||
<div class="portfolio-gallery" [@staggerGallery]>
|
||||
<div class="gallery-item" *ngFor="let item of galleryItems" (click)="openModal(item)">
|
||||
<img [src]="item.src" [alt]="item.alt">
|
||||
<p>{{ item.label }}</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design2.png" alt="Design 2">
|
||||
<p>Profile Picture Design</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design3.png" alt="Design 3">
|
||||
<p>Pixelart Canvas</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design4.png" alt="Design 4">
|
||||
<p>Profile Picture Design 2</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design5.png" alt="Design 5">
|
||||
<p>Social Media Banner</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design6.png" alt="Design 6">
|
||||
<p>Logo Design</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<img src="/assets/design7.png" alt="Design 6">
|
||||
<p>Clipart Design</p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<a href="https://github.com/itzMiney/itzmineydev">
|
||||
<img src="https://opengraph.githubassets.com/1/itzMiney/itzmineydev" alt="Frontend">
|
||||
<p>itzMiney.dev Frontend</p>
|
||||
</a>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<a href="https://github.com/Hideout-Codeworks/DoritoBot">
|
||||
<img src="https://opengraph.githubassets.com/1/Hideout-Codeworks/DoritoBot" alt="DoritoBot">
|
||||
<p>DoritoBot</p>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal-backdrop" *ngIf="showModal" (click)="closeModal()">
|
||||
<div class="modal-content" (click)="$event.stopPropagation()">
|
||||
<img [src]="selectedItem?.src" [alt]="selectedItem?.alt">
|
||||
<h2>{{ selectedItem?.label }}</h2>
|
||||
<button (click)="closeModal()">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,60 @@
|
||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||
import {VantaBackgroundService} from '../shared/services/vanta-background.service';
|
||||
import {DeviceDetectorService} from '../shared/services/device-detector.service';
|
||||
import {isPlatformBrowser, NgStyle} from '@angular/common';
|
||||
import {CommonModule, isPlatformBrowser, NgStyle} from '@angular/common';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {AudioPlayerComponent} from '../shared/audio-player/audio-player.component';
|
||||
import {TranslatePipe} from '@ngx-translate/core';
|
||||
import {animate, stagger, style, transition, trigger, query} from '@angular/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'app-portfolio',
|
||||
imports: [
|
||||
NgStyle,
|
||||
AudioPlayerComponent,
|
||||
TranslatePipe
|
||||
TranslatePipe,
|
||||
CommonModule
|
||||
],
|
||||
templateUrl: './portfolio.component.html',
|
||||
styleUrl: './portfolio.component.css'
|
||||
styleUrl: './portfolio.component.css',
|
||||
animations: [
|
||||
trigger('fadeInOut', [
|
||||
transition(':enter', [
|
||||
style({ opacity: 0, transform: 'translateY(20px)' }),
|
||||
animate('0.5s ease-out', style({ opacity: 1, transform: 'translateY(0)' }))
|
||||
]),
|
||||
transition(':leave', [
|
||||
animate('0.3s ease-in', style({ opacity: 0, transform: 'translateY(20px)' }))
|
||||
])
|
||||
]),
|
||||
trigger('staggerGallery', [
|
||||
transition(':enter', [
|
||||
query('.gallery-item', [
|
||||
style({ opacity: 0, transform: 'translateY(20px)' }),
|
||||
stagger(100, [
|
||||
animate('0.5s ease-out', style({ opacity: 1, transform: 'translateY(0)' }))
|
||||
])
|
||||
], {
|
||||
optional: true
|
||||
})
|
||||
])
|
||||
])
|
||||
]
|
||||
})
|
||||
export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
galleryItems = [
|
||||
{ src: '/assets/design1.png', alt: 'Design 1', label: 'Abstract Background' },
|
||||
{ src: '/assets/design2.png', alt: 'Design 2', label: 'Profile Picture Design' },
|
||||
{ src: '/assets/design3.png', alt: 'Design 3', label: 'Pixelart Canvas' },
|
||||
{ src: '/assets/design4.png', alt: 'Design 4', label: 'Profile Picture Design 2' },
|
||||
{ src: '/assets/design5.png', alt: 'Design 5', label: 'Social Media Banner' },
|
||||
{ src: '/assets/design6.png', alt: 'Design 6', label: 'Logo Design' },
|
||||
{ src: '/assets/design7.png', alt: 'Design 7', label: 'Clipart Design' },
|
||||
{ src: 'https://opengraph.githubassets.com/1/itzMiney/itzmineydev', alt: 'Frontend', label: 'itzMiney.dev Frontend' },
|
||||
{ src: 'https://opengraph.githubassets.com/1/Hideout-Codeworks/DoritoBot', alt: 'DoritoBot', label: 'DoritoBot' },
|
||||
];
|
||||
selectedItem: any = null;
|
||||
showModal = false;
|
||||
private readonly elementId = 'vanta-portfolio-bg';
|
||||
isMobile: boolean = false;
|
||||
constructor(
|
||||
@@ -51,4 +89,14 @@ export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
// Update the minHeight and minWidth when the window is resized
|
||||
this.vantaService.resizeVanta(this.elementId);
|
||||
}
|
||||
|
||||
openModal(item: any) {
|
||||
this.selectedItem = item;
|
||||
this.showModal = true;
|
||||
}
|
||||
|
||||
closeModal() {
|
||||
this.selectedItem = null;
|
||||
this.showModal = false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user