@launchui/launch-ui 1.0.0 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,611 @@
1
+ "use client";
2
+
3
+ import React, { useEffect, useMemo, useRef, useState } from "react";
4
+ import { MotionValue, motion, useScroll, useTransform } from "motion/react";
5
+ import {
6
+ IconBrightnessDown,
7
+ IconBrightnessUp,
8
+ IconCaretRightFilled,
9
+ IconCaretUpFilled,
10
+ IconChevronUp,
11
+ IconMicrophone,
12
+ IconMoon,
13
+ IconPlayerSkipForward,
14
+ IconPlayerTrackNext,
15
+ IconPlayerTrackPrev,
16
+ IconTable,
17
+ IconVolume,
18
+ IconVolume2,
19
+ IconVolume3,
20
+ IconSearch,
21
+ IconWorld,
22
+ IconCommand,
23
+ IconCaretLeftFilled,
24
+ IconCaretDownFilled,
25
+ } from "@tabler/icons-react";
26
+
27
+ /**
28
+ * Internal utility replacing external lib requirements ensuring zero-friction installations.
29
+ */
30
+ const cn = (...classes: any[]) => {
31
+ return classes.filter(Boolean).join(" ");
32
+ };
33
+
34
+ export const MacbookScroll = ({
35
+ src,
36
+ showGradient,
37
+ title,
38
+ badge,
39
+ }: {
40
+ src?: string;
41
+ showGradient?: boolean;
42
+ title?: string | React.ReactNode;
43
+ badge?: React.ReactNode;
44
+ }) => {
45
+ const ref = useRef<HTMLDivElement>(null);
46
+ const { scrollYProgress } = useScroll({
47
+ target: ref,
48
+ offset: ["start start", "end start"],
49
+ });
50
+
51
+ const [isMobile, setIsMobile] = useState(false);
52
+
53
+ useEffect(() => {
54
+ if (typeof window !== "undefined" && window.innerWidth < 768) {
55
+ setIsMobile(true);
56
+ }
57
+ }, []);
58
+
59
+ const scaleX = useTransform(
60
+ scrollYProgress,
61
+ [0, 0.3],
62
+ [1.2, isMobile ? 1 : 1.5],
63
+ );
64
+ const scaleY = useTransform(
65
+ scrollYProgress,
66
+ [0, 0.3],
67
+ [0.6, isMobile ? 1 : 1.5],
68
+ );
69
+ const translate = useTransform(scrollYProgress, [0, 1], [0, 1500]);
70
+ const rotate = useTransform(scrollYProgress, [0.1, 0.12, 0.3], [-28, -28, 0]);
71
+ const textTransform = useTransform(scrollYProgress, [0, 0.3], [0, 100]);
72
+ const textOpacity = useTransform(scrollYProgress, [0, 0.2], [1, 0]);
73
+
74
+ return (
75
+ <div
76
+ ref={ref}
77
+ className="flex min-h-[200vh] shrink-0 scale-[0.35] transform flex-col items-center justify-start py-0 [perspective:800px] sm:scale-50 md:scale-100 md:py-80"
78
+ >
79
+ <motion.h2
80
+ style={{
81
+ translateY: textTransform,
82
+ opacity: textOpacity,
83
+ }}
84
+ className="mb-20 text-center text-3xl font-bold text-neutral-800 dark:text-white"
85
+ >
86
+ {title || (
87
+ <span>
88
+ This Macbook is built with Tailwindcss. <br /> No kidding.
89
+ </span>
90
+ )}
91
+ </motion.h2>
92
+ {/* Lid */}
93
+ <Lid
94
+ src={src}
95
+ scaleX={scaleX}
96
+ scaleY={scaleY}
97
+ rotate={rotate}
98
+ translate={translate}
99
+ />
100
+ {/* Base area */}
101
+ <div className="relative -z-10 h-[22rem] w-[32rem] overflow-hidden rounded-2xl bg-gray-200 dark:bg-[#272729]">
102
+ {/* above keyboard bar */}
103
+ <div className="relative h-10 w-full">
104
+ <div className="absolute inset-x-0 mx-auto h-4 w-[80%] bg-[#050505]" />
105
+ </div>
106
+ <div className="relative flex">
107
+ <div className="mx-auto h-full w-[10%] overflow-hidden">
108
+ <SpeakerGrid />
109
+ </div>
110
+ <div className="mx-auto h-full w-[80%]">
111
+ <Keypad />
112
+ </div>
113
+ <div className="mx-auto h-full w-[10%] overflow-hidden">
114
+ <SpeakerGrid />
115
+ </div>
116
+ </div>
117
+ <Trackpad />
118
+ <div className="absolute inset-x-0 bottom-0 mx-auto h-2 w-20 rounded-tl-3xl rounded-tr-3xl bg-gradient-to-t from-[#272729] to-[#050505]" />
119
+ {showGradient && (
120
+ <div className="absolute inset-x-0 bottom-0 z-50 h-40 w-full bg-gradient-to-t from-white via-white to-transparent dark:from-black dark:via-black"></div>
121
+ )}
122
+ {badge && <div className="absolute bottom-4 left-4">{badge}</div>}
123
+ </div>
124
+ </div>
125
+ );
126
+ };
127
+
128
+ export const Lid = ({
129
+ scaleX,
130
+ scaleY,
131
+ rotate,
132
+ translate,
133
+ src,
134
+ }: {
135
+ scaleX: MotionValue<number>;
136
+ scaleY: MotionValue<number>;
137
+ rotate: MotionValue<number>;
138
+ translate: MotionValue<number>;
139
+ src?: string;
140
+ }) => {
141
+ return (
142
+ <div className="relative [perspective:800px]">
143
+ <div
144
+ style={{
145
+ transform: "perspective(800px) rotateX(-25deg) translateZ(0px)",
146
+ transformOrigin: "bottom",
147
+ transformStyle: "preserve-3d",
148
+ }}
149
+ className="relative h-[12rem] w-[32rem] rounded-2xl bg-[#010101] p-2"
150
+ >
151
+ <div
152
+ style={{
153
+ boxShadow: "0px 2px 0px 2px #171717 inset",
154
+ }}
155
+ className="absolute inset-0 flex items-center justify-center rounded-lg bg-[#010101]"
156
+ >
157
+ <span className="text-white">
158
+ <AceternityLogo />
159
+ </span>
160
+ </div>
161
+ </div>
162
+ <motion.div
163
+ style={{
164
+ scaleX: scaleX,
165
+ scaleY: scaleY,
166
+ rotateX: rotate,
167
+ translateY: translate,
168
+ transformStyle: "preserve-3d",
169
+ transformOrigin: "top",
170
+ }}
171
+ className="absolute inset-0 h-96 w-[32rem] rounded-2xl bg-[#010101] p-2"
172
+ >
173
+ <div className="absolute inset-0 rounded-lg bg-[#272729]" />
174
+ {src && (
175
+ <img
176
+ src={src}
177
+ alt="viewport content"
178
+ className="absolute inset-0 h-full w-full rounded-lg object-cover object-left-top"
179
+ />
180
+ )}
181
+ </motion.div>
182
+ </div>
183
+ );
184
+ };
185
+
186
+ export const Trackpad = () => {
187
+ return (
188
+ <div
189
+ className="mx-auto my-1 h-32 w-[40%] rounded-xl"
190
+ style={{
191
+ boxShadow: "0px 0px 1px 1px #00000020 inset",
192
+ }}
193
+ ></div>
194
+ );
195
+ };
196
+
197
+ export const Keypad = () => {
198
+ return (
199
+ <div className="mx-1 h-full [transform:translateZ(0)] rounded-md bg-[#050505] p-1 [will-change:transform]">
200
+ {/* First Row */}
201
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
202
+ <KBtn
203
+ className="w-10 items-end justify-start pb-[2px] pl-[4px]"
204
+ childrenClassName="items-start"
205
+ >
206
+ esc
207
+ </KBtn>
208
+ <KBtn>
209
+ <IconBrightnessDown className="h-[6px] w-[6px]" />
210
+ <span className="mt-1 inline-block">F1</span>
211
+ </KBtn>
212
+ <KBtn>
213
+ <IconBrightnessUp className="h-[6px] w-[6px]" />
214
+ <span className="mt-1 inline-block">F2</span>
215
+ </KBtn>
216
+ <KBtn>
217
+ <IconTable className="h-[6px] w-[6px]" />
218
+ <span className="mt-1 inline-block">F3</span>
219
+ </KBtn>
220
+ <KBtn>
221
+ <IconSearch className="h-[6px] w-[6px]" />
222
+ <span className="mt-1 inline-block">F4</span>
223
+ </KBtn>
224
+ <KBtn>
225
+ <IconMicrophone className="h-[6px] w-[6px]" />
226
+ <span className="mt-1 inline-block">F5</span>
227
+ </KBtn>
228
+ <KBtn>
229
+ <IconMoon className="h-[6px] w-[6px]" />
230
+ <span className="mt-1 inline-block">F6</span>
231
+ </KBtn>
232
+ <KBtn>
233
+ <IconPlayerTrackPrev className="h-[6px] w-[6px]" />
234
+ <span className="mt-1 inline-block">F7</span>
235
+ </KBtn>
236
+ <KBtn>
237
+ <IconPlayerSkipForward className="h-[6px] w-[6px]" />
238
+ <span className="mt-1 inline-block">F8</span>
239
+ </KBtn>
240
+ <KBtn>
241
+ <IconPlayerTrackNext className="h-[6px] w-[6px]" />
242
+ <span className="mt-1 inline-block">F9</span>
243
+ </KBtn>
244
+ <KBtn>
245
+ <IconVolume3 className="h-[6px] w-[6px]" />
246
+ <span className="mt-1 inline-block">F10</span>
247
+ </KBtn>
248
+ <KBtn>
249
+ <IconVolume2 className="h-[6px] w-[6px]" />
250
+ <span className="mt-1 inline-block">F11</span>
251
+ </KBtn>
252
+ <KBtn>
253
+ <IconVolume className="h-[6px] w-[6px]" />
254
+ <span className="mt-1 inline-block">F12</span>
255
+ </KBtn>
256
+ <KBtn>
257
+ <div className="h-4 w-4 rounded-full bg-gradient-to-b from-neutral-900 from-20% via-black via-50% to-neutral-900 to-95% p-px">
258
+ <div className="h-full w-full rounded-full bg-black" />
259
+ </div>
260
+ </KBtn>
261
+ </div>
262
+
263
+ {/* Second row */}
264
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
265
+ <KBtn>
266
+ <span className="block">~</span>
267
+ <span className="mt-1 block">`</span>
268
+ </KBtn>
269
+ <KBtn>
270
+ <span className="block">!</span>
271
+ <span className="block">1</span>
272
+ </KBtn>
273
+ <KBtn>
274
+ <span className="block">@</span>
275
+ <span className="block">2</span>
276
+ </KBtn>
277
+ <KBtn>
278
+ <span className="block">#</span>
279
+ <span className="block">3</span>
280
+ </KBtn>
281
+ <KBtn>
282
+ <span className="block">$</span>
283
+ <span className="block">4</span>
284
+ </KBtn>
285
+ <KBtn>
286
+ <span className="block">%</span>
287
+ <span className="block">5</span>
288
+ </KBtn>
289
+ <KBtn>
290
+ <span className="block">^</span>
291
+ <span className="block">6</span>
292
+ </KBtn>
293
+ <KBtn>
294
+ <span className="block">&</span>
295
+ <span className="block">7</span>
296
+ </KBtn>
297
+ <KBtn>
298
+ <span className="block">*</span>
299
+ <span className="block">8</span>
300
+ </KBtn>
301
+ <KBtn>
302
+ <span className="block">(</span>
303
+ <span className="block">9</span>
304
+ </KBtn>
305
+ <KBtn>
306
+ <span className="block">)</span>
307
+ <span className="block">0</span>
308
+ </KBtn>
309
+ <KBtn>
310
+ <span className="block">&mdash;</span>
311
+ <span className="block">_</span>
312
+ </KBtn>
313
+ <KBtn>
314
+ <span className="block">+</span>
315
+ <span className="block"> = </span>
316
+ </KBtn>
317
+ <KBtn
318
+ className="w-10 items-end justify-end pr-[4px] pb-[2px]"
319
+ childrenClassName="items-end"
320
+ >
321
+ delete
322
+ </KBtn>
323
+ </div>
324
+
325
+ {/* Third row */}
326
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
327
+ <KBtn
328
+ className="w-10 items-end justify-start pb-[2px] pl-[4px]"
329
+ childrenClassName="items-start"
330
+ >
331
+ tab
332
+ </KBtn>
333
+ <KBtn><span className="block">Q</span></KBtn>
334
+ <KBtn><span className="block">W</span></KBtn>
335
+ <KBtn><span className="block">E</span></KBtn>
336
+ <KBtn><span className="block">R</span></KBtn>
337
+ <KBtn><span className="block">T</span></KBtn>
338
+ <KBtn><span className="block">Y</span></KBtn>
339
+ <KBtn><span className="block">U</span></KBtn>
340
+ <KBtn><span className="block">I</span></KBtn>
341
+ <KBtn><span className="block">O</span></KBtn>
342
+ <KBtn><span className="block">P</span></KBtn>
343
+ <KBtn>
344
+ <span className="block">{`{`}</span>
345
+ <span className="block">{`[`}</span>
346
+ </KBtn>
347
+ <KBtn>
348
+ <span className="block">{`}`}</span>
349
+ <span className="block">{`]`}</span>
350
+ </KBtn>
351
+ <KBtn>
352
+ <span className="block">{`|`}</span>
353
+ <span className="block">{`\\`}</span>
354
+ </KBtn>
355
+ </div>
356
+
357
+ {/* Fourth Row */}
358
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
359
+ <KBtn
360
+ className="w-[2.8rem] items-end justify-start pb-[2px] pl-[4px]"
361
+ childrenClassName="items-start"
362
+ >
363
+ caps lock
364
+ </KBtn>
365
+ <KBtn><span className="block">A</span></KBtn>
366
+ <KBtn><span className="block">S</span></KBtn>
367
+ <KBtn><span className="block">D</span></KBtn>
368
+ <KBtn><span className="block">F</span></KBtn>
369
+ <KBtn><span className="block">G</span></KBtn>
370
+ <KBtn><span className="block">H</span></KBtn>
371
+ <KBtn><span className="block">J</span></KBtn>
372
+ <KBtn><span className="block">K</span></KBtn>
373
+ <KBtn><span className="block">L</span></KBtn>
374
+ <KBtn>
375
+ <span className="block">{`:`}</span>
376
+ <span className="block">{`;`}</span>
377
+ </KBtn>
378
+ <KBtn>
379
+ <span className="block">{`"`}</span>
380
+ <span className="block">{`'`}</span>
381
+ </KBtn>
382
+ <KBtn
383
+ className="w-[2.85rem] items-end justify-end pr-[4px] pb-[2px]"
384
+ childrenClassName="items-end"
385
+ >
386
+ return
387
+ </KBtn>
388
+ </div>
389
+
390
+ {/* Fifth Row */}
391
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
392
+ <KBtn
393
+ className="w-[3.65rem] items-end justify-start pb-[2px] pl-[4px]"
394
+ childrenClassName="items-start"
395
+ >
396
+ shift
397
+ </KBtn>
398
+ <KBtn><span className="block">Z</span></KBtn>
399
+ <KBtn><span className="block">X</span></KBtn>
400
+ <KBtn><span className="block">C</span></KBtn>
401
+ <KBtn><span className="block">V</span></KBtn>
402
+ <KBtn><span className="block">B</span></KBtn>
403
+ <KBtn><span className="block">N</span></KBtn>
404
+ <KBtn><span className="block">M</span></KBtn>
405
+ <KBtn>
406
+ <span className="block">{`<`}</span>
407
+ <span className="block">{`,`}</span>
408
+ </KBtn>
409
+ <KBtn>
410
+ <span className="block">{`>`}</span>
411
+ <span className="block">{`.`}</span>
412
+ </KBtn>
413
+ <KBtn>
414
+ <span className="block">{`?`}</span>
415
+ <span className="block">{`/`}</span>
416
+ </KBtn>
417
+ <KBtn
418
+ className="w-[3.65rem] items-end justify-end pr-[4px] pb-[2px]"
419
+ childrenClassName="items-end"
420
+ >
421
+ shift
422
+ </KBtn>
423
+ </div>
424
+
425
+ {/* sixth Row */}
426
+ <div className="mb-[2px] flex w-full shrink-0 gap-[2px]">
427
+ <KBtn className="" childrenClassName="h-full justify-between py-[4px]">
428
+ <div className="flex w-full justify-end pr-1">
429
+ <span className="block">fn</span>
430
+ </div>
431
+ <div className="flex w-full justify-start pl-1">
432
+ <IconWorld className="h-[6px] w-[6px]" />
433
+ </div>
434
+ </KBtn>
435
+ <KBtn className="" childrenClassName="h-full justify-between py-[4px]">
436
+ <div className="flex w-full justify-end pr-1">
437
+ <IconChevronUp className="h-[6px] w-[6px]" />
438
+ </div>
439
+ <div className="flex w-full justify-start pl-1">
440
+ <span className="block">control</span>
441
+ </div>
442
+ </KBtn>
443
+ <KBtn className="" childrenClassName="h-full justify-between py-[4px]">
444
+ <div className="flex w-full justify-end pr-1">
445
+ <OptionKey className="h-[6px] w-[6px]" />
446
+ </div>
447
+ <div className="flex w-full justify-start pl-1">
448
+ <span className="block">option</span>
449
+ </div>
450
+ </KBtn>
451
+ <KBtn
452
+ className="w-8"
453
+ childrenClassName="h-full justify-between py-[4px]"
454
+ >
455
+ <div className="flex w-full justify-end pr-1">
456
+ <IconCommand className="h-[6px] w-[6px]" />
457
+ </div>
458
+ <div className="flex w-full justify-start pl-1">
459
+ <span className="block">command</span>
460
+ </div>
461
+ </KBtn>
462
+ <KBtn className="w-[8.2rem]"></KBtn>
463
+ <KBtn
464
+ className="w-8"
465
+ childrenClassName="h-full justify-between py-[4px]"
466
+ >
467
+ <div className="flex w-full justify-start pl-1">
468
+ <IconCommand className="h-[6px] w-[6px]" />
469
+ </div>
470
+ <div className="flex w-full justify-start pl-1">
471
+ <span className="block">command</span>
472
+ </div>
473
+ </KBtn>
474
+ <KBtn className="" childrenClassName="h-full justify-between py-[4px]">
475
+ <div className="flex w-full justify-start pl-1">
476
+ <OptionKey className="h-[6px] w-[6px]" />
477
+ </div>
478
+ <div className="flex w-full justify-start pl-1">
479
+ <span className="block">option</span>
480
+ </div>
481
+ </KBtn>
482
+ <div className="mt-[2px] flex h-6 w-[4.9rem] flex-col items-center justify-end rounded-[4px] p-[0.5px]">
483
+ <KBtn className="h-3 w-6">
484
+ <IconCaretUpFilled className="h-[6px] w-[6px]" />
485
+ </KBtn>
486
+ <div className="flex">
487
+ <KBtn className="h-3 w-6">
488
+ <IconCaretLeftFilled className="h-[6px] w-[6px]" />
489
+ </KBtn>
490
+ <KBtn className="h-3 w-6">
491
+ <IconCaretDownFilled className="h-[6px] w-[6px]" />
492
+ </KBtn>
493
+ <KBtn className="h-3 w-6">
494
+ <IconCaretRightFilled className="h-[6px] w-[6px]" />
495
+ </KBtn>
496
+ </div>
497
+ </div>
498
+ </div>
499
+ </div>
500
+ );
501
+ };
502
+
503
+ export const KBtn = ({
504
+ className,
505
+ children,
506
+ childrenClassName,
507
+ backlit = true,
508
+ }: {
509
+ className?: string;
510
+ children?: React.ReactNode;
511
+ childrenClassName?: string;
512
+ backlit?: boolean;
513
+ }) => {
514
+ return (
515
+ <div
516
+ className={cn(
517
+ "[transform:translateZ(0)] rounded-[4px] p-[0.5px] [will-change:transform]",
518
+ backlit && "bg-white/[0.2] shadow-xl shadow-white",
519
+ )}
520
+ >
521
+ <div
522
+ className={cn(
523
+ "flex h-6 w-6 items-center justify-center rounded-[3.5px] bg-[#0A090D]",
524
+ className,
525
+ )}
526
+ style={{
527
+ boxShadow:
528
+ "0px -0.5px 2px 0 #0D0D0F inset, -0.5px 0px 2px 0 #0D0D0F inset",
529
+ }}
530
+ >
531
+ <div
532
+ className={cn(
533
+ "flex w-full flex-col items-center justify-center text-[5px] text-neutral-200",
534
+ childrenClassName,
535
+ backlit && "text-white",
536
+ )}
537
+ >
538
+ {children}
539
+ </div>
540
+ </div>
541
+ </div>
542
+ );
543
+ };
544
+
545
+ export const SpeakerGrid = () => {
546
+ return (
547
+ <div
548
+ className="mt-2 flex h-40 gap-[2px] px-[0.5px]"
549
+ style={{
550
+ backgroundImage:
551
+ "radial-gradient(circle, #08080A 0.5px, transparent 0.5px)",
552
+ backgroundSize: "3px 3px",
553
+ }}
554
+ ></div>
555
+ );
556
+ };
557
+
558
+ export const OptionKey = ({ className }: { className: string }) => {
559
+ return (
560
+ <svg
561
+ fill="none"
562
+ version="1.1"
563
+ id="icon"
564
+ xmlns="http://www.w3.org/2000/svg"
565
+ viewBox="0 0 32 32"
566
+ className={className}
567
+ >
568
+ <rect
569
+ stroke="currentColor"
570
+ strokeWidth={2}
571
+ x="18"
572
+ y="5"
573
+ width="10"
574
+ height="2"
575
+ />
576
+ <polygon
577
+ stroke="currentColor"
578
+ strokeWidth={2}
579
+ points="10.6,5 4,5 4,7 9.4,7 18.4,27 28,27 28,25 19.6,25 "
580
+ />
581
+ <rect
582
+ id="_Transparent_Rectangle_"
583
+ className="st0"
584
+ width="32"
585
+ height="32"
586
+ stroke="none"
587
+ />
588
+ </svg>
589
+ );
590
+ };
591
+
592
+ const AceternityLogo = () => {
593
+ return (
594
+ <svg
595
+ width="66"
596
+ height="65"
597
+ viewBox="0 0 66 65"
598
+ fill="none"
599
+ xmlns="http://www.w3.org/2000/svg"
600
+ className="h-3 w-3 text-white"
601
+ >
602
+ <path
603
+ d="M8 8.05571C8 8.05571 54.9009 18.1782 57.8687 30.062C60.8365 41.9458 9.05432 57.4696 9.05432 57.4696"
604
+ stroke="currentColor"
605
+ strokeWidth="15"
606
+ strokeMiterlimit="3.86874"
607
+ strokeLinecap="round"
608
+ />
609
+ </svg>
610
+ );
611
+ };