@arolariu/components 0.1.2 → 0.2.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 (323) hide show
  1. package/DEBUGGING.md +396 -396
  2. package/LICENSE.md +21 -21
  3. package/changelog.md +109 -118
  4. package/dist/components/ui/accordion.d.ts +2 -2
  5. package/dist/components/ui/accordion.d.ts.map +1 -1
  6. package/dist/components/ui/accordion.js +4 -4
  7. package/dist/components/ui/accordion.js.map +1 -1
  8. package/dist/components/ui/alert-dialog.d.ts +13 -13
  9. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  10. package/dist/components/ui/alert-dialog.js +4 -4
  11. package/dist/components/ui/alert-dialog.js.map +1 -1
  12. package/dist/components/ui/alert.d.ts +5 -5
  13. package/dist/components/ui/alert.d.ts.map +1 -1
  14. package/dist/components/ui/alert.js +3 -3
  15. package/dist/components/ui/alert.js.map +1 -1
  16. package/dist/components/ui/aspect-ratio.d.ts +1 -1
  17. package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
  18. package/dist/components/ui/aspect-ratio.js +1 -1
  19. package/dist/components/ui/aspect-ratio.js.map +1 -1
  20. package/dist/components/ui/avatar.d.ts +2 -2
  21. package/dist/components/ui/avatar.d.ts.map +1 -1
  22. package/dist/components/ui/avatar.js +3 -3
  23. package/dist/components/ui/avatar.js.map +1 -1
  24. package/dist/components/ui/background-beams.d.ts.map +1 -1
  25. package/dist/components/ui/background-beams.js +6 -6
  26. package/dist/components/ui/background-beams.js.map +1 -1
  27. package/dist/components/ui/badge.d.ts +4 -4
  28. package/dist/components/ui/badge.d.ts.map +1 -1
  29. package/dist/components/ui/badge.js +2 -2
  30. package/dist/components/ui/badge.js.map +1 -1
  31. package/dist/components/ui/breadcrumb.d.ts +6 -6
  32. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  33. package/dist/components/ui/breadcrumb.js +5 -5
  34. package/dist/components/ui/breadcrumb.js.map +1 -1
  35. package/dist/components/ui/bubble-background.d.ts +1 -1
  36. package/dist/components/ui/bubble-background.d.ts.map +1 -1
  37. package/dist/components/ui/bubble-background.js +13 -13
  38. package/dist/components/ui/bubble-background.js.map +1 -1
  39. package/dist/components/ui/button.d.ts +5 -5
  40. package/dist/components/ui/button.d.ts.map +1 -1
  41. package/dist/components/ui/button.js +2 -2
  42. package/dist/components/ui/button.js.map +1 -1
  43. package/dist/components/ui/calendar.d.ts.map +1 -1
  44. package/dist/components/ui/calendar.js +4 -4
  45. package/dist/components/ui/calendar.js.map +1 -1
  46. package/dist/components/ui/card.d.ts +1 -1
  47. package/dist/components/ui/card.d.ts.map +1 -1
  48. package/dist/components/ui/card.js +3 -3
  49. package/dist/components/ui/card.js.map +1 -1
  50. package/dist/components/ui/carousel.d.ts +2 -2
  51. package/dist/components/ui/carousel.d.ts.map +1 -1
  52. package/dist/components/ui/carousel.js +3 -3
  53. package/dist/components/ui/carousel.js.map +1 -1
  54. package/dist/components/ui/chart.d.ts +4 -4
  55. package/dist/components/ui/chart.d.ts.map +1 -1
  56. package/dist/components/ui/chart.js +1 -1
  57. package/dist/components/ui/chart.js.map +1 -1
  58. package/dist/components/ui/checkbox.d.ts +1 -1
  59. package/dist/components/ui/checkbox.d.ts.map +1 -1
  60. package/dist/components/ui/checkbox.js +3 -3
  61. package/dist/components/ui/checkbox.js.map +1 -1
  62. package/dist/components/ui/collapsible.d.ts +2 -2
  63. package/dist/components/ui/collapsible.d.ts.map +1 -1
  64. package/dist/components/ui/collapsible.js +1 -1
  65. package/dist/components/ui/collapsible.js.map +1 -1
  66. package/dist/components/ui/command.d.ts +2 -2
  67. package/dist/components/ui/command.d.ts.map +1 -1
  68. package/dist/components/ui/command.js +9 -9
  69. package/dist/components/ui/command.js.map +1 -1
  70. package/dist/components/ui/context-menu.d.ts +2 -2
  71. package/dist/components/ui/context-menu.d.ts.map +1 -1
  72. package/dist/components/ui/context-menu.js +11 -11
  73. package/dist/components/ui/context-menu.js.map +1 -1
  74. package/dist/components/ui/counting-number.d.ts +1 -1
  75. package/dist/components/ui/counting-number.d.ts.map +1 -1
  76. package/dist/components/ui/counting-number.js +4 -3
  77. package/dist/components/ui/counting-number.js.map +1 -1
  78. package/dist/components/ui/dialog.d.ts +1 -1
  79. package/dist/components/ui/dialog.d.ts.map +1 -1
  80. package/dist/components/ui/dialog.js +6 -6
  81. package/dist/components/ui/dialog.js.map +1 -1
  82. package/dist/components/ui/dot-background.d.ts +10 -17
  83. package/dist/components/ui/dot-background.d.ts.map +1 -1
  84. package/dist/components/ui/dot-background.js +2 -2
  85. package/dist/components/ui/dot-background.js.map +1 -1
  86. package/dist/components/ui/drawer.d.ts +1 -1
  87. package/dist/components/ui/drawer.d.ts.map +1 -1
  88. package/dist/components/ui/drawer.js +5 -5
  89. package/dist/components/ui/drawer.js.map +1 -1
  90. package/dist/components/ui/dropdown-menu.d.ts +2 -2
  91. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  92. package/dist/components/ui/dropdown-menu.js +10 -10
  93. package/dist/components/ui/dropdown-menu.js.map +1 -1
  94. package/dist/components/ui/dropdrawer.d.ts +2 -2
  95. package/dist/components/ui/dropdrawer.d.ts.map +1 -1
  96. package/dist/components/ui/dropdrawer.js +12 -12
  97. package/dist/components/ui/dropdrawer.js.map +1 -1
  98. package/dist/components/ui/fireworks-background.d.ts.map +1 -1
  99. package/dist/components/ui/fireworks-background.js +1 -1
  100. package/dist/components/ui/fireworks-background.js.map +1 -1
  101. package/dist/components/ui/flip-button.d.ts +1 -1
  102. package/dist/components/ui/flip-button.d.ts.map +1 -1
  103. package/dist/components/ui/flip-button.js +3 -3
  104. package/dist/components/ui/flip-button.js.map +1 -1
  105. package/dist/components/ui/form.d.ts +3 -3
  106. package/dist/components/ui/form.d.ts.map +1 -1
  107. package/dist/components/ui/form.js +4 -4
  108. package/dist/components/ui/form.js.map +1 -1
  109. package/dist/components/ui/gradient-background.d.ts +1 -1
  110. package/dist/components/ui/gradient-background.d.ts.map +1 -1
  111. package/dist/components/ui/gradient-background.js +2 -2
  112. package/dist/components/ui/gradient-background.js.map +1 -1
  113. package/dist/components/ui/gradient-text.d.ts +1 -1
  114. package/dist/components/ui/gradient-text.d.ts.map +1 -1
  115. package/dist/components/ui/gradient-text.js +5 -5
  116. package/dist/components/ui/gradient-text.js.map +1 -1
  117. package/dist/components/ui/highlight-text.d.ts +1 -1
  118. package/dist/components/ui/highlight-text.d.ts.map +1 -1
  119. package/dist/components/ui/highlight-text.js +3 -3
  120. package/dist/components/ui/highlight-text.js.map +1 -1
  121. package/dist/components/ui/hole-background.d.ts.map +1 -1
  122. package/dist/components/ui/hole-background.js +11 -10
  123. package/dist/components/ui/hole-background.js.map +1 -1
  124. package/dist/components/ui/hover-card.d.ts +2 -2
  125. package/dist/components/ui/hover-card.d.ts.map +1 -1
  126. package/dist/components/ui/hover-card.js +3 -3
  127. package/dist/components/ui/hover-card.js.map +1 -1
  128. package/dist/components/ui/input-otp.d.ts +2 -2
  129. package/dist/components/ui/input-otp.d.ts.map +1 -1
  130. package/dist/components/ui/input-otp.js +5 -5
  131. package/dist/components/ui/input-otp.js.map +1 -1
  132. package/dist/components/ui/input.d.ts.map +1 -1
  133. package/dist/components/ui/input.js +2 -2
  134. package/dist/components/ui/input.js.map +1 -1
  135. package/dist/components/ui/label.d.ts +1 -1
  136. package/dist/components/ui/label.d.ts.map +1 -1
  137. package/dist/components/ui/label.js +2 -2
  138. package/dist/components/ui/label.js.map +1 -1
  139. package/dist/components/ui/menubar.d.ts +2 -2
  140. package/dist/components/ui/menubar.d.ts.map +1 -1
  141. package/dist/components/ui/menubar.js +12 -12
  142. package/dist/components/ui/menubar.js.map +1 -1
  143. package/dist/components/ui/navigation-menu.d.ts +3 -3
  144. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  145. package/dist/components/ui/navigation-menu.js +6 -7
  146. package/dist/components/ui/navigation-menu.js.map +1 -1
  147. package/dist/components/ui/pagination.d.ts +2 -2
  148. package/dist/components/ui/pagination.d.ts.map +1 -1
  149. package/dist/components/ui/pagination.js +8 -4
  150. package/dist/components/ui/pagination.js.map +1 -1
  151. package/dist/components/ui/popover.d.ts +2 -2
  152. package/dist/components/ui/popover.d.ts.map +1 -1
  153. package/dist/components/ui/popover.js +3 -3
  154. package/dist/components/ui/popover.js.map +1 -1
  155. package/dist/components/ui/progress.d.ts +1 -1
  156. package/dist/components/ui/progress.d.ts.map +1 -1
  157. package/dist/components/ui/progress.js +4 -4
  158. package/dist/components/ui/progress.js.map +1 -1
  159. package/dist/components/ui/radio-group.d.ts +1 -1
  160. package/dist/components/ui/radio-group.d.ts.map +1 -1
  161. package/dist/components/ui/radio-group.js +3 -3
  162. package/dist/components/ui/radio-group.js.map +1 -1
  163. package/dist/components/ui/resizable.d.ts +1 -1
  164. package/dist/components/ui/resizable.d.ts.map +1 -1
  165. package/dist/components/ui/resizable.js +5 -5
  166. package/dist/components/ui/resizable.js.map +1 -1
  167. package/dist/components/ui/ripple-button.d.ts +1 -1
  168. package/dist/components/ui/ripple-button.d.ts.map +1 -1
  169. package/dist/components/ui/ripple-button.js +4 -4
  170. package/dist/components/ui/ripple-button.js.map +1 -1
  171. package/dist/components/ui/scratcher.d.ts.map +1 -1
  172. package/dist/components/ui/scratcher.js +7 -5
  173. package/dist/components/ui/scratcher.js.map +1 -1
  174. package/dist/components/ui/scroll-area.d.ts +1 -1
  175. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  176. package/dist/components/ui/scroll-area.js +4 -4
  177. package/dist/components/ui/scroll-area.js.map +1 -1
  178. package/dist/components/ui/select.d.ts +1 -1
  179. package/dist/components/ui/select.d.ts.map +1 -1
  180. package/dist/components/ui/select.js +7 -7
  181. package/dist/components/ui/select.js.map +1 -1
  182. package/dist/components/ui/separator.d.ts +1 -1
  183. package/dist/components/ui/separator.d.ts.map +1 -1
  184. package/dist/components/ui/separator.js +3 -3
  185. package/dist/components/ui/separator.js.map +1 -1
  186. package/dist/components/ui/sheet.d.ts +2 -2
  187. package/dist/components/ui/sheet.d.ts.map +1 -1
  188. package/dist/components/ui/sheet.js +6 -6
  189. package/dist/components/ui/sheet.js.map +1 -1
  190. package/dist/components/ui/sidebar.d.ts +5 -5
  191. package/dist/components/ui/sidebar.d.ts.map +1 -1
  192. package/dist/components/ui/sidebar.js +5 -5
  193. package/dist/components/ui/sidebar.js.map +1 -1
  194. package/dist/components/ui/skeleton.d.ts.map +1 -1
  195. package/dist/components/ui/skeleton.js +2 -2
  196. package/dist/components/ui/skeleton.js.map +1 -1
  197. package/dist/components/ui/slider.d.ts +1 -1
  198. package/dist/components/ui/slider.d.ts.map +1 -1
  199. package/dist/components/ui/slider.js +5 -5
  200. package/dist/components/ui/slider.js.map +1 -1
  201. package/dist/components/ui/sonner.d.ts +1 -1
  202. package/dist/components/ui/sonner.d.ts.map +1 -1
  203. package/dist/components/ui/sonner.js +1 -1
  204. package/dist/components/ui/sonner.js.map +1 -1
  205. package/dist/components/ui/switch.d.ts +1 -1
  206. package/dist/components/ui/switch.d.ts.map +1 -1
  207. package/dist/components/ui/switch.js +4 -4
  208. package/dist/components/ui/switch.js.map +1 -1
  209. package/dist/components/ui/table.d.ts +1 -1
  210. package/dist/components/ui/table.d.ts.map +1 -1
  211. package/dist/components/ui/table.js +5 -5
  212. package/dist/components/ui/table.js.map +1 -1
  213. package/dist/components/ui/tabs.d.ts +2 -2
  214. package/dist/components/ui/tabs.d.ts.map +1 -1
  215. package/dist/components/ui/tabs.js +4 -4
  216. package/dist/components/ui/tabs.js.map +1 -1
  217. package/dist/components/ui/textarea.d.ts +1 -1
  218. package/dist/components/ui/textarea.d.ts.map +1 -1
  219. package/dist/components/ui/textarea.js +2 -2
  220. package/dist/components/ui/textarea.js.map +1 -1
  221. package/dist/components/ui/toggle-group.d.ts +3 -3
  222. package/dist/components/ui/toggle-group.d.ts.map +1 -1
  223. package/dist/components/ui/toggle-group.js +2 -2
  224. package/dist/components/ui/toggle-group.js.map +1 -1
  225. package/dist/components/ui/toggle.d.ts +6 -6
  226. package/dist/components/ui/toggle.d.ts.map +1 -1
  227. package/dist/components/ui/toggle.js +2 -2
  228. package/dist/components/ui/toggle.js.map +1 -1
  229. package/dist/components/ui/tooltip.d.ts +6 -6
  230. package/dist/components/ui/tooltip.d.ts.map +1 -1
  231. package/dist/components/ui/tooltip.js +4 -4
  232. package/dist/components/ui/tooltip.js.map +1 -1
  233. package/dist/components/ui/typewriter.d.ts.map +1 -1
  234. package/dist/components/ui/typewriter.js +15 -11
  235. package/dist/components/ui/typewriter.js.map +1 -1
  236. package/dist/hooks/useIsMobile.d.ts +2 -5
  237. package/dist/hooks/useIsMobile.d.ts.map +1 -1
  238. package/dist/hooks/useIsMobile.js +1 -1
  239. package/dist/hooks/useIsMobile.js.map +1 -1
  240. package/dist/hooks/useWindowSize.d.ts +0 -1
  241. package/dist/hooks/useWindowSize.d.ts.map +1 -1
  242. package/dist/hooks/useWindowSize.js +1 -1
  243. package/dist/hooks/useWindowSize.js.map +1 -1
  244. package/dist/index.css +2 -2
  245. package/dist/index.css.map +1 -1
  246. package/dist/index.d.ts +37 -37
  247. package/dist/index.d.ts.map +1 -1
  248. package/dist/index.js +2 -2
  249. package/dist/lib/utilities.d.ts +9 -0
  250. package/dist/lib/utilities.d.ts.map +1 -0
  251. package/dist/lib/{utils.js → utilities.js} +1 -1
  252. package/dist/lib/utilities.js.map +1 -0
  253. package/package.json +85 -89
  254. package/{README.md → readme.md} +627 -627
  255. package/src/components/ui/accordion.tsx +56 -66
  256. package/src/components/ui/alert-dialog.tsx +135 -160
  257. package/src/components/ui/alert.tsx +58 -69
  258. package/src/components/ui/aspect-ratio.tsx +15 -12
  259. package/src/components/ui/avatar.tsx +38 -53
  260. package/src/components/ui/background-beams.tsx +145 -142
  261. package/src/components/ui/badge.tsx +47 -48
  262. package/src/components/ui/breadcrumb.tsx +97 -117
  263. package/src/components/ui/bubble-background.tsx +170 -189
  264. package/src/components/ui/button.tsx +61 -61
  265. package/src/components/ui/calendar.tsx +177 -216
  266. package/src/components/ui/card.tsx +83 -97
  267. package/src/components/ui/carousel.tsx +204 -241
  268. package/src/components/ui/chart.tsx +303 -385
  269. package/src/components/ui/checkbox.tsx +27 -32
  270. package/src/components/ui/collapsible.tsx +33 -34
  271. package/src/components/ui/command.tsx +137 -184
  272. package/src/components/ui/context-menu.tsx +229 -255
  273. package/src/components/ui/counting-number.tsx +92 -108
  274. package/src/components/ui/dialog.tsx +141 -146
  275. package/src/components/ui/dot-background.tsx +153 -158
  276. package/src/components/ui/drawer.tsx +133 -141
  277. package/src/components/ui/dropdown-menu.tsx +235 -260
  278. package/src/components/ui/dropdrawer.tsx +870 -973
  279. package/src/components/ui/fireworks-background.tsx +325 -378
  280. package/src/components/ui/flip-button.tsx +89 -110
  281. package/src/components/ui/form.tsx +145 -174
  282. package/src/components/ui/gradient-background.tsx +30 -43
  283. package/src/components/ui/gradient-text.tsx +62 -65
  284. package/src/components/ui/highlight-text.tsx +54 -71
  285. package/src/components/ui/hole-background.tsx +326 -361
  286. package/src/components/ui/hover-card.tsx +48 -44
  287. package/src/components/ui/input-otp.tsx +76 -77
  288. package/src/components/ui/input.tsx +22 -22
  289. package/src/components/ui/label.tsx +21 -24
  290. package/src/components/ui/menubar.tsx +256 -279
  291. package/src/components/ui/navigation-menu.tsx +135 -171
  292. package/src/components/ui/pagination.tsx +103 -129
  293. package/src/components/ui/popover.tsx +52 -48
  294. package/src/components/ui/progress.tsx +23 -31
  295. package/src/components/ui/radio-group.tsx +37 -45
  296. package/src/components/ui/resizable.tsx +52 -56
  297. package/src/components/ui/ripple-button.tsx +90 -111
  298. package/src/components/ui/scratcher.tsx +167 -171
  299. package/src/components/ui/scroll-area.tsx +45 -58
  300. package/src/components/ui/select.tsx +160 -191
  301. package/src/components/ui/separator.tsx +28 -28
  302. package/src/components/ui/sheet.tsx +133 -145
  303. package/src/components/ui/sidebar.tsx +673 -729
  304. package/src/components/ui/skeleton.tsx +16 -19
  305. package/src/components/ui/slider.tsx +49 -63
  306. package/src/components/ui/sonner.tsx +30 -26
  307. package/src/components/ui/switch.tsx +27 -31
  308. package/src/components/ui/table.tsx +98 -119
  309. package/src/components/ui/tabs.tsx +54 -66
  310. package/src/components/ui/textarea.tsx +20 -20
  311. package/src/components/ui/toggle-group.tsx +66 -73
  312. package/src/components/ui/toggle.tsx +46 -47
  313. package/src/components/ui/tooltip.tsx +56 -61
  314. package/src/components/ui/typewriter.tsx +174 -188
  315. package/src/hooks/useIsMobile.tsx +42 -45
  316. package/src/hooks/useWindowSize.tsx +66 -72
  317. package/src/index.css +73 -73
  318. package/src/index.ts +303 -408
  319. package/src/lib/utilities.ts +12 -0
  320. package/dist/lib/utils.d.ts +0 -7
  321. package/dist/lib/utils.d.ts.map +0 -1
  322. package/dist/lib/utils.js.map +0 -1
  323. package/src/lib/utils.ts +0 -10
