Optimized code (significantly)
This commit is contained in:
1 parent
5fbb41c477
commit
a4b69c5b9a
26 files changed
+299
-397
No files matched your search
Generated
+7
@@ -28,6 +28,7 @@
|
|||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"three": "^0.171.0",
|
"three": "^0.171.0",
|
||||||
|
"three.js": "^0.77.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"vanta": "^0.5.24",
|
"vanta": "^0.5.24",
|
||||||
"zone.js": "~0.15.0"
|
"zone.js": "~0.15.0"
|
||||||
@@ -13506,6 +13507,12 @@
|
|||||||
"integrity": "sha512-Y/lAXPaKZPcEdkKjh0JOAHVv8OOnv/NDJqm0wjfCzyQmfKxV7zvkwsnBgPBKTzJHToSOhRGQAGbPJObT59B/PQ==",
|
"integrity": "sha512-Y/lAXPaKZPcEdkKjh0JOAHVv8OOnv/NDJqm0wjfCzyQmfKxV7zvkwsnBgPBKTzJHToSOhRGQAGbPJObT59B/PQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/three.js": {
|
||||||
|
"version": "0.77.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/three.js/-/three.js-0.77.0.tgz",
|
||||||
|
"integrity": "sha512-ouSy18ZEiwz+aEsN5psLd7hftf08cyVw/zV1XFYjPhDDnUwIr+bEGryJAy6z3VbSJjuIQUbbM8FtWMZjGdqD+w==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/thunky": {
|
"node_modules/thunky": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"three": "^0.171.0",
|
"three": "^0.171.0",
|
||||||
|
"three.js": "^0.77.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"vanta": "^0.5.24",
|
"vanta": "^0.5.24",
|
||||||
"zone.js": "~0.15.0"
|
"zone.js": "~0.15.0"
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#vanta-about-bg {
|
#vanta-about-bg {
|
||||||
transition: opacity 0.3s ease-in-out;
|
animation: fadeIn 1s ease-out;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject} from '@angular/core';
|
import {AfterViewInit, Component, OnDestroy, OnInit, ChangeDetectorRef, PLATFORM_ID, Inject} from '@angular/core';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import {isPlatformBrowser, NgIf} from '@angular/common';
|
||||||
import {NgIf} from '@angular/common';
|
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||||
import { Meta, Title } from '@angular/platform-browser';
|
import {DeviceDetectorService} from '../services/device-detector.service';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
|
||||||
import { PLATFORM_ID } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-about',
|
selector: 'app-about',
|
||||||
@@ -15,84 +12,31 @@ import { PLATFORM_ID } from '@angular/core';
|
|||||||
styleUrls: ['./about.component.css']
|
styleUrls: ['./about.component.css']
|
||||||
})
|
})
|
||||||
export class AboutComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class AboutComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
constructor(
|
private readonly elementId = 'vanta-about-bg';
|
||||||
private deviceService: DeviceDetectorService,
|
|
||||||
private meta: Meta,
|
|
||||||
private title: Title,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
isMobile: boolean = false;
|
isMobile: boolean = false;
|
||||||
private vantaEffect: any;
|
constructor(
|
||||||
|
private vantaService: VantaBackgroundService,
|
||||||
|
private deviceService: DeviceDetectorService,
|
||||||
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isMobile = this.deviceService.isMobile();
|
this.isMobile = this.deviceService.isMobile;
|
||||||
const metaData = this.route.snapshot.data['meta'];
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (metaData?.title) {
|
window.addEventListener('resize', this.onResize.bind(this));
|
||||||
this.title.setTitle(metaData.title);
|
|
||||||
}
|
|
||||||
if (metaData?.description) {
|
|
||||||
this.meta.updateTag({ name: 'description', content: metaData.description });
|
|
||||||
}
|
|
||||||
if (metaData?.image) {
|
|
||||||
this.meta.updateTag({ property: 'og:image', content: metaData.image });
|
|
||||||
}
|
|
||||||
if (metaData?.url) {
|
|
||||||
this.meta.updateTag({ property: 'og:url', content: metaData.url });
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', this.onResize.bind(this)); // Add resize listener for responsiveness
|
|
||||||
|
|
||||||
const bgElement = document.getElementById('vanta-about-bg');
|
|
||||||
if (bgElement) {
|
|
||||||
bgElement.style.position = 'fixed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.vantaService.initVanta(this.elementId, {});
|
||||||
// Initialize VANTA effect only in the browser
|
|
||||||
this.initVanta();
|
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (this.vantaEffect) {
|
window.removeEventListener('resize', this.onResize);
|
||||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
|
||||||
}
|
|
||||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initVanta() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
|
||||||
this.vantaEffect = window.VANTA.NET({
|
|
||||||
el: '#vanta-about-bg',
|
|
||||||
mouseControls: false,
|
|
||||||
touchControls: false,
|
|
||||||
gyroControls: false,
|
|
||||||
scale: 1.00,
|
|
||||||
scaleMobile: 1.00,
|
|
||||||
points: 20.00,
|
|
||||||
maxDistance: 25.00,
|
|
||||||
spacing: 18.00,
|
|
||||||
showDots: false,
|
|
||||||
minWidth: window.innerWidth,
|
|
||||||
minHeight: window.innerHeight,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
// Update the minHeight and minWidth when the window is resized
|
this.vantaService.resizeVanta(this.elementId);
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeVanta() {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
// Trigger the resize on the vanta effect
|
|
||||||
this.vantaEffect.resize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import { ArticleService } from '../article.service';
|
import {ArticleService} from '../services/article.service';
|
||||||
import {NgFor, NgIf} from '@angular/common';
|
import {NgFor, NgIf} from '@angular/common';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import {Observer} from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin',
|
selector: 'app-admin',
|
||||||
@@ -10,8 +10,7 @@ import { HttpClientModule } from '@angular/common/http';
|
|||||||
styleUrls: ['./admin.component.css'],
|
styleUrls: ['./admin.component.css'],
|
||||||
imports: [
|
imports: [
|
||||||
NgIf,
|
NgIf,
|
||||||
NgFor,
|
NgFor
|
||||||
HttpClientModule
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AdminComponent implements OnInit {
|
export class AdminComponent implements OnInit {
|
||||||
@@ -28,19 +27,35 @@ export class AdminComponent implements OnInit {
|
|||||||
fetchArticles() {
|
fetchArticles() {
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
if (!token) {
|
if (!token) {
|
||||||
this.router.navigate(['/login']); // Redirect to login if not logged in
|
this.router.navigate(['/login']).then(
|
||||||
|
(success) => {
|
||||||
|
if (success) {
|
||||||
|
console.log('Navigation to login succeeded');
|
||||||
|
} else {
|
||||||
|
console.warn('Navigation to login failed');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Navigation error:', error);
|
||||||
|
}
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.articleService.getArticles(token).subscribe(
|
const articleObserver: Observer<any> = {
|
||||||
(data) => {
|
next: (data) => {
|
||||||
this.articles = data;
|
this.articles = data;
|
||||||
this.noArticles = this.articles.length === 0;
|
this.noArticles = this.articles.length === 0;
|
||||||
},
|
},
|
||||||
(error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load articles', error);
|
console.error('Failed to load articles', error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
console.log('Article loading complete');
|
||||||
}
|
}
|
||||||
);
|
};
|
||||||
|
|
||||||
|
this.articleService.getArticles(token).subscribe(articleObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
createArticle() {
|
createArticle() {
|
||||||
@@ -61,6 +76,17 @@ export class AdminComponent implements OnInit {
|
|||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
this.router.navigate(['/login']); // Redirect to login page
|
this.router.navigate(['/login']).then(
|
||||||
|
(success) => {
|
||||||
|
if (success) {
|
||||||
|
console.log('Navigation to login succeeded');
|
||||||
|
} else {
|
||||||
|
console.warn('Navigation to login failed');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Navigation error:', error);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-26
@@ -1,48 +1,35 @@
|
|||||||
import { Component, OnInit, Inject, PLATFORM_ID} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import {ActivatedRoute, NavigationEnd, Router, RouterOutlet} from '@angular/router';
|
||||||
import {RouterOutlet, ActivatedRoute, Router, NavigationEnd} from '@angular/router';
|
|
||||||
import {NavbarComponent} from './navbar/navbar.component';
|
import {NavbarComponent} from './navbar/navbar.component';
|
||||||
import {MobileNavbarComponent} from './mobile-navbar/mobile-navbar.component';
|
import {MobileNavbarComponent} from './mobile-navbar/mobile-navbar.component';
|
||||||
import {FooterComponent} from './footer/footer.component';
|
import {FooterComponent} from './footer/footer.component';
|
||||||
import { Title, Meta } from '@angular/platform-browser';
|
import {Meta, Title} from '@angular/platform-browser';
|
||||||
import {filter, map, mergeMap} from 'rxjs/operators';
|
import {filter, map, mergeMap} from 'rxjs/operators';
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
import {DeviceDetectorService} from './services/device-detector.service';
|
||||||
import {subscribe} from 'node:diagnostics_channel';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet, NavbarComponent, FooterComponent, MobileNavbarComponent, NgIf],
|
imports: [RouterOutlet, NavbarComponent, FooterComponent, MobileNavbarComponent, NgIf],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.css'
|
styleUrl: './app.component.css',
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
isMobile: boolean;
|
isMobile: boolean = false;
|
||||||
|
|
||||||
showNavbar: boolean = true;
|
showNavbar: boolean = true;
|
||||||
showFooter: boolean = true;
|
showFooter: boolean = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: DeviceDetectorService,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private activatedRoute: ActivatedRoute,
|
private activatedRoute: ActivatedRoute,
|
||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
private metaService: Meta,
|
private metaService: Meta,
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
private deviceService: DeviceDetectorService,
|
||||||
) {
|
) {}
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Use client-side logic to determine if it's mobile
|
|
||||||
this.isMobile = window.innerWidth <= 768; // Adjust breakpoint as needed
|
|
||||||
} else {
|
|
||||||
// Default fallback for SSR
|
|
||||||
this.isMobile = false; // Or any other logic to handle SSR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.isMobile = this.deviceService.isMobile;
|
||||||
this.isMobile = window.innerWidth <= 768;
|
|
||||||
}
|
|
||||||
this.router.events
|
this.router.events
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(event => event instanceof NavigationEnd),
|
filter(event => event instanceof NavigationEnd),
|
||||||
@@ -56,7 +43,7 @@ export class AppComponent implements OnInit {
|
|||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
const meta = data['meta'] || {};
|
const meta = data['meta'] || {};
|
||||||
if (this.router.url === '/about') {
|
if (this.router.url === '/about') {
|
||||||
// fallback meta
|
// fallback meta data
|
||||||
meta.title = meta.title || 'itzMiney\'s Home';
|
meta.title = meta.title || 'itzMiney\'s Home';
|
||||||
meta.description = meta.description || 'Welcome to itzMiney\'s Homepage! Here you can find my portfolio and other cool stuff.';
|
meta.description = meta.description || 'Welcome to itzMiney\'s Homepage! Here you can find my portfolio and other cool stuff.';
|
||||||
meta.image = meta.image || 'https://itzminey.dev/assets/ogimg.png';
|
meta.image = meta.image || 'https://itzminey.dev/assets/ogimg.png';
|
||||||
@@ -66,7 +53,6 @@ export class AppComponent implements OnInit {
|
|||||||
this.updateMetaTags(meta);
|
this.updateMetaTags(meta);
|
||||||
this.checkRoute();
|
this.checkRoute();
|
||||||
});
|
});
|
||||||
this.checkRoute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMetaTags(meta: { title?: string; description?: string; image?: string; url?: string; color?: string }) {
|
updateMetaTags(meta: { title?: string; description?: string; image?: string; url?: string; color?: string }) {
|
||||||
@@ -92,7 +78,7 @@ export class AppComponent implements OnInit {
|
|||||||
checkRoute() {
|
checkRoute() {
|
||||||
const currentRoute = this.activatedRoute.snapshot.firstChild?.routeConfig?.path;
|
const currentRoute = this.activatedRoute.snapshot.firstChild?.routeConfig?.path;
|
||||||
|
|
||||||
// Hide navbar and footer on admin route
|
|
||||||
switch (currentRoute) {
|
switch (currentRoute) {
|
||||||
case 'admin': {
|
case 'admin': {
|
||||||
this.showNavbar = false;
|
this.showNavbar = false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
import {ApplicationConfig, mergeApplicationConfig} from '@angular/core';
|
||||||
import {provideServerRendering} from '@angular/platform-server';
|
import {provideServerRendering} from '@angular/platform-server';
|
||||||
import {provideServerRoutesConfig} from '@angular/ssr';
|
import {provideServerRoutesConfig} from '@angular/ssr';
|
||||||
import {appConfig} from './app.config';
|
import {appConfig} from './app.config';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { routes } from './app.routes';
|
|||||||
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
|
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
|
||||||
import {provideClientHydration, withEventReplay} from '@angular/platform-browser';
|
import {provideClientHydration, withEventReplay} from '@angular/platform-browser';
|
||||||
import {provideHttpClient} from '@angular/common/http';
|
import {provideHttpClient} from '@angular/common/http';
|
||||||
import { AuthService } from './auth.service';
|
import {AuthService} from './services/auth.service';
|
||||||
import {AuthInterceptor} from './auth.interceptor';
|
import {AuthInterceptor} from './auth.interceptor';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#vanta-blog-bg {
|
#vanta-blog-bg {
|
||||||
transition: opacity 0.3s ease-in-out;
|
animation: fadeIn 1s ease-out;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject } from '@angular/core';
|
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import {DeviceDetectorService} from '../services/device-detector.service'
|
||||||
import {NgIf} from '@angular/common';
|
import {isPlatformBrowser, NgIf} from '@angular/common';
|
||||||
import {Meta, Title} from '@angular/platform-browser';
|
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
|
||||||
import { PLATFORM_ID } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-blog',
|
selector: 'app-blog',
|
||||||
@@ -15,87 +12,36 @@ import { PLATFORM_ID } from '@angular/core';
|
|||||||
styleUrl: './blog.component.css'
|
styleUrl: './blog.component.css'
|
||||||
})
|
})
|
||||||
export class BlogComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class BlogComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
private readonly elementId = 'vanta-blog-bg';
|
||||||
|
isMobile: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private meta: Meta,
|
private vantaService: VantaBackgroundService,
|
||||||
private title: Title,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
isMobile: boolean = false;
|
|
||||||
private vantaEffect: any;
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isMobile = this.deviceService.isMobile();
|
this.isMobile = this.deviceService.isMobile;
|
||||||
const metaData = this.route.snapshot.data['meta'];
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (metaData?.title) {
|
window.addEventListener('resize', this.onResize.bind(this));
|
||||||
this.title.setTitle(metaData.title);
|
|
||||||
}
|
|
||||||
if (metaData?.description) {
|
|
||||||
this.meta.updateTag({ name: 'description', content: metaData.description });
|
|
||||||
}
|
|
||||||
if (metaData?.image) {
|
|
||||||
this.meta.updateTag({ property: 'og:image', content: metaData.image });
|
|
||||||
}
|
|
||||||
if (metaData?.url) {
|
|
||||||
this.meta.updateTag({ property: 'og:url', content: metaData.url });
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', this.onResize.bind(this)); // Add resize listener for responsiveness
|
|
||||||
|
|
||||||
const bgElement = document.getElementById('vanta-blog-bg');
|
|
||||||
if (bgElement) {
|
|
||||||
bgElement.style.position = 'fixed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.vantaService.initVanta(this.elementId, {
|
||||||
// Initialize VANTA effect only in the browser
|
|
||||||
this.initVanta();
|
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ngOnDestroy() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
|
||||||
}
|
|
||||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initVanta() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
|
||||||
this.vantaEffect = window.VANTA.NET({
|
|
||||||
el: '#vanta-blog-bg',
|
|
||||||
mouseControls: false,
|
|
||||||
touchControls: false,
|
|
||||||
gyroControls: false,
|
|
||||||
scale: 1.00,
|
|
||||||
scaleMobile: 1.00,
|
|
||||||
points: 20.00,
|
|
||||||
maxDistance: 25.00,
|
|
||||||
spacing: 18.00,
|
|
||||||
showDots: false,
|
|
||||||
minWidth: window.innerWidth,
|
|
||||||
minHeight: window.innerHeight,
|
|
||||||
color: 0xac1f4e,
|
color: 0xac1f4e,
|
||||||
backgroundColor: 0x191522
|
backgroundColor: 0x191522
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
window.removeEventListener('resize', this.onResize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
// Update the minHeight and minWidth when the window is resized
|
this.vantaService.resizeVanta(this.elementId);
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeVanta() {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
// Trigger the resize on the vanta effect
|
|
||||||
this.vantaEffect.resize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#vanta-login-bg {
|
#vanta-login-bg {
|
||||||
transition: opacity 0.3s ease-in-out;
|
animation: fadeIn 1s ease-out;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject} from '@angular/core';
|
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||||
import { AuthService } from '../auth.service';
|
import {AuthService} from '../services/auth.service';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||||
|
import {DeviceDetectorService} from '../services/device-detector.service';
|
||||||
import {isPlatformBrowser} from '@angular/common';
|
import {isPlatformBrowser} from '@angular/common';
|
||||||
import { PLATFORM_ID } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@@ -14,7 +14,6 @@ import { PLATFORM_ID } from '@angular/core';
|
|||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NgIf,
|
NgIf,
|
||||||
HttpClientModule
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -22,80 +21,60 @@ export class LoginComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
username: string = '';
|
username: string = '';
|
||||||
password: string = '';
|
password: string = '';
|
||||||
errorMessage: string = '';
|
errorMessage: string = '';
|
||||||
private vantaEffect: any;
|
private readonly elementId = 'vanta-login-bg';
|
||||||
|
isMobile: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private vantaService: VantaBackgroundService,
|
||||||
|
private deviceService: DeviceDetectorService,
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.isMobile = this.deviceService.isMobile;
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
window.addEventListener('resize', this.onResize.bind(this));
|
window.addEventListener('resize', this.onResize.bind(this));
|
||||||
|
|
||||||
const bgElement = document.getElementById('vanta-login-bg');
|
|
||||||
if (bgElement) {
|
|
||||||
bgElement.style.position = 'fixed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogin() {
|
onLogin() {
|
||||||
this.authService.login(this.username, this.password).subscribe(
|
const observer = {
|
||||||
(response: any) => {
|
'next': (response: any) => {
|
||||||
localStorage.setItem('token', response.token);
|
localStorage.setItem('token', response.token);
|
||||||
this.router.navigate(['/admin']); // Redirect to admin page
|
this.router.navigate(['/admin']).then(
|
||||||
|
(success) => {
|
||||||
|
if (success) {
|
||||||
|
console.log('Navigation to admin succeeded');
|
||||||
|
} else {
|
||||||
|
console.warn('Navigation to admin failed');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
() => {
|
(error) => {
|
||||||
this.errorMessage = 'Invalid credentials';
|
console.error('Navigation error:', error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.errorMessage = 'Invalid credentials';
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.authService.login(this.username, this.password).subscribe(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.vantaService.initVanta(this.elementId, {});
|
||||||
// Initialize VANTA effect only in the browser
|
|
||||||
this.initVanta();
|
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (this.vantaEffect) {
|
window.removeEventListener('resize', this.onResize);
|
||||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
|
||||||
}
|
|
||||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initVanta() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
|
||||||
this.vantaEffect = window.VANTA.NET({
|
|
||||||
el: '#vanta-login-bg',
|
|
||||||
mouseControls: false,
|
|
||||||
touchControls: false,
|
|
||||||
gyroControls: false,
|
|
||||||
scale: 1.00,
|
|
||||||
scaleMobile: 1.00,
|
|
||||||
points: 20.00,
|
|
||||||
maxDistance: 25.00,
|
|
||||||
spacing: 18.00,
|
|
||||||
showDots: false,
|
|
||||||
minWidth: window.innerWidth,
|
|
||||||
minHeight: window.innerHeight,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
// Update the minHeight and minWidth when the window is resized
|
this.vantaService.resizeVanta(this.elementId);
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeVanta() {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
// Trigger the resize on the vanta effect
|
|
||||||
this.vantaEffect.resize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {DeviceDetectorService} from 'ngx-device-detector';
|
import {DeviceDetectorService} from 'ngx-device-detector';
|
||||||
import {NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
import {Router, NavigationEnd, RouterLink} from '@angular/router';
|
import {NavigationEnd, Router, RouterLink} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mobile-navbar',
|
selector: 'app-mobile-navbar',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<nav class="navbar" *ngIf="!isMobile">
|
<nav class="navbar">
|
||||||
<div class="navbar-links">
|
<div class="navbar-links">
|
||||||
<a [routerLink]="'/'" [class.active]="activeLink === '/'">About</a>
|
<a [routerLink]="'/'" [class.active]="activeLink === '/'">About</a>
|
||||||
<a [routerLink]="'/portfolio'" [class.active]="activeLink === '/portfolio'">Portfolio</a>
|
<a [routerLink]="'/portfolio'" [class.active]="activeLink === '/portfolio'">Portfolio</a>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Router, NavigationEnd, RouterLink} from '@angular/router';
|
import {NavigationEnd, Router, RouterLink} from '@angular/router';
|
||||||
import {DeviceDetectorService} from 'ngx-device-detector';
|
import {DeviceDetectorService} from 'ngx-device-detector';
|
||||||
import {NgIf} from '@angular/common';
|
import {NgIf} from '@angular/common';
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@ import {NgIf} from '@angular/common';
|
|||||||
templateUrl: './navbar.component.html',
|
templateUrl: './navbar.component.html',
|
||||||
styleUrls: ['./navbar.component.css'],
|
styleUrls: ['./navbar.component.css'],
|
||||||
imports: [
|
imports: [
|
||||||
RouterLink,
|
RouterLink
|
||||||
NgIf,
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class NavbarComponent implements OnInit {
|
export class NavbarComponent implements OnInit {
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#vanta-not-found-bg {
|
#vanta-not-found-bg {
|
||||||
transition: opacity 0.3s ease-in-out;
|
animation: fadeIn 1s ease-out;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject} from '@angular/core';
|
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||||
import {DeviceDetectorService} from 'ngx-device-detector';
|
import {DeviceDetectorService} from '../services/device-detector.service';
|
||||||
import {Meta, Title} from '@angular/platform-browser';
|
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
import {isPlatformBrowser} from '@angular/common';
|
import {isPlatformBrowser} from '@angular/common';
|
||||||
import { PLATFORM_ID } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-not-found',
|
selector: 'app-not-found',
|
||||||
@@ -13,87 +11,35 @@ import { PLATFORM_ID } from '@angular/core';
|
|||||||
})
|
})
|
||||||
|
|
||||||
export class NotFoundComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class NotFoundComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
private readonly elementId = 'vanta-not-found-bg';
|
||||||
|
isMobile: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
|
private vantaService: VantaBackgroundService,
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private meta: Meta,
|
|
||||||
private title: Title,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
isMobile: boolean = false;
|
|
||||||
private vantaEffect: any;
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isMobile = this.deviceService.isMobile();
|
this.isMobile = this.deviceService.isMobile;
|
||||||
const metaData = this.route.snapshot.data['meta'];
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (metaData?.title) {
|
window.addEventListener('resize', this.onResize.bind(this));
|
||||||
this.title.setTitle(metaData.title);
|
|
||||||
}
|
|
||||||
if (metaData?.description) {
|
|
||||||
this.meta.updateTag({ name: 'description', content: metaData.description });
|
|
||||||
}
|
|
||||||
if (metaData?.image) {
|
|
||||||
this.meta.updateTag({ property: 'og:image', content: metaData.image });
|
|
||||||
}
|
|
||||||
if (metaData?.url) {
|
|
||||||
this.meta.updateTag({ property: 'og:url', content: metaData.url });
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', this.onResize.bind(this)); // Add resize listener for responsiveness
|
|
||||||
|
|
||||||
const bgElement = document.getElementById('vanta-not-found-bg');
|
|
||||||
if (bgElement) {
|
|
||||||
bgElement.style.position = 'fixed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.vantaService.initVanta(this.elementId, {
|
||||||
// Initialize VANTA effect only in the browser
|
|
||||||
this.initVanta();
|
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ngOnDestroy() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
|
||||||
}
|
|
||||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initVanta() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
|
||||||
this.vantaEffect = window.VANTA.NET({
|
|
||||||
el: '#vanta-not-found-bg',
|
|
||||||
mouseControls: false,
|
|
||||||
touchControls: false,
|
|
||||||
gyroControls: false,
|
|
||||||
scale: 1.00,
|
|
||||||
scaleMobile: 1.00,
|
|
||||||
points: 20.00,
|
|
||||||
maxDistance: 25.00,
|
|
||||||
spacing: 18.00,
|
|
||||||
showDots: false,
|
|
||||||
minWidth: window.innerWidth,
|
|
||||||
minHeight: window.innerHeight,
|
|
||||||
color: 0xac1f4e,
|
color: 0xac1f4e,
|
||||||
backgroundColor: 0x191522
|
backgroundColor: 0x191522
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
window.removeEventListener('resize', this.onResize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
// Update the minHeight and minWidth when the window is resized
|
this.vantaService.resizeVanta(this.elementId);
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeVanta() {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
// Trigger the resize on the vanta effect
|
|
||||||
this.vantaEffect.resize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#vanta-portfolio-bg {
|
#vanta-portfolio-bg {
|
||||||
transition: opacity 0.3s ease-in-out;
|
animation: fadeIn 1s ease-out;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import {AfterViewInit, Component, OnDestroy, OnInit, Inject} from '@angular/core';
|
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||||
import {NgIf} from '@angular/common';
|
import {DeviceDetectorService} from '../services/device-detector.service';
|
||||||
import {Meta, Title} from '@angular/platform-browser';
|
import {isPlatformBrowser, NgIf} from '@angular/common';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
|
||||||
import { PLATFORM_ID } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-portfolio',
|
selector: 'app-portfolio',
|
||||||
@@ -15,87 +12,37 @@ import { PLATFORM_ID } from '@angular/core';
|
|||||||
styleUrl: './portfolio.component.css'
|
styleUrl: './portfolio.component.css'
|
||||||
})
|
})
|
||||||
export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
private readonly elementId = 'vanta-portfolio-bg';
|
||||||
|
isMobile: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
|
private vantaService: VantaBackgroundService,
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private meta: Meta,
|
|
||||||
private title: Title,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
@Inject(PLATFORM_ID) private platformId: Object
|
@Inject(PLATFORM_ID) private platformId: Object
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
isMobile: boolean = false;
|
|
||||||
private vantaEffect: any;
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isMobile = this.deviceService.isMobile();
|
this.isMobile = this.deviceService.isMobile;
|
||||||
const metaData = this.route.snapshot.data['meta'];
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
if (metaData?.title) {
|
window.addEventListener('resize', this.onResize.bind(this));
|
||||||
this.title.setTitle(metaData.title);
|
|
||||||
}
|
|
||||||
if (metaData?.description) {
|
|
||||||
this.meta.updateTag({ name: 'description', content: metaData.description });
|
|
||||||
}
|
|
||||||
if (metaData?.image) {
|
|
||||||
this.meta.updateTag({ property: 'og:image', content: metaData.image });
|
|
||||||
}
|
|
||||||
if (metaData?.url) {
|
|
||||||
this.meta.updateTag({ property: 'og:url', content: metaData.url });
|
|
||||||
}
|
|
||||||
window.addEventListener('resize', this.onResize.bind(this)); // Add resize listener for responsiveness
|
|
||||||
|
|
||||||
const bgElement = document.getElementById('vanta-portfolio-bg');
|
|
||||||
if (bgElement) {
|
|
||||||
bgElement.style.position = 'fixed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
this.vantaService.initVanta(this.elementId, {
|
||||||
// Initialize VANTA effect only in the browser
|
|
||||||
this.initVanta();
|
|
||||||
this.resizeVanta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ngOnDestroy() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
this.vantaEffect.destroy(); // Clean up the effect on destroy
|
|
||||||
}
|
|
||||||
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initVanta() {
|
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
|
||||||
this.vantaEffect = window.VANTA.NET({
|
|
||||||
el: '#vanta-portfolio-bg',
|
|
||||||
mouseControls: false,
|
|
||||||
touchControls: false,
|
|
||||||
gyroControls: false,
|
|
||||||
scale: 1.00,
|
|
||||||
scaleMobile: 1.00,
|
|
||||||
points: 20.00,
|
|
||||||
maxDistance: 25.00,
|
|
||||||
spacing: 18.00,
|
|
||||||
showDots: false,
|
|
||||||
minWidth: window.innerWidth,
|
|
||||||
minHeight: window.innerHeight,
|
|
||||||
color: 0xac1f4e,
|
color: 0xac1f4e,
|
||||||
backgroundColor: 0x191522
|
backgroundColor: 0x191522
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.vantaService.destroyVanta(this.elementId);
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
window.removeEventListener('resize', this.onResize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
// Update the minHeight and minWidth when the window is resized
|
// Update the minHeight and minWidth when the window is resized
|
||||||
this.resizeVanta();
|
this.vantaService.resizeVanta(this.elementId);
|
||||||
}
|
|
||||||
|
|
||||||
resizeVanta() {
|
|
||||||
if (this.vantaEffect) {
|
|
||||||
// Trigger the resize on the vanta effect
|
|
||||||
this.vantaEffect.resize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,24 @@
|
|||||||
|
import {Inject, Injectable, PLATFORM_ID} from '@angular/core';
|
||||||
|
import {isPlatformBrowser} from '@angular/common';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class DeviceDetectorService {
|
||||||
|
isMobile: boolean = false;
|
||||||
|
|
||||||
|
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
|
||||||
|
this.updateDeviceType();
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
window.addEventListener('resize', () => this.updateDeviceType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateDeviceType() {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
this.isMobile = window.innerWidth <= 768;
|
||||||
|
} else {
|
||||||
|
this.isMobile = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import {Inject, Injectable, PLATFORM_ID} from '@angular/core';
|
||||||
|
import {isPlatformBrowser} from '@angular/common';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class VantaBackgroundService {
|
||||||
|
private vantaEffect: Map<string, any> = new Map();
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(PLATFORM_ID) private platformId: Object,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
initVanta(elementId: string, options?: any) {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
const element = document.getElementById(elementId);
|
||||||
|
if (element && !this.vantaEffect.has(elementId)) {
|
||||||
|
(window as any).VANTA.NET({
|
||||||
|
el: element,
|
||||||
|
mouseControls: false,
|
||||||
|
touchControls: false,
|
||||||
|
gyroControls: false,
|
||||||
|
scale: 1.0,
|
||||||
|
scaleMobile: 1.0,
|
||||||
|
points: 20.0,
|
||||||
|
maxDistance: 25.0,
|
||||||
|
spacing: 18.0,
|
||||||
|
showDots: false,
|
||||||
|
minWidth: window.innerWidth,
|
||||||
|
minHeight: window.innerHeight,
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
element.style.position = 'fixed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeVanta(elementId: string): void {
|
||||||
|
const effect = this.vantaEffect.get(elementId);
|
||||||
|
if (effect) {
|
||||||
|
effect.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyVanta(elementId: string): void {
|
||||||
|
const effect = this.vantaEffect.get(elementId);
|
||||||
|
if (effect) {
|
||||||
|
effect.destroy();
|
||||||
|
this.vantaEffect.delete(elementId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
||||||
|
<title>itzMiney's Home</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|||||||
+1
-6
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import {AngularNodeAppEngine, createNodeRequestHandler, isMainModule,} from '@angular/ssr/node';
|
||||||
AngularNodeAppEngine,
|
|
||||||
createNodeRequestHandler,
|
|
||||||
isMainModule,
|
|
||||||
writeResponseToNodeResponse,
|
|
||||||
} from '@angular/ssr/node';
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import {dirname, resolve} from 'node:path';
|
import {dirname, resolve} from 'node:path';
|
||||||
import {fileURLToPath} from 'node:url';
|
import {fileURLToPath} from 'node:url';
|
||||||
|
|||||||
Vendored
-6
@@ -1,6 +0,0 @@
|
|||||||
declare global {
|
|
||||||
interface Window {
|
|
||||||
VANTA: any; // This declares VANTA as a global object with an 'any' type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
Reference in new issue
Block a user