-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmacbook-scroll.tsx
658 lines (636 loc) · 18.7 KB
/
macbook-scroll.tsx
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
"use client";
import React, { useEffect, useRef, useState } from "react";
import { MotionValue, motion, useScroll, useTransform } from "motion/react";
import { cn } from "@/lib/utils";
import {
IconBrightnessDown,
IconBrightnessUp,
IconCaretRightFilled,
IconCaretUpFilled,
IconChevronUp,
IconMicrophone,
IconMoon,
IconPlayerSkipForward,
IconPlayerTrackNext,
IconPlayerTrackPrev,
IconTable,
IconVolume,
IconVolume2,
IconVolume3,
} from "@tabler/icons-react";
import { IconSearch } from "@tabler/icons-react";
import { IconWorld } from "@tabler/icons-react";
import { IconCommand } from "@tabler/icons-react";
import { IconCaretLeftFilled } from "@tabler/icons-react";
import { IconCaretDownFilled } from "@tabler/icons-react";
import Image, { StaticImageData } from "next/image";
import { mac, nav_logo } from "@/images/main";
import Link from "next/link";
export const MacbookScroll = ({
showGradient,
badge,
}: {
showGradient?: boolean;
title?: string | React.ReactNode;
badge?: React.ReactNode;
}) => {
const ref = useRef<HTMLDivElement>(null);
const { scrollYProgress } = useScroll({
target: ref,
offset: ["start start", "end start"],
});
const [isMobile, setIsMobile] = useState(false);
const [deviceWidth, setDeviceWidth] = useState(0);
useEffect(() => {
if (window && window.innerWidth < 768) {
setIsMobile(true);
}
}, []);
useEffect(() => {
if (typeof window !== "undefined") {
const handleResize = () => setDeviceWidth(window.innerWidth);
setDeviceWidth(window.innerWidth); // Set initial width
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}
}, []);
const scaleX = useTransform(
scrollYProgress,
[0, 0.3],
[1.2, isMobile ? 1.25 : 1.5],
);
const scaleY = useTransform(
scrollYProgress,
[0, 0.3],
[0.6, isMobile ? 1.25 : 1.5],
);
const translate = useTransform(
scrollYProgress,
[0, 1],
[0, deviceWidth - 200],
);
const rotate = useTransform(scrollYProgress, [0.1, 0.12, 0.3], [-28, -28, 0]);
return (
<section className="min-h-[300vh] overflow-hidden sm:flex hidden justify-center">
<div
ref={ref}
className="md:min-h-[200vh] h-screen flex flex-col max-h-max items-center py-12 justify-start flex-shrink-0 [perspective:800px] transform md:scale-100 scale-50 sm:scale-75"
>
{/* Lid */}
<Lid
src={mac}
scaleX={scaleX}
scaleY={scaleY}
rotate={rotate}
translate={translate}
/>
{/* Base area */}
<div className="h-[22rem] w-[32rem] bg-[#4e4e50] rounded-2xl overflow-hidden relative -z-10">
{/* above keyboard bar */}
<div className="h-10 w-full relative">
<div className="absolute inset-x-0 mx-auto w-[80%] h-4 bg-[#050505]" />
</div>
<div className="flex relative">
<div className="mx-auto w-[10%] overflow-hidden h-full"></div>
<div className="mx-auto w-[80%] h-full">
<Keypad />
</div>
<div className="mx-auto w-[10%] overflow-hidden h-full"></div>
</div>
<Trackpad />
<div className="h-2 w-20 mx-auto inset-x-0 absolute bottom-0 bg-gradient-to-t from-[#272729] to-[#050505] rounded-tr-3xl rounded-tl-3xl" />
{showGradient && (
<div className="h-40 w-full absolute bottom-0 inset-x-0 bg-gradient-to-t dark:from-black from-white via-white dark:via-black to-transparent z-50"></div>
)}
{badge && <div className="absolute bottom-4 left-4">{badge}</div>}
</div>
</div>
</section>
);
};
export const Lid = ({
scaleX,
scaleY,
rotate,
translate,
src = mac, // Default to mac image
}: {
scaleX: MotionValue<number>;
scaleY: MotionValue<number>;
rotate: MotionValue<number>;
translate: MotionValue<number>;
src?: StaticImageData;
}) => {
return (
<div className="relative [perspective:800px]">
{/* Static Lid Section */}
<div
style={{
transform: "perspective(800px) rotateX(-25deg) translateZ(0px)",
transformOrigin: "bottom",
transformStyle: "preserve-3d",
}}
className="h-[12rem] w-[32rem] bg-[#010101] rounded-2xl p-2 relative"
>
<div
style={{
boxShadow: "0px 2px 0px 2px var(--neutral-900) inset",
}}
className="absolute inset-0 bg-[#010101] rounded-lg flex items-center justify-center"
>
<span className="text-white">
<AceternityLogo />
</span>
</div>
</div>
{/* Motion Lid Section */}
<motion.div
style={{
scaleX: scaleX,
scaleY: scaleY,
rotateX: rotate,
translateY: translate,
transformStyle: "preserve-3d",
transformOrigin: "top",
}}
className="h-96 w-[32rem] absolute inset-0 bg-[#010101] rounded-2xl p-2"
>
<div className="absolute inset-0 bg-[#272729] rounded-lg" />
{/* Image Section */}
<Link
href="/mac.png"
target="_blank"
className="h-full w-full object-cover"
>
<Image
src={src}
alt="EduViti"
width={640}
height={360}
priority
className="border border-primary/20 object-left-top absolute rounded-lg inset-0 h-full w-full object-cover"
/>
</Link>
{/* Blur Effect */}
<div className="absolute inset-x-0 h-full w-full scale-150 -z-50 rounded-full bg-[#60a5fa09] to-transparent blur-3xl" />
</motion.div>
</div>
);
};
export const Trackpad = () => {
return (
<div
className="w-[40%] mx-auto h-32 rounded-xl my-1"
style={{
boxShadow: "0px 0px 1px 1px #00000020 inset",
}}
></div>
);
};
export const Keypad = () => {
return (
<div className="h-full rounded-md bg-[#050505] mx-1 p-1">
{/* First Row */}
<Row>
<KBtn
className="w-10 items-end justify-start pl-[4px] pb-[2px]"
childrenClassName="items-start"
>
esc
</KBtn>
<KBtn>
<IconBrightnessDown className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F1</span>
</KBtn>
<KBtn>
<IconBrightnessUp className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F2</span>
</KBtn>
<KBtn>
<IconTable className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F3</span>
</KBtn>
<KBtn>
<IconSearch className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F4</span>
</KBtn>
<KBtn>
<IconMicrophone className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F5</span>
</KBtn>
<KBtn>
<IconMoon className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F6</span>
</KBtn>
<KBtn>
<IconPlayerTrackPrev className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F7</span>
</KBtn>
<KBtn>
<IconPlayerSkipForward className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F8</span>
</KBtn>
<KBtn>
<IconPlayerTrackNext className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F8</span>
</KBtn>
<KBtn>
<IconVolume3 className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F10</span>
</KBtn>
<KBtn>
<IconVolume2 className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F11</span>
</KBtn>
<KBtn>
<IconVolume className="h-[6px] w-[6px]" />
<span className="inline-block mt-1">F12</span>
</KBtn>
<KBtn>
<div className="h-4 w-4 rounded-full bg-gradient-to-b from-20% from-neutral-900 via-black via-50% to-neutral-900 to-95% p-px">
<div className="bg-black h-full w-full rounded-full" />
</div>
</KBtn>
</Row>
{/* Second row */}
<Row>
<KBtn>
<span className="block">~</span>
<span className="block mt-1">`</span>
</KBtn>
<KBtn>
<span className="block ">!</span>
<span className="block">1</span>
</KBtn>
<KBtn>
<span className="block">@</span>
<span className="block">2</span>
</KBtn>
<KBtn>
<span className="block">#</span>
<span className="block">3</span>
</KBtn>
<KBtn>
<span className="block">$</span>
<span className="block">4</span>
</KBtn>
<KBtn>
<span className="block">%</span>
<span className="block">5</span>
</KBtn>
<KBtn>
<span className="block">^</span>
<span className="block">6</span>
</KBtn>
<KBtn>
<span className="block">&</span>
<span className="block">7</span>
</KBtn>
<KBtn>
<span className="block">*</span>
<span className="block">8</span>
</KBtn>
<KBtn>
<span className="block">(</span>
<span className="block">9</span>
</KBtn>
<KBtn>
<span className="block">)</span>
<span className="block">0</span>
</KBtn>
<KBtn>
<span className="block">—</span>
<span className="block">_</span>
</KBtn>
<KBtn>
<span className="block">+</span>
<span className="block"> = </span>
</KBtn>
<KBtn
className="w-10 items-end justify-end pr-[4px] pb-[2px]"
childrenClassName="items-end"
>
delete
</KBtn>
</Row>
{/* Third row */}
<Row>
<KBtn
className="w-10 items-end justify-start pl-[4px] pb-[2px]"
childrenClassName="items-start"
>
tab
</KBtn>
<KBtn>
<span className="block">Q</span>
</KBtn>
<KBtn>
<span className="block">W</span>
</KBtn>
<KBtn>
<span className="block">E</span>
</KBtn>
<KBtn>
<span className="block">R</span>
</KBtn>
<KBtn>
<span className="block">T</span>
</KBtn>
<KBtn>
<span className="block">Y</span>
</KBtn>
<KBtn>
<span className="block">U</span>
</KBtn>
<KBtn>
<span className="block">I</span>
</KBtn>
<KBtn>
<span className="block">O</span>
</KBtn>
<KBtn>
<span className="block">P</span>
</KBtn>
<KBtn>
<span className="block">{`{`}</span>
<span className="block">{`[`}</span>
</KBtn>
<KBtn>
<span className="block">{`}`}</span>
<span className="block">{`]`}</span>
</KBtn>
<KBtn>
<span className="block">{`|`}</span>
<span className="block">{`\\`}</span>
</KBtn>
</Row>
{/* Fourth Row */}
<Row>
<KBtn
className="w-[2.8rem] items-end justify-start pl-[4px] pb-[2px]"
childrenClassName="items-start"
>
caps lock
</KBtn>
<KBtn>
<span className="block">A</span>
</KBtn>
<KBtn>
<span className="block">S</span>
</KBtn>
<KBtn>
<span className="block">D</span>
</KBtn>
<KBtn>
<span className="block">F</span>
</KBtn>
<KBtn>
<span className="block">G</span>
</KBtn>
<KBtn>
<span className="block">H</span>
</KBtn>
<KBtn>
<span className="block">J</span>
</KBtn>
<KBtn>
<span className="block">K</span>
</KBtn>
<KBtn>
<span className="block">L</span>
</KBtn>
<KBtn>
<span className="block">{`:`}</span>
<span className="block">{`;`}</span>
</KBtn>
<KBtn>
<span className="block">{`"`}</span>
<span className="block">{`'`}</span>
</KBtn>
<KBtn
className="w-[2.85rem] items-end justify-end pr-[4px] pb-[2px]"
childrenClassName="items-end"
>
return
</KBtn>
</Row>
{/* Fifth Row */}
<Row>
<KBtn
className="w-[3.65rem] items-end justify-start pl-[4px] pb-[2px]"
childrenClassName="items-start"
>
shift
</KBtn>
<KBtn>
<span className="block">Z</span>
</KBtn>
<KBtn>
<span className="block">X</span>
</KBtn>
<KBtn>
<span className="block">C</span>
</KBtn>
<KBtn>
<span className="block">V</span>
</KBtn>
<KBtn>
<span className="block">B</span>
</KBtn>
<KBtn>
<span className="block">N</span>
</KBtn>
<KBtn>
<span className="block">M</span>
</KBtn>
<KBtn>
<span className="block">{`<`}</span>
<span className="block">{`,`}</span>
</KBtn>
<KBtn>
<span className="block">{`>`}</span>
<span className="block">{`.`}</span>
</KBtn>{" "}
<KBtn>
<span className="block">{`?`}</span>
<span className="block">{`/`}</span>
</KBtn>
<KBtn
className="w-[3.65rem] items-end justify-end pr-[4px] pb-[2px]"
childrenClassName="items-end"
>
shift
</KBtn>
</Row>
{/* sixth Row */}
<Row>
<KBtn className="" childrenClassName="h-full justify-between py-[4px]">
<div className="flex justify-end w-full pr-1">
<span className="block">fn</span>
</div>
<div className="flex justify-start w-full pl-1">
<IconWorld className="h-[6px] w-[6px]" />
</div>
</KBtn>
<KBtn className="" childrenClassName="h-full justify-between py-[4px]">
<div className="flex justify-end w-full pr-1">
<IconChevronUp className="h-[6px] w-[6px]" />
</div>
<div className="flex justify-start w-full pl-1">
<span className="block">control</span>
</div>
</KBtn>
<KBtn className="" childrenClassName="h-full justify-between py-[4px]">
<div className="flex justify-end w-full pr-1">
<OptionKey className="h-[6px] w-[6px]" />
</div>
<div className="flex justify-start w-full pl-1">
<span className="block">option</span>
</div>
</KBtn>
<KBtn
className="w-8"
childrenClassName="h-full justify-between py-[4px]"
>
<div className="flex justify-end w-full pr-1">
<IconCommand className="h-[6px] w-[6px]" />
</div>
<div className="flex justify-start w-full pl-1">
<span className="block">command</span>
</div>
</KBtn>
<KBtn className="w-[8.2rem]"></KBtn>
<KBtn
className="w-8"
childrenClassName="h-full justify-between py-[4px]"
>
<div className="flex justify-start w-full pl-1">
<IconCommand className="h-[6px] w-[6px]" />
</div>
<div className="flex justify-start w-full pl-1">
<span className="block">command</span>
</div>
</KBtn>
<KBtn className="" childrenClassName="h-full justify-between py-[4px]">
<div className="flex justify-start w-full pl-1">
<OptionKey className="h-[6px] w-[6px]" />
</div>
<div className="flex justify-start w-full pl-1">
<span className="block">option</span>
</div>
</KBtn>
<div className="w-[4.9rem] mt-[2px] h-6 p-[0.5px] rounded-[4px] flex flex-col justify-end items-center">
<KBtn className="w-6 h-3">
<IconCaretUpFilled className="h-[6px] w-[6px]" />
</KBtn>
<div className="flex">
<KBtn className="w-6 h-3">
<IconCaretLeftFilled className="h-[6px] w-[6px]" />
</KBtn>
<KBtn className="w-6 h-3">
<IconCaretDownFilled className="h-[6px] w-[6px]" />
</KBtn>
<KBtn className="w-6 h-3">
<IconCaretRightFilled className="h-[6px] w-[6px]" />
</KBtn>
</div>
</div>
</Row>
</div>
);
};
export const KBtn = ({
className,
children,
childrenClassName,
backlit = true,
}: {
className?: string;
children?: React.ReactNode;
childrenClassName?: string;
backlit?: boolean;
}) => {
return (
<div
className={cn(
"p-[0.5px] rounded-[4px]",
backlit && "bg-white/[0.2] shadow-xl shadow-white/50",
)}
>
<div
className={cn(
"h-6 w-6 bg-[#0A090D] rounded-[3.5px] flex items-center justify-center",
className,
)}
style={{
boxShadow:
"0px -0.5px 2px 0 #0D0D0F inset, -0.5px 0px 2px 0 #0D0D0F inset",
}}
>
<div
className={cn(
"text-neutral-200 text-[5px] w-full flex justify-center items-center flex-col",
childrenClassName,
backlit && "text-white",
)}
>
{children}
</div>
</div>
</div>
);
};
export const Row = ({ children }: { children: React.ReactNode }) => {
return (
<div className="flex gap-[2px] mb-[2px] w-full flex-shrink-0">
{children}
</div>
);
};
export const OptionKey = ({ className }: { className: string }) => {
return (
<svg
fill="none"
version="1.1"
id="icon"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 32 32"
className={className}
>
<rect
stroke="currentColor"
strokeWidth={2}
x="18"
y="5"
width="10"
height="2"
/>
<polygon
stroke="currentColor"
strokeWidth={2}
points="10.6,5 4,5 4,7 9.4,7 18.4,27 28,27 28,25 19.6,25 "
/>
<rect
id="_Transparent_Rectangle_"
className="st0"
width="32"
height="32"
stroke="none"
/>
</svg>
);
};
const AceternityLogo = () => {
return (
<div className="top-0 left-0 w-full h-full flex justify-center items-center">
<Image
src={nav_logo}
alt="EduViti Logo"
width={150}
height={150}
style={{ transform: "rotateX(-25deg)" }}
className="object-contain shadow-lg rounded-lg h-24 w-24 opacity-25"
/>
</div>
);
};