@@ -1,188 +1,174 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { cn } from "@/lib/utils";
5
- import { motion, stagger, useAnimate, useInView } from "motion/react";
6
- import { useEffect } from "react";
7
-
8
- export const TypewriterText = ({
9
- words,
10
- className,
11
- cursorClassName,
12
- }: {
13
- words: {
14
- text: string;
15
- className?: string;
16
- }[];
17
- className?: string;
18
- cursorClassName?: string;
19
- }): React.JSX.Element => {
20
- // split text inside of words into array of characters
21
- const wordsArray = words.map((word) => {
22
- return {
23
- ...word,
24
- text: word.text.split(""),
25
- };
26
- });
27
-
28
- const [scope, animate] = useAnimate();
29
- const isInView = useInView(scope);
30
- useEffect(() => {
31
- if (isInView) {
32
- animate(
33
- "span",
34
- {
35
- display: "inline-block",
36
- opacity: 1,
37
- width: "fit-content",
38
- },
39
- {
40
- duration: 0.3,
41
- delay: stagger(0.1),
42
- ease: "easeInOut",
43
- },
44
- );
45
- }
46
- }, [isInView]);
47
-
48
- const renderWords = () => {
49
- return (
50
- <motion.div ref={scope} className="inline">
51
- {wordsArray.map((word, idx) => {
52
- return (
53
- <div key={`word-${idx}`} className="inline-block">
54
- {word.text.map((char, index) => (
55
- <motion.span
56
- initial={{}}
57
- key={`char-${index}`}
58
- className={cn(
59
- `dark:text-white text-black opacity-0 hidden`,
60
- word.className,
61
- )}
62
- >
63
- {char}
64
- </motion.span>
65
- ))}
66
- &nbsp;
67
- </div>
68
- );
69
- })}
70
- </motion.div>
71
- );
72
- };
73
- return (
74
- <div
75
- className={cn(
76
- "text-base sm:text-xl md:text-3xl lg:text-5xl font-bold text-center",
77
- className,
78
- )}
79
- >
80
- {renderWords()}
81
- <motion.span
82
- initial={{
83
- opacity: 0,
84
- }}
85
- animate={{
86
- opacity: 1,
87
- }}
88
- transition={{
89
- duration: 0.8,
90
- repeat: Infinity,
91
- repeatType: "reverse",
92
- }}
93
- className={cn(
94
- "inline-block rounded-sm w-[4px] h-4 md:h-6 lg:h-10 bg-blue-500",
95
- cursorClassName,
96
- )}
97
- ></motion.span>
98
- </div>
99
- );
100
- };
101
-
102
- export const TypewriterTextSmooth = ({
103
- words,
104
- className,
105
- cursorClassName,
106
- }: {
107
- words: {
108
- text: string;
109
- className?: string;
110
- }[];
111
- className?: string;
112
- cursorClassName?: string;
113
- }): React.JSX.Element => {
114
- // split text inside of words into array of characters
115
- const wordsArray = words.map((word) => {
116
- return {
117
- ...word,
118
- text: word.text.split(""),
119
- };
120
- });
121
- const renderWords = () => {
122
- return (
123
- <div>
124
- {wordsArray.map((word, idx) => {
125
- return (
126
- <div key={`word-${idx}`} className="inline-block">
127
- {word.text.map((char, index) => (
128
- <span
129
- key={`char-${index}`}
130
- className={cn(`dark:text-white text-black `, word.className)}
131
- >
132
- {char}
133
- </span>
134
- ))}
135
- &nbsp;
136
- </div>
137
- );
138
- })}
139
- </div>
140
- );
141
- };
142
-
143
- return (
144
- <div className={cn("flex space-x-1 my-6", className)}>
145
- <motion.div
146
- className="overflow-hidden pb-2"
147
- initial={{
148
- width: "0%",
149
- }}
150
- whileInView={{
151
- width: "fit-content",
152
- }}
153
- transition={{
154
- duration: 2,
155
- ease: "linear",
156
- delay: 1,
157
- }}
158
- >
159
- <div
160
- className="text-xs sm:text-base md:text-xl lg:text:3xl xl:text-5xl font-bold"
161
- style={{
162
- whiteSpace: "nowrap",
163
- }}
164
- >
165
- {renderWords()}{" "}
166
- </div>{" "}
167
- </motion.div>
168
- <motion.span
169
- initial={{
170
- opacity: 0,
171
- }}
172
- animate={{
173
- opacity: 1,
174
- }}
175
- transition={{
176
- duration: 0.8,
177
-
178
- repeat: Infinity,
179
- repeatType: "reverse",
180
- }}
181
- className={cn(
182
- "block rounded-sm w-[4px] h-4 sm:h-6 xl:h-12 bg-blue-500",
183
- cursorClassName,
184
- )}
185
- ></motion.span>
186
- </div>
187
- );
188
- };
1
+ "use client";
2
+
3
+ import {cn} from "@/lib/utilities";
4
+ import {motion, stagger, useAnimate, useInView} from "motion/react";
5
+ import * as React from "react";
6
+ import {useEffect} from "react";
7
+
8
+ export const TypewriterText = ({
9
+ words,
10
+ className,
11
+ cursorClassName,
12
+ }: {
13
+ words: {
14
+ text: string;
15
+ className?: string;
16
+ }[];
17
+ className?: string;
18
+ cursorClassName?: string;
19
+ }): React.JSX.Element => {
20
+ // split text inside of words into array of characters
21
+ const wordsArray = words.map((word) => {
22
+ return {
23
+ ...word,
24
+ text: [...word.text],
25
+ };
26
+ });
27
+
28
+ const [scope, animate] = useAnimate();
29
+ const isInView = useInView(scope);
30
+ useEffect(() => {
31
+ if (isInView) {
32
+ animate(
33
+ "span",
34
+ {
35
+ display: "inline-block",
36
+ opacity: 1,
37
+ width: "fit-content",
38
+ },
39
+ {
40
+ duration: 0.3,
41
+ delay: stagger(0.1),
42
+ ease: "easeInOut",
43
+ },
44
+ );
45
+ }
46
+ }, [isInView]);
47
+
48
+ const renderWords = () => {
49
+ return (
50
+ <motion.div
51
+ ref={scope}
52
+ className='inline'>
53
+ {wordsArray.map((word, idx) => {
54
+ return (
55
+ <div
56
+ key={`word-${idx}`}
57
+ className='inline-block'>
58
+ {word.text.map((char, index) => (
59
+ <motion.span
60
+ initial={{}}
61
+ key={`char-${index}`}
62
+ className={cn(`hidden text-black opacity-0 dark:text-white`, word.className)}>
63
+ {char}
64
+ </motion.span>
65
+ ))}
66
+ &nbsp;
67
+ </div>
68
+ );
69
+ })}
70
+ </motion.div>
71
+ );
72
+ };
73
+ return (
74
+ <div className={cn("text-center text-base font-bold sm:text-xl md:text-3xl lg:text-5xl", className)}>
75
+ {renderWords()}
76
+ <motion.span
77
+ initial={{
78
+ opacity: 0,
79
+ }}
80
+ animate={{
81
+ opacity: 1,
82
+ }}
83
+ transition={{
84
+ duration: 0.8,
85
+ repeat: Infinity,
86
+ repeatType: "reverse",
87
+ }}
88
+ className={cn("inline-block h-4 w-[4px] rounded-sm bg-blue-500 md:h-6 lg:h-10", cursorClassName)}></motion.span>
89
+ </div>
90
+ );
91
+ };
92
+
93
+ export const TypewriterTextSmooth = ({
94
+ words,
95
+ className,
96
+ cursorClassName,
97
+ }: {
98
+ words: {
99
+ text: string;
100
+ className?: string;
101
+ }[];
102
+ className?: string;
103
+ cursorClassName?: string;
104
+ }): React.JSX.Element => {
105
+ // split text inside of words into array of characters
106
+ const wordsArray = words.map((word) => {
107
+ return {
108
+ ...word,
109
+ text: [...word.text],
110
+ };
111
+ });
112
+ const renderWords = () => {
113
+ return (
114
+ <div>
115
+ {wordsArray.map((word, idx) => {
116
+ return (
117
+ <div
118
+ key={`word-${idx}`}
119
+ className='inline-block'>
120
+ {word.text.map((char, index) => (
121
+ <span
122
+ key={`char-${index}`}
123
+ className={cn(`text-black dark:text-white`, word.className)}>
124
+ {char}
125
+ </span>
126
+ ))}
127
+ &nbsp;
128
+ </div>
129
+ );
130
+ })}
131
+ </div>
132
+ );
133
+ };
134
+
135
+ return (
136
+ <div className={cn("my-6 flex space-x-1", className)}>
137
+ <motion.div
138
+ className='overflow-hidden pb-2'
139
+ initial={{
140
+ width: "0%",
141
+ }}
142
+ whileInView={{
143
+ width: "fit-content",
144
+ }}
145
+ transition={{
146
+ duration: 2,
147
+ ease: "linear",
148
+ delay: 1,
149
+ }}>
150
+ <div
151
+ className='lg:text:3xl text-xs font-bold sm:text-base md:text-xl xl:text-5xl'
152
+ style={{
153
+ whiteSpace: "nowrap",
154
+ }}>
155
+ {renderWords()}{" "}
156
+ </div>{" "}
157
+ </motion.div>
158
+ <motion.span
159
+ initial={{
160
+ opacity: 0,
161
+ }}
162
+ animate={{
163
+ opacity: 1,
164
+ }}
165
+ transition={{
166
+ duration: 0.8,
167
+
168
+ repeat: Infinity,
169
+ repeatType: "reverse",
170
+ }}
171
+ className={cn("block h-4 w-[4px] rounded-sm bg-blue-500 sm:h-6 xl:h-12", cursorClassName)}></motion.span>
172
+ </div>
173
+ );
174
+ };
@@ -1,45 +1,42 @@
1
- "use client";
2
- import * as React from "react";
3
-
4
- const MOBILE_BREAKPOINT = 768;
5
-
6
- /**
7
- * A custom React hook that detects whether the current device is a mobile device
8
- * based on the screen width.
9
- *
10
- * This hook uses a media query to check if the viewport width is less than the defined
11
- * mobile breakpoint (768px). It updates the state when the window size changes.
12
- *
13
- * @returns {boolean} Returns true if the viewport width is less than the mobile breakpoint,
14
- * false otherwise.
15
- *
16
- * @example
17
- * ```tsx
18
- * function MyComponent() {
19
- * const isMobile = useIsMobile();
20
- *
21
- * return (
22
- * <div>
23
- * {isMobile ? 'Mobile View' : 'Desktop View'}
24
- * </div>
25
- * );
26
- * }
27
- * ```
28
- */
29
- export function useIsMobile(): boolean {
30
- const [isMobile, setIsMobile] = React.useState<boolean | null>(null);
31
-
32
- React.useEffect(() => {
33
- const mql = globalThis.window.matchMedia(
34
- `(max-width: ${MOBILE_BREAKPOINT - 1}px)`,
35
- );
36
- const onChange = () => {
37
- setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
38
- };
39
- mql.addEventListener("change", onChange);
40
- setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
41
- return () => mql.removeEventListener("change", onChange);
42
- }, []);
43
-
44
- return !!isMobile;
45
- }
1
+ "use client";
2
+ import * as React from "react";
3
+
4
+ const MOBILE_BREAKPOINT = 768;
5
+
6
+ /**
7
+ * A custom React hook that detects whether the current device is a mobile device
8
+ * based on the screen width.
9
+ * This hook uses a media query to check if the viewport width is less than the defined
10
+ * mobile breakpoint (768px). It updates the state when the window size changes.
11
+ * @returns Returns true if the viewport width is less than the mobile breakpoint,
12
+ * false otherwise.
13
+ * @example
14
+ * ```tsx
15
+ * function MyComponent() {
16
+ * const isMobile = useIsMobile();
17
+ *
18
+ * return (
19
+ * <div>
20
+ * {isMobile ? 'Mobile View' : 'Desktop View'}
21
+ * </div>
22
+ * );
23
+ * }
24
+ * ```
25
+ */
26
+ export function useIsMobile(): boolean {
27
+ const [isMobile, setIsMobile] = React.useState<boolean | null>(null);
28
+
29
+ React.useEffect(() => {
30
+ const mql = globalThis.window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
31
+ const onChange = () => {
32
+ // eslint-disable-next-line react-hooks-extra/no-direct-set-state-in-use-effect
33
+ setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
34
+ };
35
+ mql.addEventListener("change", onChange);
36
+ // eslint-disable-next-line react-hooks-extra/no-direct-set-state-in-use-effect
37
+ setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
38
+ return () => mql.removeEventListener("change", onChange);
39
+ }, []);
40
+
41
+ return Boolean(isMobile);
42
+ }
@@ -1,72 +1,66 @@
1
- /** @format */
2
-
3
- "use client";
4
-
5
- import { useEffect, useState } from "react";
6
-
7
- const MOBILE_BREAKPOINT = 768;
8
-
9
- type WindowSize = {
10
- width: number | null;
11
- height: number | null;
12
- };
13
-
14
- type HookReturnType = Readonly<{
15
- windowSize: WindowSize;
16
- isMobile: boolean;
17
- isDesktop: boolean;
18
- }>;
19
-
20
- /**
21
- * Client hook to get the window size and whether the window is mobile or desktop.
22
- * @returns An object containing the window size and whether the window is mobile or desktop.
23
- *@example
24
- * ```tsx
25
- * function MyComponent() {
26
- * const { windowSize, isMobile, isDesktop } = useWindowSize();
27
- *
28
- * return (
29
- * <div>
30
- * <p>Window Size: {windowSize.width} x {windowSize.height}</p>
31
- * <p>{isMobile ? 'Mobile View' : 'Desktop View'}</p>
32
- * </div>
33
- * );
34
- * }
35
- * ```
36
- */
37
- export function useWindowSize(): HookReturnType {
38
- const [windowSize, setWindowSize] = useState<WindowSize>({
39
- width: null,
40
- height: null,
41
- });
42
-
43
- useEffect(() => {
44
- /**
45
- * This function updates the window size.
46
- * It is created inside of useEffect and has a short lifespan.
47
- * After it is attached to the window object, it will be garbage collected
48
- * when the component unmounts or the window is resized.
49
- */
50
- function __handleResize__() {
51
- setWindowSize({
52
- width: globalThis.window.innerWidth,
53
- height: globalThis.window.innerHeight,
54
- });
55
- }
56
-
57
- globalThis.window.addEventListener("resize", __handleResize__);
58
- __handleResize__(); // Call the function once to get the initial window size
59
- return () =>
60
- globalThis.window.removeEventListener("resize", __handleResize__);
61
- }, []); // Empty array ensures that effect is only run on mount
62
-
63
- return {
64
- windowSize,
65
- isMobile:
66
- typeof windowSize.width === "number" &&
67
- windowSize.width < MOBILE_BREAKPOINT,
68
- isDesktop:
69
- typeof windowSize.width === "number" &&
70
- windowSize.width >= MOBILE_BREAKPOINT,
71
- } as const;
72
- }
1
+ "use client";
2
+
3
+ import {useEffect, useState} from "react";
4
+
5
+ const MOBILE_BREAKPOINT = 768;
6
+
7
+ type WindowSize = {
8
+ width: number | null;
9
+ height: number | null;
10
+ };
11
+
12
+ type HookReturnType = Readonly<{
13
+ windowSize: WindowSize;
14
+ isMobile: boolean;
15
+ isDesktop: boolean;
16
+ }>;
17
+
18
+ /**
19
+ * Client hook to get the window size and whether the window is mobile or desktop.
20
+ * @returns An object containing the window size and whether the window is mobile or desktop.
21
+ *@example
22
+ * ```tsx
23
+ * function MyComponent() {
24
+ * const { windowSize, isMobile, isDesktop } = useWindowSize();
25
+ *
26
+ * return (
27
+ * <div>
28
+ * <p>Window Size: {windowSize.width} x {windowSize.height}</p>
29
+ * <p>{isMobile ? 'Mobile View' : 'Desktop View'}</p>
30
+ * </div>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ export function useWindowSize(): HookReturnType {
36
+ const [windowSize, setWindowSize] = useState<WindowSize>({
37
+ width: null,
38
+ height: null,
39
+ });
40
+
41
+ useEffect(() => {
42
+ /**
43
+ * This function updates the window size.
44
+ * It is created inside of useEffect and has a short lifespan.
45
+ * After it is attached to the window object, it will be garbage collected
46
+ * when the component unmounts or the window is resized.
47
+ */
48
+ function __handleResize__() {
49
+ // eslint-disable-next-line react-hooks-extra/no-direct-set-state-in-use-effect
50
+ setWindowSize({
51
+ width: globalThis.window.innerWidth,
52
+ height: globalThis.window.innerHeight,
53
+ });
54
+ }
55
+
56
+ globalThis.window.addEventListener("resize", __handleResize__);
57
+ __handleResize__(); // Call the function once to get the initial window size
58
+ return () => globalThis.window.removeEventListener("resize", __handleResize__);
59
+ }, []); // Empty array ensures that effect is only run on mount
60
+
61
+ return {
62
+ windowSize,
63
+ isMobile: typeof windowSize.width === "number" && windowSize.width < MOBILE_BREAKPOINT,
64
+ isDesktop: typeof windowSize.width === "number" && windowSize.width >= MOBILE_BREAKPOINT,
65
+ } as const;
66
+ }