Skip to content

Commit 4d20950

Browse files
committed
gallery
1 parent 0caa546 commit 4d20950

3 files changed

Lines changed: 65 additions & 29 deletions

File tree

src/styles/globals.css

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,7 @@
22

33
@custom-variant dark (&:is(.dark *));
44

5-
/* Slow Motion Animation for Video Background */
6-
@keyframes slowMotion {
7-
0% {
8-
transform: scale(1.1) translate(0, 0);
9-
}
10-
25% {
11-
transform: scale(1.1) translate(-2px, -1px);
12-
}
13-
50% {
14-
transform: scale(1.1) translate(1px, -2px);
15-
}
16-
75% {
17-
transform: scale(1.1) translate(-1px, 1px);
18-
}
19-
100% {
20-
transform: scale(1.1) translate(0, 0);
21-
}
22-
}
5+
236

247
:root {
258
--font-size: 14px;

src/types/assets.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
declare module '*.mp4' {
2+
const src: string;
3+
export default src;
4+
}
5+
6+
declare module '*.webm' {
7+
const src: string;
8+
export default src;
9+
}
10+
11+
declare module '*.svg' {
12+
const src: string;
13+
export default src;
14+
}
15+
16+
declare module '*.png' {
17+
const src: string;
18+
export default src;
19+
}
20+
21+
declare module '*.jpg' {
22+
const src: string;
23+
export default src;
24+
}
25+
26+
declare module '*.jpeg' {
27+
const src: string;
28+
export default src;
29+
}
30+
31+
declare module '*.webp' {
32+
const src: string;
33+
export default src;
34+
}

src/utils/imageUtils.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@ import heroVideoPoster from '../assets/video/hero-video-poster.svg';
66
import cyberBrutalLogo from '../assets/logo/cyber-brutal-logo.svg';
77
import cyberDistrictMap from '../assets/map/cyber-district-map.svg';
88

9+
// Import gallery images
10+
import futuristicTechnology from '../assets/gallery/futuristic-technology.png';
11+
import cyberArchitecture from '../assets/gallery/cyber-architecture.png';
12+
import neonLightsCity from '../assets/gallery/neon-lights-city.png';
13+
import digitalArtAbstract from '../assets/gallery/digital-art-abstract.png';
14+
import cyberpunkAesthetic from '../assets/gallery/cyberpunk-aesthetic.png';
15+
import holographicDisplay from '../assets/gallery/holographic-display.png';
16+
17+
// Utility function to convert snake_case/kebab-case to camelCase
18+
const toCamelCase = (str: string): string => {
19+
return str
20+
.toLowerCase()
21+
.replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
22+
};
23+
924
// Image and video utility functions for handling placeholders and fallbacks
1025

1126
export const getGalleryImagePath = (query: string): string => {
12-
// Convert query to filename format
13-
const filename = query.replace(/\s+/g, '-').toLowerCase();
14-
return `/src/assets/gallery/${filename}.png`;
27+
// Convert query to camelCase and dynamically access the imported image
28+
const camelCaseQuery = toCamelCase(query);
29+
30+
// Create an object with all imported images for dynamic access
31+
const images = {
32+
futuristicTechnology,
33+
cyberArchitecture,
34+
neonLightsCity,
35+
digitalArtAbstract,
36+
cyberpunkAesthetic,
37+
holographicDisplay,
38+
};
39+
40+
// Dynamically access the image using the camelCase key
41+
return (images as any)[camelCaseQuery] || futuristicTechnology; // fallback to first image
1542
};
1643

1744
export const getMapImagePath = (): string => {
@@ -22,14 +49,6 @@ export const getLogoPath = (): string => {
2249
return cyberBrutalLogo;
2350
};
2451

25-
export const getHeroVideoPath = (): string => {
26-
return heroBackgroundMp4;
27-
};
28-
29-
export const getHeroVideoWebmPath = (): string => {
30-
return heroBackgroundWebm;
31-
};
32-
3352
export const getHeroVideoPosterPath = (): string => {
3453
return heroVideoPoster;
3554
};

0 commit comments

Comments
 (0)