@ghatak/slash-ui 1.0.0

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.
Files changed (66) hide show
  1. package/README.md +36 -0
  2. package/__registry__/index.ts +493 -0
  3. package/app/(auth)/layout.tsx +18 -0
  4. package/app/(auth)/login/page.tsx +152 -0
  5. package/app/(protected)/component/[id]/page.tsx +48 -0
  6. package/app/(protected)/component/page.tsx +151 -0
  7. package/app/(protected)/docs/page.tsx +222 -0
  8. package/app/account/page.tsx +109 -0
  9. package/app/api/me/route.ts +24 -0
  10. package/app/globals.css +68 -0
  11. package/app/icon.png +0 -0
  12. package/app/layout.tsx +43 -0
  13. package/app/page.tsx +22 -0
  14. package/app/pricing/page.tsx +12 -0
  15. package/bin/intex.ts +19 -0
  16. package/components/smooth-scroll.tsx +26 -0
  17. package/components/toast.tsx +101 -0
  18. package/components/ui/IndustryProof.tsx +159 -0
  19. package/components/ui/ShowcaseContainer.tsx +497 -0
  20. package/components/ui/dot-cursor.tsx +108 -0
  21. package/components/ui/featuredComponents.tsx +126 -0
  22. package/components/ui/footer.tsx +59 -0
  23. package/components/ui/hero.tsx +85 -0
  24. package/components/ui/navbar.tsx +337 -0
  25. package/components/ui/pricing.tsx +163 -0
  26. package/eslint.config.mjs +18 -0
  27. package/hooks/use-component-search.tsx +52 -0
  28. package/lib/actions/auth.action.ts +88 -0
  29. package/lib/auth.ts +18 -0
  30. package/lib/email.ts +46 -0
  31. package/lib/prisma.ts +14 -0
  32. package/lib/registry.ts +17 -0
  33. package/lib/utils.ts +6 -0
  34. package/middleware/middleware.ts +21 -0
  35. package/next.config.ts +7 -0
  36. package/package.json +61 -0
  37. package/postcss.config.mjs +7 -0
  38. package/prisma/migrations/20260303172729_init/migration.sql +21 -0
  39. package/prisma/migrations/migration_lock.toml +3 -0
  40. package/prisma/schema.prisma +22 -0
  41. package/prisma.config.ts +14 -0
  42. package/public/compVideos/neubrutal-button.mp4 +0 -0
  43. package/public/fonts/BeVietnamPro-ExtraBold.otf +0 -0
  44. package/public/fonts/CartographCF-Regular.ttf +0 -0
  45. package/public/fonts/Hoshiko-Satsuki.ttf +0 -0
  46. package/public/fonts/Switzer-Regular.otf +0 -0
  47. package/public/images/PricingSlash.svg +58 -0
  48. package/public/images/slash_1.svg +59 -0
  49. package/public/images/slash_2.svg +18 -0
  50. package/public/video/hero_video.mp4 +0 -0
  51. package/registry/details/buttons/neubrutal-button-details.tsx +146 -0
  52. package/registry/details/cursor/dot-cursor-details.tsx +11 -0
  53. package/registry/details/navbar/floating-navbar-details.tsx +11 -0
  54. package/registry/details/scrollbars/minimal-scrollbar-details.tsx +0 -0
  55. package/registry/index.ts +35 -0
  56. package/registry/ui/buttons/neubrutal-button.tsx +33 -0
  57. package/registry/ui/cursors/dot-cursor.tsx +108 -0
  58. package/registry/ui/navbars/floating-navbar.tsx +99 -0
  59. package/registry/ui/scrollbars/minimal-scrollbar.tsx +203 -0
  60. package/scripts/build-registry.ts +60 -0
  61. package/src/commands/add.ts +40 -0
  62. package/src/commands/init.ts +75 -0
  63. package/src/commands/list.ts +44 -0
  64. package/src/index.ts +35 -0
  65. package/src/utils/get-pkg-manager.ts +7 -0
  66. package/tsconfig.json +34 -0
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -0,0 +1,493 @@
1
+ // @ts-nocheck
2
+ // This file is autogenerated by scripts/build-registry.ts
3
+ import * as React from "react"
4
+
5
+ export const Index: Record<string, any> = {
6
+ "default": {
7
+ "neubrutal-button": {
8
+ name: "neubrutal-button",
9
+ type: "ui",
10
+ component: React.lazy(() => import("../registry/ui/buttons/neubrutal-button")),
11
+ details: null,
12
+ files: ["ui/buttons/neubrutal-button.tsx"],
13
+ category: "buttons",
14
+ content: `import React from 'react';
15
+ import { cn } from '@/lib/utils';
16
+
17
+ interface NeubrutalButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
18
+ children: React.ReactNode;
19
+ }
20
+
21
+ // 1. CHANGE THIS TO DEFAULT EXPORT
22
+ export default function NeubrutalButton({
23
+ children = 'Click Me!',
24
+ className,
25
+ ...props
26
+ }: NeubrutalButtonProps) {
27
+ return (
28
+ <button
29
+ {...props}
30
+ className={cn(
31
+ 'group relative w-[140px] h-[50px] bg-none outline-none border-none p-0 cursor-pointer active:translate-y-[2px] transition-transform',
32
+ className,
33
+ )}
34
+ >
35
+ <div className='absolute top-[14px] -left-[1px] w-[calc(100%+2px)] h-full bg-[#8c8c8c] rounded-[7mm] outline outline-2 outline-[#242622] -z-10' />
36
+ <div className='absolute top-[10px] left-0 w-full h-full bg-[#e5e5c7] rounded-[7mm] outline outline-2 outline-[#242622] -z-10'>
37
+ <div className='absolute bottom-0 left-[15%] w-[2px] h-[9px] bg-[#242622]' />
38
+ <div className='absolute bottom-0 left-[85%] w-[2px] h-[9px] bg-[#242622]' />
39
+ </div>
40
+ <div className='relative w-full h-full flex items-center justify-center bg-[#ffffee] rounded-[7mm] outline outline-2 outline-[#242622] text-[#242622] font-semibold text-base overflow-hidden transition-all duration-200 group-active:translate-y-[10px]'>
41
+ <div className='absolute top-0 -left-[20px] w-[15px] h-full bg-black/10 skew-x-[30deg] transition-all duration-300 group-active:left-[calc(100%+20px)]' />
42
+ {children}
43
+ </div>
44
+ </button>
45
+ );
46
+ }
47
+ `,
48
+ description: ``,
49
+ install: "npm install framer-motion lucide-react",
50
+ },
51
+ "dot-cursor": {
52
+ name: "dot-cursor",
53
+ type: "ui",
54
+ component: React.lazy(() => import("../registry/ui/cursors/dot-cursor")),
55
+ details: null,
56
+ files: ["ui/cursors/dot-cursor.tsx"],
57
+ category: "cursors",
58
+ content: `'use client';
59
+
60
+ import React, { useState, useEffect } from 'react';
61
+
62
+ const CustomCursor = () => {
63
+ const [position, setPosition] = useState({ x: 0, y: 0 });
64
+ const [isHovering, setIsHovering] = useState(false);
65
+ const [isDarkBackground, setIsDarkBackground] = useState(false);
66
+
67
+ useEffect(() => {
68
+
69
+ // document.body.style.cursor = 'none';
70
+
71
+ const updatePosition = (e: MouseEvent) => {
72
+ setPosition({ x: e.clientX, y: e.clientY });
73
+
74
+ const element = document.elementFromPoint(e.clientX, e.clientY);
75
+ if (element) {
76
+ const bgColor = window.getComputedStyle(element).backgroundColor;
77
+ const brightness = getBrightness(bgColor);
78
+ setIsDarkBackground(brightness < 128);
79
+ }
80
+ };
81
+
82
+ const handleMouseOver = (e: MouseEvent) => {
83
+ const target = e.target as HTMLElement;
84
+ if (
85
+ target.tagName === 'A' ||
86
+ target.tagName === 'BUTTON' ||
87
+ target.onclick !== null ||
88
+ window.getComputedStyle(target).cursor === 'pointer'
89
+ ) {
90
+ setIsHovering(true);
91
+ }
92
+ };
93
+
94
+ const handleMouseOut = () => {
95
+ setIsHovering(false);
96
+ };
97
+
98
+ window.addEventListener('mousemove', updatePosition);
99
+ document.addEventListener('mouseover', handleMouseOver);
100
+ document.addEventListener('mouseout', handleMouseOut);
101
+
102
+ return () => {
103
+ window.removeEventListener('mousemove', updatePosition);
104
+ document.removeEventListener('mouseover', handleMouseOver);
105
+ document.removeEventListener('mouseout', handleMouseOut);
106
+
107
+
108
+ };
109
+ }, []);
110
+
111
+ const getBrightness = (color: string) => {
112
+ const rgb = color.match(/\d+/g);
113
+ if (!rgb) return 255;
114
+ const r = parseInt(rgb[0]);
115
+ const g = parseInt(rgb[1]);
116
+ const b = parseInt(rgb[2]);
117
+ return (r * 299 + g * 587 + b * 114) / 1000;
118
+ };
119
+
120
+ return (
121
+ <div
122
+ style={{
123
+ cursor: 'none',
124
+ width: '100vw',
125
+ height: '100vh',
126
+ position: 'fixed',
127
+ top: 0,
128
+ left: 0,
129
+ pointerEvents: 'none'
130
+ }}>
131
+
132
+ <div
133
+ style={{
134
+ position: 'fixed',
135
+ left: \`\${position.x}px\`,
136
+ top: \`\${position.y}px\`,
137
+ pointerEvents: 'none',
138
+ transform: \`translate(-50%, -50%) scale(\${isHovering ? 1.5 : 1})\`,
139
+ transition: 'transform 0.2s ease',
140
+ zIndex: 9999,
141
+ }}
142
+ >
143
+ <svg
144
+ xmlns="http://www.w3.org/2000/svg"
145
+ width="24"
146
+ height="24"
147
+ viewBox="0 0 24 24"
148
+ style={{
149
+ display: 'block',
150
+ transition: 'all 0.2s ease',
151
+ }}
152
+ >
153
+ <path
154
+ fill={isDarkBackground ? '#ffffff' : '#000000'}
155
+ stroke={isDarkBackground ? '#000000' : '#ffffff'}
156
+ strokeWidth="2"
157
+ d="M5.5 3.21V20.8c0 .45.54.67.85.35l4.86-4.86a.5.5 0 0 1 .35-.15h6.87a.5.5 0 0 0 .35-.85L6.35 2.85a.5.5 0 0 0-.85.35Z"
158
+ />
159
+ </svg>
160
+ </div>
161
+ </div>
162
+ );
163
+ };
164
+
165
+ export default CustomCursor;`,
166
+ description: ``,
167
+ install: "npm install framer-motion",
168
+ },
169
+ "flaoting-navbar": {
170
+ name: "flaoting-navbar",
171
+ type: "ui",
172
+ component: React.lazy(() => import("../registry/ui/navbars/floating-navbar")),
173
+ details: null,
174
+ files: ["ui/navbars/floating-navbar.tsx"],
175
+ category: "navbars",
176
+ content: `'use client';
177
+
178
+ import React, { useState, useEffect } from 'react';
179
+ import Link from 'next/link';
180
+ import { motion, AnimatePresence } from 'framer-motion';
181
+ import { Sun, Moon } from 'lucide-react';
182
+
183
+ const Navbar = () => {
184
+ const [mounted, setMounted] = useState(false);
185
+ const [isDark, setIsDark] = useState(true);
186
+ const [scrolled, setScrolled] = useState(false);
187
+
188
+ useEffect(() => {
189
+ setMounted(true);
190
+ const handleScroll = () => setScrolled(window.scrollY > 20);
191
+ window.addEventListener('scroll', handleScroll);
192
+ return () => window.removeEventListener('scroll', handleScroll);
193
+ }, []);
194
+
195
+ const toggleTheme = () => {
196
+ setIsDark(!isDark);
197
+ document.documentElement.classList.toggle('dark');
198
+ };
199
+
200
+ const navLinks = [
201
+ { name: 'Archives', slug: 'work' },
202
+ { name: 'Capabilities', slug: 'service' },
203
+ { name: 'Ethos', slug: 'about' },
204
+ ];
205
+
206
+ if (!mounted) return null;
207
+
208
+ return (
209
+ <nav className='fixed top-0 left-0 w-full z-[100] flex justify-center pt-6 px-6 pointer-events-none mt-10'>
210
+ <motion.div
211
+ initial={{ y: -100 }}
212
+ animate={{ y: 0 }}
213
+ className={\`
214
+ flex items-center justify-between px-6 transition-all duration-500 pointer-events-auto
215
+ \${
216
+ scrolled
217
+ ? 'w-full md:w-[800px] h-14 bg-white/5 backdrop-blur-md border border-white/10 rounded-full shadow-2xl'
218
+ : 'w-full h-20 bg-transparent border-transparent'
219
+ }
220
+ \`}
221
+ >
222
+ <Link href='/' className='group flex items-center'>
223
+ <span className=' text-3xl uppercase tracking-wide font-bold'>
224
+ Renoh
225
+ </span>
226
+ </Link>
227
+
228
+ <div className='hidden md:flex items-center space-x-8'>
229
+ {navLinks.map((link) => (
230
+ <Link
231
+ key={link.slug}
232
+ href={\`/\${link.slug}\`}
233
+ className='text-[10px] font-plex uppercase tracking-[0.2em] text-zinc-400 hover:text-white transition-colors relative group'
234
+ >
235
+ {link.name}
236
+ <span className='absolute -bottom-1 left-0 w-0 h-px bg-white transition-all duration-500 group-hover:w-full' />
237
+ </Link>
238
+ ))}
239
+ </div>
240
+
241
+ <div className='flex items-center space-x-4'>
242
+ <button
243
+ onClick={toggleTheme}
244
+ className='p-2 hover:bg-white/10 rounded-full transition-colors text-white'
245
+ >
246
+ <AnimatePresence mode='wait'>
247
+ <motion.div
248
+ key={isDark ? 'dark' : 'light'}
249
+ initial={{ opacity: 0, rotate: -90 }}
250
+ animate={{ opacity: 1, rotate: 0 }}
251
+ exit={{ opacity: 0, rotate: 90 }}
252
+ transition={{ duration: 0.2 }}
253
+ >
254
+ {isDark ? <Sun size={16} /> : <Moon size={16} />}
255
+ </motion.div>
256
+ </AnimatePresence>
257
+ </button>
258
+
259
+ <Link href='/contact'>
260
+ <motion.div
261
+ whileHover={{ scale: 1.05 }}
262
+ whileTap={{ scale: 0.95 }}
263
+ className='px-4 py-2 bg-white text-black text-[10px] font-plex uppercase tracking-widest rounded-full'
264
+ >
265
+ Inquire
266
+ </motion.div>
267
+ </Link>
268
+ </div>
269
+ </motion.div>
270
+ </nav>
271
+ );
272
+ };
273
+
274
+ export default Navbar;
275
+ `,
276
+ description: ``,
277
+ install: "npm install lucide-react framer-motion gsap",
278
+ },
279
+ "minimal-scrollbar": {
280
+ name: "minimal-scrollbar",
281
+ type: "ui",
282
+ component: React.lazy(() => import("../registry/ui/scrollbars/minimal-scrollbar")),
283
+ details: null,
284
+ files: ["ui/scrollbars/minimal-scrollbar.tsx"],
285
+ category: "scrollbars",
286
+ content: `'use client';
287
+
288
+ import React, { useState, useEffect, useRef, useCallback } from 'react';
289
+ import { usePathname } from 'next/navigation';
290
+
291
+ const VisualScrollbar = () => {
292
+ const [thumbTop, setThumbTop] = useState(0);
293
+ const channelRef = useRef<HTMLDivElement>(null);
294
+ const thumbRef = useRef<HTMLDivElement>(null);
295
+ const tickingRef = useRef(false);
296
+ const measurementsRef = useRef({
297
+ height: 0,
298
+ thumbH: 0,
299
+ paddingTop: 0,
300
+ paddingBottom: 0,
301
+ available: 0,
302
+ });
303
+
304
+ // Hide scrollbar on contact page
305
+ const pathname = usePathname();
306
+ const shouldHide = pathname === '/contact';
307
+
308
+ const measure = useCallback(() => {
309
+ if (!channelRef.current || !thumbRef.current) return;
310
+
311
+ const chRect = channelRef.current.getBoundingClientRect();
312
+ const thumbRect = thumbRef.current.getBoundingClientRect();
313
+ const style = window.getComputedStyle(channelRef.current);
314
+
315
+ const height = chRect.height;
316
+ const thumbH = thumbRect.height;
317
+ const paddingTop = parseFloat(style.paddingTop) || 0;
318
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
319
+ const available = Math.max(
320
+ height - thumbH - (paddingTop + paddingBottom),
321
+ 0
322
+ );
323
+
324
+ measurementsRef.current = {
325
+ height,
326
+ thumbH,
327
+ paddingTop,
328
+ paddingBottom,
329
+ available,
330
+ };
331
+ }, []);
332
+
333
+ const updateThumb = useCallback(() => {
334
+ const scrollTop = window.scrollY;
335
+ const scrollHeight = document.documentElement.scrollHeight;
336
+ const clientHeight = document.documentElement.clientHeight;
337
+ const maxScroll = Math.max(scrollHeight - clientHeight, 1);
338
+ const scrollPercent = Math.min(Math.max(scrollTop / maxScroll, 0), 1);
339
+ const topPx =
340
+ measurementsRef.current.paddingTop +
341
+ scrollPercent * measurementsRef.current.available;
342
+
343
+ setThumbTop(topPx);
344
+ }, []);
345
+
346
+ useEffect(() => {
347
+ const handleScroll = () => {
348
+ if (!tickingRef.current) {
349
+ tickingRef.current = true;
350
+ requestAnimationFrame(() => {
351
+ updateThumb();
352
+ tickingRef.current = false;
353
+ });
354
+ }
355
+ };
356
+
357
+ let resizeTimeout: ReturnType<typeof setTimeout> | null = null;
358
+ const handleResize = () => {
359
+ if (resizeTimeout) clearTimeout(resizeTimeout);
360
+ resizeTimeout = setTimeout(() => {
361
+ measure();
362
+ updateThumb();
363
+ }, 150);
364
+ };
365
+
366
+ // Initial setup with small delay to ensure DOM is ready
367
+ const initTimeout = setTimeout(() => {
368
+ measure();
369
+ updateThumb();
370
+ }, 100);
371
+
372
+ window.addEventListener('scroll', handleScroll, { passive: true });
373
+ window.addEventListener('resize', handleResize, { passive: true });
374
+
375
+ return () => {
376
+ clearTimeout(initTimeout);
377
+ if (resizeTimeout) clearTimeout(resizeTimeout);
378
+ window.removeEventListener('scroll', handleScroll);
379
+ window.removeEventListener('resize', handleResize);
380
+ };
381
+ }, [measure, updateThumb]);
382
+
383
+ // Return null if on contact page
384
+ if (shouldHide) return null;
385
+
386
+ return (
387
+ <>
388
+ <style>{\`
389
+ :root {
390
+ --left-offset: 20px;
391
+ --track-h: 50vh;
392
+ --track-w: 3px;
393
+ --thumb-w: 2px;
394
+ --thumb-h: 50px;
395
+ --track-bg: #212121;
396
+ --channel-bg: rgba(255,255,255,0.15);
397
+ --thumb-gradient: linear-gradient(180deg,#ffffff,#d7d7d7);
398
+ --track-radius: 0px;
399
+ --thumb-radius: 0px;
400
+ --transition-speed: 1ms;
401
+ }
402
+
403
+ * {
404
+ box-sizing: border-box;
405
+ }
406
+
407
+ body {
408
+ background: #0a0a0a;
409
+ color: #e6e6e6;
410
+ margin: 0;
411
+ padding: 0;
412
+ }
413
+
414
+ .vs {
415
+ position: fixed;
416
+ left: var(--left-offset);
417
+ top: 50%;
418
+ transform: translateY(-50%);
419
+ width: var(--track-w);
420
+ height: var(--track-h);
421
+ background: var(--track-bg);
422
+ border-radius: var(--track-radius);
423
+ overflow: hidden;
424
+ box-shadow:
425
+ inset 0 1px 0 rgba(255,255,255,0.08),
426
+ 0 10px 24px rgba(0,0,0,0.6);
427
+ backdrop-filter: blur(6px);
428
+ pointer-events: none;
429
+ z-index: 9999;
430
+ display: flex;
431
+ justify-content: center;
432
+ will-change: transform;
433
+ }
434
+
435
+ .vs__channel {
436
+ position: relative;
437
+ width: 100%;
438
+ height: 100%;
439
+ background: var(--channel-bg);
440
+ border-radius: var(--track-radius);
441
+ overflow: hidden;
442
+ }
443
+
444
+ .vs__thumb {
445
+ position: absolute;
446
+ left: 50%;
447
+ transform: translateX(-50%) translateZ(0);
448
+ width: var(--thumb-w);
449
+ height: var(--thumb-h);
450
+ border-radius: var(--thumb-radius);
451
+ background: var(--thumb-gradient);
452
+ box-shadow:
453
+ 0 4px 14px rgba(0,0,0,0.6),
454
+ inset 0 1px 0 rgba(255,255,255,0.4);
455
+ will-change: top;
456
+ }
457
+
458
+ .vs:hover .vs__thumb {
459
+ transform: translateX(-50%) translateZ(0) scaleY(1.05);
460
+ transition: transform 180ms ease;
461
+ }
462
+
463
+ @media (max-width:720px) {
464
+ :root {
465
+ --left-offset: 10px;
466
+ --thumb-h: 30px;
467
+ --track-w: 3px;
468
+ --track-h: 30vh;
469
+ }
470
+ }
471
+ \`}</style>
472
+
473
+ {/* Visual Scrollbar */}
474
+ <div className='vs'>
475
+ <div className='vs__channel' ref={channelRef}>
476
+ <div
477
+ className='vs__thumb'
478
+ ref={thumbRef}
479
+ style={{ top: \`\${thumbTop}px\` }}
480
+ aria-hidden='true'
481
+ />
482
+ </div>
483
+ </div>
484
+ </>
485
+ );
486
+ };
487
+
488
+ export default VisualScrollbar;`,
489
+ description: ``,
490
+ install: "",
491
+ },
492
+ }
493
+ };
@@ -0,0 +1,18 @@
1
+ import { redirect } from 'next/dist/server/api-utils';
2
+ import React from 'react'
3
+
4
+ const layout = async ({children}: { children: React.ReactNode }) => {
5
+
6
+ const isUserAuthenticated = false; // remove later
7
+
8
+
9
+ // const isUserAuthenticated = await isAuthenticated();
10
+ // if (!isUserAuthenticated) redirect('/sign-in');
11
+ return (
12
+ <div className='auth-layout'>
13
+ {children}
14
+ </div>
15
+ )
16
+ }
17
+
18
+ export default layout
@@ -0,0 +1,152 @@
1
+ 'use client';
2
+
3
+ import { ArrowRight } from 'lucide-react';
4
+ import { useState, useCallback } from 'react';
5
+ import { sendOtp, verifyOtp } from '@/lib/actions/auth.action';
6
+ import { Toast } from '@/components/toast';
7
+
8
+ interface ToastState {
9
+ id: number;
10
+ message: string;
11
+ }
12
+
13
+ function useToast() {
14
+ const [toasts, setToasts] = useState<ToastState[]>([]);
15
+
16
+ const showToast = useCallback((message: string) => {
17
+ const id = Date.now();
18
+ setToasts((prev) => [...prev, { id, message }]);
19
+ }, []);
20
+
21
+ const removeToast = useCallback((id: number) => {
22
+ setToasts((prev) => prev.filter((t) => t.id !== id));
23
+ }, []);
24
+
25
+ return { toasts, showToast, removeToast };
26
+ }
27
+
28
+ export default function LoginPage() {
29
+ const [step, setStep] = useState<'email' | 'otp'>('email');
30
+ const [email, setEmail] = useState('');
31
+ const [loading, setLoading] = useState(false);
32
+ const { toasts, showToast, removeToast } = useToast();
33
+
34
+ return (
35
+ <div className='min-h-screen flex flex-col items-center justify-center text-white px-4 font-sans selection:bg-zinc-800'>
36
+ {/* Toast notifications */}
37
+ {toasts.map((t) => (
38
+ <Toast
39
+ key={t.id}
40
+ message={t.message}
41
+ onClose={() => removeToast(t.id)}
42
+ />
43
+ ))}
44
+
45
+ <div className='w-full max-w-2xl'>
46
+ {/* EMAIL STEP */}
47
+ {step === 'email' ? (
48
+ <form
49
+ onSubmit={async (e) => {
50
+ e.preventDefault();
51
+ setLoading(true);
52
+
53
+ const formData = new FormData();
54
+ formData.append('email', email);
55
+
56
+ await sendOtp(formData);
57
+
58
+ setLoading(false);
59
+ showToast('OTP sent to your email');
60
+ setStep('otp');
61
+ }}
62
+ className='relative group'
63
+ >
64
+ <input
65
+ type='email'
66
+ autoFocus
67
+ required
68
+ disabled={loading}
69
+ value={email}
70
+ placeholder='you@example.com'
71
+ onChange={(e) => setEmail(e.target.value)}
72
+ className='w-full bg-transparent text-xl md:text-5xl font-light py-4 outline-none border-b border-zinc-800 focus:border-zinc-400 transition-all duration-500 placeholder:text-zinc-800'
73
+ />
74
+
75
+ {loading ? (
76
+ <Loader text='Sending' />
77
+ ) : (
78
+ <button
79
+ type='submit'
80
+ className='absolute right-0 top-1/2 -translate-y-1/2 p-2 text-zinc-500 hover:text-white transition-colors'
81
+ >
82
+ <ArrowRight size={32} strokeWidth={1.5} />
83
+ </button>
84
+ )}
85
+ </form>
86
+ ) : (
87
+ /* OTP STEP */
88
+ <form
89
+ onSubmit={async (e) => {
90
+ e.preventDefault();
91
+ setLoading(true);
92
+
93
+ const formData = new FormData(e.currentTarget);
94
+ formData.append('email', email);
95
+
96
+ await verifyOtp(formData);
97
+ }}
98
+ className='space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700'
99
+ >
100
+ <label htmlFor='otp'>
101
+ Enter the 6-digit code sent to your email
102
+ </label>
103
+
104
+ <div className='relative group'>
105
+ <input
106
+ type='text'
107
+ name='otp'
108
+ autoFocus
109
+ maxLength={6}
110
+ disabled={loading}
111
+ placeholder='000000'
112
+ className='w-full bg-transparent text-xl md:text-5xl font-light py-4 outline-none border-b border-zinc-800 focus:border-zinc-400 transition-all text-center tracking-[1em] placeholder:text-zinc-900'
113
+ />
114
+
115
+ {loading ? (
116
+ <Loader text='Verifying' />
117
+ ) : (
118
+ <button
119
+ type='submit'
120
+ className='absolute right-0 top-1/2 -translate-y-1/2 p-2 text-zinc-500 hover:text-white transition-colors'
121
+ >
122
+ <ArrowRight size={32} strokeWidth={1.5} />
123
+ </button>
124
+ )}
125
+ </div>
126
+ </form>
127
+ )}
128
+ </div>
129
+
130
+ {/* Footer Branding */}
131
+ <footer className='fixed bottom-8 text-md text-zinc-600 uppercase font-hoshiko font-bold'>
132
+ Slash/ui
133
+ </footer>
134
+ </div>
135
+ );
136
+ }
137
+
138
+ /* Loader Component */
139
+
140
+ function Loader({ text }: { text: string }) {
141
+ return (
142
+ <div className='absolute right-0 top-1/2 -translate-y-1/2 text-zinc-400 text-sm flex items-center gap-1'>
143
+ [{text}
144
+ <span className='flex'>
145
+ <span className='animate-bounce'>.</span>
146
+ <span className='animate-bounce delay-150'>.</span>
147
+ <span className='animate-bounce delay-300'>.</span>
148
+ </span>
149
+ ]
150
+ </div>
151
+ );
152
+ }