Skip to content

Commit ce723e7

Browse files
committed
fix artwork rotation
1 parent 870075d commit ce723e7

File tree

2 files changed

+62
-73
lines changed

2 files changed

+62
-73
lines changed

app/page.tsx

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,5 @@
1-
'use client';
1+
import ArtworkRotation from '../components/ArtworkRotation';
22

3-
import Image from 'next/image';
4-
import Link from 'next/link';
5-
import { useState, useEffect } from 'react';
6-
7-
const SKETCH_PATHS = [
8-
'/images/sunflowersketch.png',
9-
'/images/handrose.png',
10-
'/images/peony.png',
11-
'/images/hummingbird.png',
12-
'/images/howl.png',
13-
'/images/hokusai.png',
14-
'/images/christ.png',
15-
'/images/metro.png',
16-
'/images/wave.png',
17-
'/images/room.png',
18-
'/images/angel.png',
19-
] as const;
20-
21-
const ROTATION_INTERVAL = 3000;
22-
23-
const HomePage = () => {
24-
const [currentIndex, setCurrentIndex] = useState(0);
25-
26-
useEffect(() => {
27-
// Rotate sketches
28-
const timer = setInterval(() => {
29-
setCurrentIndex((prev) => (prev + 1) % SKETCH_PATHS.length);
30-
}, ROTATION_INTERVAL);
31-
32-
return () => {
33-
clearInterval(timer);
34-
};
35-
}, []);
36-
37-
useEffect(() => {
38-
// Prevent scrolling on homepage
39-
document.documentElement.style.overflow = 'hidden';
40-
document.body.style.overflow = 'hidden';
41-
42-
return () => {
43-
document.documentElement.style.overflow = '';
44-
document.body.style.overflow = '';
45-
};
46-
}, []);
47-
48-
return (
49-
<div className="fixed inset-0 md:left-64 flex items-center justify-center overflow-hidden">
50-
<div className="relative w-full h-full max-w-6xl px-8 flex items-center justify-center">
51-
<div className="relative w-full h-[75vh] select-none">
52-
<Image
53-
src={SKETCH_PATHS[currentIndex]}
54-
alt="sketch"
55-
fill
56-
className="object-contain opacity-90"
57-
priority
58-
draggable={false}
59-
sizes="(max-width: 768px) 100vw, 1280px"
60-
/>
61-
</div>
62-
</div>
63-
64-
<Link
65-
href="/about"
66-
className="absolute bottom-8 right-8 text-sm text-japanese-sumiiro dark:text-japanese-shironezu hover:underline"
67-
>
68-
about
69-
</Link>
70-
</div>
71-
);
72-
};
73-
74-
export default HomePage;
3+
export default function HomePage() {
4+
return <ArtworkRotation />;
5+
}

components/ArtworkRotation.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use client';
2+
3+
import Image from 'next/image';
4+
import Link from 'next/link';
5+
import { useState, useEffect } from 'react';
6+
7+
const SKETCH_PATHS = [
8+
'/images/sunflowersketch.png',
9+
'/images/handrose.png',
10+
'/images/peony.png',
11+
'/images/hummingbird.png',
12+
'/images/howl.png',
13+
'/images/hokusai.png',
14+
'/images/christ.png',
15+
'/images/metro.png',
16+
'/images/wave.png',
17+
'/images/room.png',
18+
'/images/angel.png',
19+
] as const;
20+
21+
const ROTATION_INTERVAL = 3000;
22+
23+
export default function ArtworkRotation() {
24+
const [currentIndex, setCurrentIndex] = useState(0);
25+
26+
useEffect(() => {
27+
const timer = setInterval(() => {
28+
setCurrentIndex((prev) => (prev + 1) % SKETCH_PATHS.length);
29+
}, ROTATION_INTERVAL);
30+
31+
return () => clearInterval(timer);
32+
}, []);
33+
34+
return (
35+
<div className="fixed inset-0 md:left-64 flex items-center justify-center overflow-hidden">
36+
<div className="relative w-full h-full max-w-6xl px-8 flex items-center justify-center">
37+
<div className="relative w-full h-[75vh] select-none">
38+
<Image
39+
src={SKETCH_PATHS[currentIndex]}
40+
alt="sketch"
41+
fill
42+
className="object-contain opacity-90"
43+
priority
44+
draggable={false}
45+
sizes="(max-width: 768px) 100vw, 1280px"
46+
/>
47+
</div>
48+
</div>
49+
50+
<Link
51+
href="/about"
52+
className="absolute bottom-8 right-8 text-sm text-japanese-sumiiro dark:text-japanese-shironezu hover:underline"
53+
>
54+
about
55+
</Link>
56+
</div>
57+
);
58+
}

0 commit comments

Comments
 (0)