-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.tsx
More file actions
360 lines (329 loc) · 12 KB
/
index.tsx
File metadata and controls
360 lines (329 loc) · 12 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
import { useState, useEffect, useRef } from 'react';
import Button from '@components/Button';
import styles from './styles.module.css';
import clsx from 'clsx';
import SeqeraLogo from '@icons/SeqeraLogo';
import Link from './Link';
import { motion, AnimatePresence } from 'framer-motion';
import PortableText from '@components/PortableText';
import Pixels from '@modules/Pixels';
import shareOverlay from '@images/pixel-share-overlay.svg';
interface HeroProps {
title?: string;
subtitle?: string;
content: string;
ctaText1?: string;
ctaLink1?: string;
ctaExternal1?: boolean;
ctaText2?: string;
ctaLink2?: string;
ctaExternal2?: boolean;
namespace?: string;
headlineSize?: 'small' | 'medium' | 'large' | 'xl';
image?: any;
imageAlt?: string;
}
const fadeIn = {
initial: { opacity: 0 },
whileInView: { opacity: 1 },
viewport: { once: true },
};
const fadeInUp = {
initial: { opacity: 0, y: 5 },
whileInView: { opacity: 1, y: 0 },
viewport: { once: true },
};
const LandingHero: React.FC<HeroProps> = ({
title,
subtitle,
content,
ctaText1,
ctaLink1,
ctaText2,
ctaLink2,
ctaExternal1,
ctaExternal2,
headlineSize = 'medium',
image,
imageAlt,
}) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [pacmanMode, setPacmanMode] = useState(false);
const pixelsRef = useRef<{ getCanvas: () => HTMLCanvasElement | null }>(null);
const [hashtagCopied, setHashtagCopied] = useState(false);
// Close modal on Escape key
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') setIsModalOpen(false);
};
if (isModalOpen) {
document.addEventListener('keydown', handleEscape);
// Prevent body scroll when modal is open
document.body.style.overflow = 'hidden';
}
return () => {
document.removeEventListener('keydown', handleEscape);
document.body.style.overflow = 'unset';
};
}, [isModalOpen]);
// Exit pacman mode on Escape key
useEffect(() => {
if (!pacmanMode) return;
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') setPacmanMode(false);
};
document.addEventListener('keydown', handleEscape);
return () => document.removeEventListener('keydown', handleEscape);
}, [pacmanMode]);
const handleDownload = () => {
const canvas = pixelsRef.current?.getCanvas();
if (!canvas) return;
const sourceWidth = canvas.width;
const sourceHeight = canvas.height;
// Target 1.91:1 aspect ratio for social sharing
let targetWidth = sourceWidth;
let targetHeight = Math.round(sourceWidth / 1.91);
// If source is already wider than 1.91:1, pad sides instead
if (targetHeight < sourceHeight) {
targetHeight = sourceHeight;
targetWidth = Math.round(sourceHeight * 1.91);
}
// Artwork position: bottom-aligned, horizontally centered
const xOffset = Math.round((targetWidth - sourceWidth) / 2);
const yOffset = targetHeight - sourceHeight;
const downloadCanvas = document.createElement('canvas');
downloadCanvas.width = targetWidth;
downloadCanvas.height = targetHeight;
const ctx = downloadCanvas.getContext('2d');
if (!ctx) return;
// Fill with black background
ctx.fillStyle = '#000000';
ctx.fillRect(0, 0, targetWidth, targetHeight);
// Draw pixel art (bottom-aligned, horizontally centered)
ctx.drawImage(canvas, xOffset, yOffset);
// Load and draw the share overlay, then export
const overlay = new Image();
overlay.onload = () => {
ctx.drawImage(overlay, 0, 0, targetWidth, targetHeight);
downloadCanvas.toBlob((blob) => {
if (!blob) return;
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = `nextflow-summit-2026-${Date.now()}.png`;
link.href = url;
link.click();
URL.revokeObjectURL(url);
});
};
overlay.src = shareOverlay.src;
};
return (
<motion.div
{...fadeIn}
transition={{ duration: 0.4, delay: 0.6, ease: 'linear' }}
className="py-20 md:py-20 relative w-full h-full flex flex-row justify-between items-center container-xl"
>
<Pixels
ref={pixelsRef}
initialCellSize={18}
initialSpeed={100}
initialDensity={0.002}
colorScheme="green"
pacmanMode={pacmanMode}
/>
<section className={clsx(styles.landingHero, 'h-full relative w-full')}>
<div className="flex flex-col-reverse sm:flex-row h-full items-center relative">
{/* Left Column */}
<div className="w-full h-full sm:pr-10 md:mt-10 md:pb-15">
<div className="pointer-events-none">
<div className="relative inline-flex">
<h1
className={` mb-4 md:max-w-[800px] z-30 relative
${!headlineSize && 'h3'}
${headlineSize === 'xl' ? 'h1' : ''}
${headlineSize === 'large' ? 'h2' : ''}
${headlineSize === 'medium' ? 'h3' : ''}
${headlineSize === 'small' ? 'h4' : ''}
`}
>
<span
className="bg-black box-decoration-clone"
style={{
boxDecorationBreak: 'clone',
WebkitBoxDecorationBreak: 'clone',
}}
>
{title}
</span>
</h1>
</div>
<h1 className="h1 mb-4 sm:max-w-[500px] ">{subtitle}</h1>
</div>
<div className="flex flex-col sm:max-w-[550px] relative">
<div
className={clsx('z-50 pointer-events-auto', styles.heroText)}
>
<PortableText value={content} />
</div>
<div className="inline-flex flex-col sm:flex-row sm:items-center">
{ctaText1 && (
<Button
arrow
className="mt-10 z-50 relative"
href={ctaLink1}
target={ctaExternal1 ? '_blank' : '_self'}
>
{ctaText1}
</Button>
)}
{ctaText2 && (
<Button
light
arrow
className="sm:ml-4 mt-3 sm:mt-10 z-50 relative"
href={ctaLink2}
target={ctaExternal2 ? '_blank' : '_self'}
>
{ctaText2}
</Button>
)}
</div>
</div>
</div>
{/* Right Column */}
{image && (
<motion.div
{...fadeIn}
transition={{ duration: 0.3, delay: 0.5, ease: 'linear' }}
className="h-full flex flex-col w-full "
>
<div>
<div
className={`mb-6 md:mb-0 relative w-full h-0 overflow-hidden pb-[100%] `}
>
<img
className="absolute top-0 left-0 right-0 bottom-0 w-full h-full z-0 object-cover"
src={image}
alt={imageAlt || 'Image'}
/>
</div>
</div>
</motion.div>
)}
</div>
</section>
{/* Pacman Button */}
<button
onClick={() => setPacmanMode((v) => !v)}
className={`z-50 cursor-pointer absolute top-4 right-8 w-[18px] h-[18px] flex justify-center items-center transition-colors monospace text-[10px] leading-none ${
pacmanMode
? 'bg-nextflow-600 text-black hover:bg-nextflow-800'
: 'bg-gray-100 text-black hover:bg-gray-300'
}`}
aria-label={pacmanMode ? 'Exit Pacman' : 'Play Pacman'}
title={pacmanMode ? 'Exit Pacman (Esc)' : 'Play Pacman'}
>
{pacmanMode ? 'x' : '\u25CF'}
</button>
{/* Help Button */}
<button
onClick={() => setIsModalOpen(true)}
className="z-50 cursor-pointer absolute bottom-4 right-4 bg-gray-100 text-black w-[18px] h-[18px] flex justify-center items-center hover:bg-gray-300 transition-colors "
aria-label="Help"
>
?
</button>
{/* Modal */}
<AnimatePresence>
{isModalOpen && (
<>
{/* Backdrop */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={() => setIsModalOpen(false)}
className="absolute inset-0 z-[100] "
/>
{/* Modal Content */}
<motion.div
initial={{ opacity: 0, scale: 0.95, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.95, y: 20 }}
transition={{ duration: 0.2 }}
className="absolute bottom-6 right-6 z-[100] bg-white shadow-xl max-w-[300px] w-full mx-4 text-black"
>
<div className="p-4">
<p className="text-[.8rem]">
Share your pixel art!{' '}
<span
className="text-nextflow-800 monospace text-[.9rem] cursor-pointer hover:underline inline-flex items-center gap-1"
onClick={() => {
navigator.clipboard.writeText(
'Check out my pixel art! #NextflowSummit2026\n\nNextflow Summit, presented by Seqera, brings together scientists from around the world to shape the future of biotech R&D through community-driven innovation in data science and computational biology.'
);
setHashtagCopied(true);
setTimeout(() => setHashtagCopied(false), 2000);
}}
>
{hashtagCopied ? 'Hashtag copied!' : '#NextflowSummit2026'}
{hashtagCopied ? (
<svg
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.5"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="20 6 9 17 4 12" />
</svg>
) : (
<svg
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect
x="9"
y="9"
width="13"
height="13"
rx="2"
ry="2"
/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
</svg>
)}
</span>
</p>
<div className="mt-4 flex justify-start gap-2">
<button
onClick={handleDownload}
className="px-4 py-1 bg-nextflow-600 monospace uppercase text-xs text-black hover:bg-nextflow-800 transition-colors"
>
Download Artwork
</button>
<button
onClick={() => setIsModalOpen(false)}
className="px-4 py-1 bg-gray-200 monospace uppercase text-xs text-black hover:bg-gray-300 transition-colors"
>
Close
</button>
</div>
</div>
</motion.div>
</>
)}
</AnimatePresence>
</motion.div>
);
};
export default LandingHero;