-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuxeProjectsPage.jsx
More file actions
317 lines (286 loc) · 12.1 KB
/
LuxeProjectsPage.jsx
File metadata and controls
317 lines (286 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import React, { useState, useRef } from 'react';
import { Link } from 'react-router-dom';
import {
motion,
useScroll,
useTransform,
useMotionValueEvent,
} from 'framer-motion';
import {
ArrowUpRightIcon,
StackIcon,
GridFourIcon,
ArrowLeftIcon,
MouseIcon,
MagnifyingGlassIcon,
} from '@phosphor-icons/react';
import { useProjects } from '../../utils/projectParser';
import Seo from '../../components/Seo';
import LuxeArt from '../../components/LuxeArt';
const StackedCard = ({ project, index, scrollYProgress, total }) => {
// Each card has a range in the 0-1 scroll progress
const step = 1 / total;
const start = index * step;
// Transition logic:
// We want the card to stay "solo" for a while.
// So it slides in during the second half of the PREVIOUS card's segment.
// And it finishes sliding in exactly when its own segment starts.
const slideStart = Math.max(0, start - step * 0.6); // 60% of the previous segment is used for the slide-in
const slideEnd = start;
const y = useTransform(
scrollYProgress,
[slideStart, slideEnd],
['100vh', '0vh'],
);
// The first card is always at 0
const translateY = index === 0 ? 0 : y;
return (
<motion.div
style={{
y: translateY,
zIndex: index,
}}
className="absolute inset-0 flex flex-col items-center justify-center px-6 md:px-12"
>
<div className="relative aspect-[3/4] md:aspect-square lg:aspect-[16/10] w-full max-w-[1000px] bg-[#EBEBEB] rounded-2xl overflow-hidden border border-white/20 group shadow-2xl max-h-[60vh] shrink-0">
<Link
to={`/projects/${project.slug}`}
className="block w-full h-full relative"
>
<div className="absolute inset-0 transition-transform duration-1000 group-hover:scale-110">
<LuxeArt
seed={project.title}
className="w-full h-full opacity-90 group-hover:opacity-100 transition-opacity"
/>
</div>
<div className="absolute inset-0 bg-gradient-to-t from-black/90 via-black/20 to-black/5 p-8 md:p-16 flex flex-col justify-between text-white">
<div className="flex justify-between items-start">
<span className="font-outfit text-xs uppercase tracking-widest border border-white/20 px-4 py-2 rounded-full backdrop-blur-md">
Work {String(index + 1).padStart(2, '0')}
</span>
<div className="w-14 h-14 rounded-full bg-white/10 backdrop-blur-md flex items-center justify-center group-hover:bg-white group-hover:text-black transition-all duration-500 shadow-xl">
<ArrowUpRightIcon size={28} />
</div>
</div>
<div className="max-w-3xl">
<h3 className="font-playfairDisplay italic text-4xl md:text-7xl lg:text-8xl mb-6 leading-none tracking-tighter">
{project.title}
</h3>
<p className="font-outfit text-white/80 leading-relaxed max-w-xl text-sm md:text-lg line-clamp-3 italic">
{project.shortDescription}
</p>
</div>
</div>
</Link>
</div>
</motion.div>
);
};
const GridCard = ({ project, index }) => (
<div className="w-full h-full group">
<Link to={`/projects/${project.slug}`} className="block h-full">
<div className="relative aspect-[3/4] md:aspect-square lg:aspect-[4/5] w-full bg-[#EBEBEB] rounded-xl overflow-hidden border border-black/5 shadow-sm hover:shadow-xl transition-all duration-500">
<div className="absolute inset-0 transition-transform duration-1000 group-hover:scale-110">
<LuxeArt
seed={project.title}
className="w-full h-full opacity-90 group-hover:opacity-100 transition-opacity"
/>
</div>
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-transparent to-transparent p-8 flex flex-col justify-end text-white">
<h3 className="font-playfairDisplay text-3xl italic mb-2">
{project.title}
</h3>
<p className="font-outfit text-xs text-white/70 line-clamp-2">
{project.shortDescription}
</p>
</div>
</div>
</Link>
</div>
);
const LuxeProjectsPage = () => {
const { projects, loading, error } = useProjects();
const [layoutMode, setLayoutMode] = useState('stack');
const [searchQuery, setSearchQuery] = useState('');
const containerRef = useRef(null);
// Track active index for optimized rendering (only show current, prev, next)
const [visibleIndices, setVisibleIndices] = useState([0, 1, 2]);
const { scrollYProgress } = useScroll({
target: containerRef,
offset: ['start start', 'end end'],
});
const [currentIdx, setCurrentIdx] = useState(0);
useMotionValueEvent(scrollYProgress, 'change', (latest) => {
if (!projects.length) return;
const idx = Math.min(
projects.length - 1,
Math.floor(latest * projects.length),
);
setCurrentIdx(idx);
// Window of 3: prev, current, next
const start = Math.max(0, idx - 1);
const end = Math.min(projects.length - 1, idx + 1);
// Only update if indices changed to avoid unnecessary re-renders
if (
visibleIndices[0] !== start ||
visibleIndices[visibleIndices.length - 1] !== end
) {
const newIndices = [];
for (let i = start; i <= end; i++) newIndices.push(i);
setVisibleIndices(newIndices);
}
});
if (loading) {
return (
<div className="min-h-screen bg-[#F5F5F0] flex items-center justify-center font-outfit text-[#1A1A1A]/40 text-xs uppercase tracking-widest">
Loading Archive...
</div>
);
}
if (error) {
return (
<div className="min-h-screen bg-[#F5F5F0] flex items-center justify-center font-outfit text-red-500 text-xs uppercase tracking-widest">
Error: {error.message}
</div>
);
}
return (
<div className="min-h-screen bg-[#F5F5F0] text-[#1A1A1A] font-sans selection:bg-[#C0B298] selection:text-black">
<Seo
title="Works | Fezcodex"
description="A curated collection of digital experiments and architectural explorations."
keywords={['Fezcodex', 'projects', 'portfolio', 'developer']}
/>
{/* Persistent Header */}
<div className="relative z-40 max-w-[1800px] mx-auto px-6 md:px-12 pt-24">
<header className="mb-12 border-b border-[#1A1A1A]/10 pb-12">
<Link
to="/"
className="inline-flex items-center gap-2 mb-8 font-outfit text-xs uppercase tracking-widest text-black/40 hover:text-[#8D4004] transition-colors"
>
<ArrowLeftIcon /> Home
</Link>
<div className="flex flex-col md:flex-row justify-between items-end gap-12">
<div className="space-y-6 flex-1">
<h1 className="font-playfairDisplay text-7xl md:text-9xl text-[#1A1A1A] mb-0 leading-none">
Works
</h1>
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-8">
<p className="font-outfit text-sm text-[#1A1A1A]/60 max-w-lg leading-relaxed italic">
Explorations in code, design, and user interaction. A
catalogue of shipped products and experimental prototypes.
</p>
{layoutMode === 'grid' && (
<div className="relative group border-b border-[#1A1A1A]/20 focus-within:border-[#1A1A1A] transition-colors min-w-[300px]">
<input
type="text"
placeholder="Search Archive..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="w-full bg-transparent py-2 outline-none font-outfit text-sm placeholder-[#1A1A1A]/30"
/>
<MagnifyingGlassIcon className="absolute right-0 top-1/2 -translate-y-1/2 text-[#1A1A1A]/40" />
</div>
)}
</div>
</div>
<div className="flex items-center gap-8">
<div className="flex bg-white rounded-full p-1 border border-black/5 shadow-sm">
<button
onClick={() => setLayoutMode('grid')}
className={`p-2 rounded-full transition-all ${layoutMode === 'grid' ? 'bg-[#1A1A1A] text-white shadow-lg' : 'text-black/40 hover:text-black'}`}
title="Grid View"
>
<GridFourIcon size={20} />
</button>
<button
onClick={() => setLayoutMode('stack')}
className={`p-2 rounded-full transition-all ${layoutMode === 'stack' ? 'bg-[#1A1A1A] text-white shadow-lg' : 'text-black/40 hover:text-black'}`}
title="Stack View"
>
<StackIcon size={20} />
</button>
</div>
<span className="font-outfit text-[10px] uppercase tracking-widest text-[#1A1A1A]/40 border border-[#1A1A1A]/10 px-4 py-2 rounded-full bg-white/50">
Archive Size: {projects.length}
</span>
</div>
</div>
</header>
</div>
{/* Content Area */}
{layoutMode === 'grid' ? (
<div className="max-w-[1800px] mx-auto px-6 md:px-12 pb-32 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{projects
.filter(
(p) =>
p.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
p.shortDescription
.toLowerCase()
.includes(searchQuery.toLowerCase()),
)
.map((project, index) => (
<GridCard key={project.slug} project={project} index={index} />
))}
</div>
) : (
<div
ref={containerRef}
className="relative"
style={{ height: `${projects.length * 150}vh` }}
>
{/* Top Progress Bar */}
<div className="fixed top-0 left-0 right-0 h-1 bg-[#1A1A1A]/5 z-[110]">
<motion.div
className="h-full bg-[#8D4004] origin-left"
style={{ scaleX: scrollYProgress }}
/>
</div>
{/* Right Side Scroll Prompt & Pagination */}
<div className="fixed right-12 top-1/2 -translate-y-1/2 z-[110] hidden lg:flex flex-col gap-6 items-center">
{/* Scroll Prompt */}
<div className="flex flex-col items-center gap-2 pointer-events-none opacity-20 mb-4">
<motion.div
animate={{ y: [0, 8, 0] }}
transition={{
duration: 2,
repeat: Infinity,
ease: 'easeInOut',
}}
>
<MouseIcon size={32} weight="light" />
</motion.div>
<span className="font-outfit text-[9px] uppercase tracking-[0.4em] [writing-mode:vertical-lr]">
Scroll
</span>
</div>
<div className="w-px h-12 bg-gradient-to-b from-transparent via-[#1A1A1A]/10 to-transparent" />
{projects.map((_, i) => (
<div
key={i}
className={`w-1.5 h-1.5 rounded-full transition-all duration-500 ${currentIdx === i ? 'bg-[#8D4004] scale-150' : 'bg-[#1A1A1A]/10'}`}
/>
))}
<div className="w-px h-12 bg-gradient-to-b from-transparent via-[#1A1A1A]/10 to-transparent" />
</div>
<div className="sticky top-0 h-screen w-full overflow-hidden">
{projects.map((project, index) => {
// Optimized Rendering: only render the 3 cards in the current window
if (!visibleIndices.includes(index)) return null;
return (
<StackedCard
key={project.slug}
project={project}
index={index}
scrollYProgress={scrollYProgress}
total={projects.length}
/>
);
})}
</div>
</div>
)}
</div>
);
};
export default LuxeProjectsPage;