@onepercentio/one-ui 0.28.7 → 0.28.9

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 (278) hide show
  1. package/package.json +8 -5
  2. package/src/assets/img/svg/checkbox.svg +3 -0
  3. package/src/assets/styles/index.scss +2 -0
  4. package/src/assets/styles/mixins.scss +12 -0
  5. package/src/assets/styles/variables.scss +49 -0
  6. package/src/components/AdaptiveButton/AdaptiveButton.module.scss +7 -0
  7. package/src/components/AdaptiveButton/AdaptiveButton.tsx +26 -0
  8. package/src/components/AdaptiveButton/index.tsx +1 -0
  9. package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +53 -0
  10. package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +200 -0
  11. package/src/components/AdaptiveContainer/index.tsx +1 -0
  12. package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +147 -0
  13. package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +97 -0
  14. package/src/components/AdaptiveDialog/index.tsx +1 -0
  15. package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +49 -0
  16. package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +10 -0
  17. package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +123 -0
  18. package/src/components/AdaptiveSidebar/index.tsx +1 -0
  19. package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +64 -0
  20. package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +250 -0
  21. package/src/components/AnchoredTooltip/index.tsx +1 -0
  22. package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +108 -0
  23. package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +227 -0
  24. package/src/components/AnimatedEntrance/index.tsx +5 -0
  25. package/src/components/AsyncWrapper/AsyncWrapper.tsx +38 -0
  26. package/src/components/AsyncWrapper/index.tsx +1 -0
  27. package/src/components/Avatar/Avatar.module.scss +22 -0
  28. package/src/components/Avatar/Avatar.tsx +31 -0
  29. package/src/components/Avatar/index.tsx +1 -0
  30. package/src/components/BucketFill/BucketFill.module.scss +36 -0
  31. package/src/components/BucketFill/BucketFill.tsx +65 -0
  32. package/src/components/BucketFill/index.tsx +1 -0
  33. package/src/components/Button/Button.module.scss +45 -0
  34. package/src/components/Button/Button.tsx +40 -0
  35. package/src/components/Button/index.tsx +1 -0
  36. package/src/components/Card/Card.module.scss +12 -0
  37. package/src/components/Card/Card.tsx +9 -0
  38. package/src/components/Card/index.tsx +1 -0
  39. package/src/components/Chart/Chart.e2e.ts +4 -0
  40. package/src/components/Chart/Chart.logic.tsx +8 -0
  41. package/src/components/Chart/Chart.module.scss +58 -0
  42. package/src/components/Chart/Chart.types.ts +35 -0
  43. package/src/components/Chart/Chart.view.tsx +240 -0
  44. package/src/components/Chart/index.tsx +1 -0
  45. package/src/components/CheckBox/CheckBox.module.scss +36 -0
  46. package/src/components/CheckBox/CheckBox.tsx +63 -0
  47. package/src/components/CheckBox/index.tsx +1 -0
  48. package/src/components/CodeInput/CodeInput.module.scss +5 -0
  49. package/src/components/CodeInput/CodeInput.tsx +84 -0
  50. package/src/components/CodeInput/index.tsx +1 -0
  51. package/src/components/Collapsable/Collapsable.module.scss +42 -0
  52. package/src/components/Collapsable/Collapsable.tsx +253 -0
  53. package/src/components/Collapsable/index.tsx +1 -0
  54. package/src/components/Countdown/Countdown.tsx +130 -0
  55. package/src/components/Countdown/index.tsx +1 -0
  56. package/src/components/CurrencyInput/CurrencyInput.hook.ts +37 -0
  57. package/src/components/CurrencyInput/CurrencyInput.tsx +25 -0
  58. package/src/components/CurrencyInput/index.tsx +1 -0
  59. package/src/components/Divider/Divider.module.scss +7 -0
  60. package/src/components/Divider/Divider.tsx +13 -0
  61. package/src/components/Divider/index.tsx +1 -0
  62. package/src/components/EmailInput/EmailInput.module.scss +0 -0
  63. package/src/components/EmailInput/EmailInput.tsx +51 -0
  64. package/src/components/EmailInput/index.tsx +1 -0
  65. package/src/components/FadeIn/FadeIn.module.scss +9 -0
  66. package/src/components/FadeIn/FadeIn.tsx +77 -0
  67. package/src/components/FadeIn/index.tsx +1 -0
  68. package/src/components/FileInput/FileInput.module.scss +6 -0
  69. package/src/components/FileInput/FileInput.tsx +75 -0
  70. package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +20 -0
  71. package/src/components/FileInput/View/BigFactory/BigFactory.tsx +48 -0
  72. package/src/components/FileInput/View/BigFactory/index.tsx +1 -0
  73. package/src/components/FileInput/View/Compact/Compact.module.scss +68 -0
  74. package/src/components/FileInput/View/Compact/Compact.tsx +151 -0
  75. package/src/components/FileInput/View/Compact/index.tsx +1 -0
  76. package/src/components/FileInput/View/View.types.ts +12 -0
  77. package/src/components/FileInput/index.tsx +1 -0
  78. package/src/components/FlowController/FlowController.module.scss +47 -0
  79. package/src/components/FlowController/FlowController.tsx +93 -0
  80. package/src/components/FlowController/index.tsx +1 -0
  81. package/src/components/Form/Form.tsx +243 -0
  82. package/src/components/Form/index.ts +1 -0
  83. package/src/components/Form/v2/Form.hook.ts +341 -0
  84. package/src/components/Form/v2/Form.module.scss +0 -0
  85. package/src/components/Form/v2/Form.tsx +78 -0
  86. package/src/components/Form/v2/Form.types.ts +118 -0
  87. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
  88. package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +73 -0
  89. package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +1 -0
  90. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
  91. package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +91 -0
  92. package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +1 -0
  93. package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
  94. package/src/components/Form/v2/FormField/FormField.tsx +378 -0
  95. package/src/components/Form/v2/FormField/FormField.types.ts +129 -0
  96. package/src/components/Form/v2/FormField/index.tsx +1 -0
  97. package/src/components/Form/v2/index.tsx +1 -0
  98. package/src/components/Freeze/Freeze.tsx +9 -0
  99. package/src/components/Freeze/index.tsx +1 -0
  100. package/src/components/HSForms/HSForms.tsx +57 -0
  101. package/src/components/HSForms/index.tsx +1 -0
  102. package/src/components/Header/Header.module.scss +119 -0
  103. package/src/components/Header/Header.tsx +138 -0
  104. package/src/components/Header/index.tsx +1 -0
  105. package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +44 -0
  106. package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +28 -0
  107. package/src/components/HeaderCloseBtn/index.tsx +1 -0
  108. package/src/components/InfinityScroll/InfinityScroll.module.scss +30 -0
  109. package/src/components/InfinityScroll/InfinityScroll.tsx +187 -0
  110. package/src/components/InfinityScroll/index.tsx +1 -0
  111. package/src/components/Input/Input.module.scss +71 -0
  112. package/src/components/Input/Input.tsx +134 -0
  113. package/src/components/Input/index.tsx +1 -0
  114. package/src/components/InstantCounter/InstantCounter.tsx +77 -0
  115. package/src/components/InstantCounter/index.tsx +1 -0
  116. package/src/components/LavaLamp/LavaLamp.data.tsx +114 -0
  117. package/src/components/LavaLamp/LavaLamp.module.scss +26 -0
  118. package/src/components/LavaLamp/LavaLamp.tsx +131 -0
  119. package/src/components/LavaLamp/index.tsx +1 -0
  120. package/src/components/LavaLamp/v2/LavaLamp.module.scss +23 -0
  121. package/src/components/LavaLamp/v2/LavaLamp.tsx +197 -0
  122. package/src/components/LinkToId/LinkToId.module.scss +4 -0
  123. package/src/components/LinkToId/LinkToId.tsx +51 -0
  124. package/src/components/LinkToId/index.tsx +1 -0
  125. package/src/components/Loader/Loader.module.scss +40 -0
  126. package/src/components/Loader/Loader.tsx +18 -0
  127. package/src/components/Loader/index.tsx +1 -0
  128. package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +34 -0
  129. package/src/components/LoaderDotsIndicator/index.tsx +1 -0
  130. package/src/components/LoopableVideo/LoopableVideo.tsx +37 -0
  131. package/src/components/LoopableVideo/index.tsx +1 -0
  132. package/src/components/MainGrid/MainGrid.module.scss +28 -0
  133. package/src/components/MainGrid/MainGrid.tsx +68 -0
  134. package/src/components/MainGrid/index.tsx +1 -0
  135. package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +220 -0
  136. package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +38 -0
  137. package/src/components/MutableHamburgerButton/index.tsx +1 -0
  138. package/src/components/Notification/Notification.module.scss +25 -0
  139. package/src/components/Notification/Notification.tsx +13 -0
  140. package/src/components/Notification/index.tsx +1 -0
  141. package/src/components/OrderableList/OrderableList.module.scss +98 -0
  142. package/src/components/OrderableList/OrderableList.tsx +564 -0
  143. package/src/components/OrderableList/index.tsx +1 -0
  144. package/src/components/PaginationIndicator/PaginationIndicator.tsx +365 -0
  145. package/src/components/PaginationIndicator/index.tsx +1 -0
  146. package/src/components/Parallax/Parallax.module.scss +28 -0
  147. package/src/components/Parallax/Parallax.tsx +248 -0
  148. package/src/components/Parallax/index.tsx +1 -0
  149. package/src/components/Parallax/math/helpers.ts +289 -0
  150. package/src/components/PasswordInput/PasswordInput.module.scss +17 -0
  151. package/src/components/PasswordInput/PasswordInput.tsx +154 -0
  152. package/src/components/PasswordInput/index.tsx +1 -0
  153. package/src/components/PingPongText/PingPongText.module.scss +4 -0
  154. package/src/components/PingPongText/PingPongText.tsx +83 -0
  155. package/src/components/PingPongText/index.tsx +1 -0
  156. package/src/components/PixelatedScan/PixelatedScan.module.scss +86 -0
  157. package/src/components/PixelatedScan/PixelatedScan.tsx +175 -0
  158. package/src/components/PixelatedScan/index.tsx +1 -0
  159. package/src/components/Portal/Portal.module.scss +3 -0
  160. package/src/components/Portal/Portal.tsx +68 -0
  161. package/src/components/Portal/index.tsx +1 -0
  162. package/src/components/ProgressBar/ProgressBar.module.scss +44 -0
  163. package/src/components/ProgressBar/ProgressBar.tsx +124 -0
  164. package/src/components/ProgressBar/index.tsx +1 -0
  165. package/src/components/ProgressTexts/ProgressTexts.module.scss +37 -0
  166. package/src/components/ProgressTexts/ProgressTexts.tsx +85 -0
  167. package/src/components/ProgressTexts/index.tsx +1 -0
  168. package/src/components/Radio/Radio.module.scss +36 -0
  169. package/src/components/Radio/Radio.tsx +53 -0
  170. package/src/components/Radio/index.tsx +1 -0
  171. package/src/components/SectionContainer/SectionContainer.module.scss +30 -0
  172. package/src/components/SectionContainer/SectionContainer.tsx +49 -0
  173. package/src/components/SectionContainer/index.tsx +1 -0
  174. package/src/components/Select/Select.module.scss +58 -0
  175. package/src/components/Select/Select.tsx +192 -0
  176. package/src/components/Select/index.tsx +1 -0
  177. package/src/components/Skeleton/Skeleton.module.scss +21 -0
  178. package/src/components/Skeleton/Skeleton.tsx +29 -0
  179. package/src/components/Skeleton/index.tsx +1 -0
  180. package/src/components/Spacing/Spacing.module.scss +13 -0
  181. package/src/components/Spacing/Spacing.tsx +24 -0
  182. package/src/components/Spacing/index.tsx +1 -0
  183. package/src/components/StaticScroller/StaticScroller.module.scss +14 -0
  184. package/src/components/StaticScroller/StaticScroller.tsx +83 -0
  185. package/src/components/StaticScroller/index.tsx +1 -0
  186. package/src/components/Switch/Switch.module.scss +43 -0
  187. package/src/components/Switch/Switch.tsx +41 -0
  188. package/src/components/Switch/index.tsx +1 -0
  189. package/src/components/Table/Table.module.scss +76 -0
  190. package/src/components/Table/Table.tsx +152 -0
  191. package/src/components/Table/index.tsx +1 -0
  192. package/src/components/Tabs/Tabs.module.scss +40 -0
  193. package/src/components/Tabs/Tabs.tsx +104 -0
  194. package/src/components/Tabs/index.tsx +1 -0
  195. package/src/components/Text/Text.module.scss +81 -0
  196. package/src/components/Text/Text.tsx +42 -0
  197. package/src/components/Text/index.tsx +1 -0
  198. package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +47 -0
  199. package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +78 -0
  200. package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +106 -0
  201. package/src/components/Transition/MasksFactory/SquareToBalls.tsx +66 -0
  202. package/src/components/Transition/MasksFactory/utils.ts +35 -0
  203. package/src/components/Transition/Transition.module.scss +211 -0
  204. package/src/components/Transition/Transition.tsx +495 -0
  205. package/src/components/Transition/index.tsx +1 -0
  206. package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +9 -0
  207. package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +34 -0
  208. package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +143 -0
  209. package/src/components/UncontrolledTransition/index.tsx +2 -0
  210. package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +212 -0
  211. package/src/components/WalletConnectionWrapper/index.tsx +1 -0
  212. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +5 -0
  213. package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +52 -0
  214. package/src/components/utilitary/ScrollAndFocusLock/index.tsx +1 -0
  215. package/src/context/AsyncProcess.tsx +107 -0
  216. package/src/context/ContextAsyncControl.tsx +89 -0
  217. package/src/context/CustomBrowserRouter.tsx +55 -0
  218. package/src/context/OneUIProvider.tsx +308 -0
  219. package/src/hooks/logs/useDependencyChangeDetection.ts +25 -0
  220. package/src/hooks/logs/useIsMounting.ts +7 -0
  221. package/src/hooks/persistence/useLocalStorage.ts +45 -0
  222. package/src/hooks/shims/ObjectWatchShim.ts +56 -0
  223. package/src/hooks/ui/useAdaptiveImage.tsx +36 -0
  224. package/src/hooks/ui/useAlternating.tsx +22 -0
  225. package/src/hooks/ui/useBreakpoint.tsx +21 -0
  226. package/src/hooks/ui/useCustomScrollbar.module.scss +20 -0
  227. package/src/hooks/ui/useCustomScrollbar.tsx +22 -0
  228. package/src/hooks/ui/useEffectIf.ts +11 -0
  229. package/src/hooks/ui/useMouseHover.tsx +26 -0
  230. package/src/hooks/ui/usePaginationControls.module.scss +16 -0
  231. package/src/hooks/ui/usePaginationControls.tsx +176 -0
  232. package/src/hooks/ui/useSnapToViewport.module.scss +6 -0
  233. package/src/hooks/ui/useSnapToViewport.ts +28 -0
  234. package/src/hooks/ui/useTilt.tsx +219 -0
  235. package/src/hooks/ui/useZoomable.module.scss +34 -0
  236. package/src/hooks/ui/useZoomable.tsx +144 -0
  237. package/src/hooks/useAsyncControl.ai.md +25 -0
  238. package/src/hooks/useAsyncControl.ts +101 -0
  239. package/src/hooks/useContainedRepositioning.ts +110 -0
  240. package/src/hooks/useCustomHistory.ts +14 -0
  241. package/src/hooks/useElementFit.ts +82 -0
  242. package/src/hooks/useFirestoreWatch.ts +54 -0
  243. package/src/hooks/useForm.ts +49 -0
  244. package/src/hooks/useFreeze.ts +12 -0
  245. package/src/hooks/useHero.module.scss +41 -0
  246. package/src/hooks/useHero.ts +512 -0
  247. package/src/hooks/useIntersection.ts +32 -0
  248. package/src/hooks/useMergeRefs.ts +29 -0
  249. package/src/hooks/useObserve.ts +24 -0
  250. package/src/hooks/usePagination.ts +228 -0
  251. package/src/hooks/usePooledOperation.ts +54 -0
  252. package/src/hooks/usePooling.ts +46 -0
  253. package/src/hooks/useRebound.ts +23 -0
  254. package/src/hooks/useShortIntl.ai.md +5 -0
  255. package/src/hooks/useShortIntl.ts +97 -0
  256. package/src/hooks/utility/useAsyncMemo.ts +43 -0
  257. package/src/hooks/utility/useDepChange.ts +11 -0
  258. package/src/hooks/utility/useEvents.ts +33 -0
  259. package/src/hooks/utility/useImmediate.ts +8 -0
  260. package/src/hooks/utility/useManualInit.ts +24 -0
  261. package/src/hooks/utility/useModule.ts +15 -0
  262. package/src/hooks/utility/useQuery.ts +15 -0
  263. package/src/hooks/utility/useUniqueEffect.ts +22 -0
  264. package/src/index.ts +3 -0
  265. package/src/models/DebugLogger.ts +7 -0
  266. package/src/models/GenericContract.ts +169 -0
  267. package/src/models/Orbs.ts +97 -0
  268. package/src/reac-app-env.d.ts +6 -0
  269. package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
  270. package/src/storybookUtils/index.tsx +53 -0
  271. package/src/type-utils.ts +49 -0
  272. package/src/utility.d.ts +70 -0
  273. package/src/utils/blockchain.ts +43 -0
  274. package/src/utils/flatten.ts +17 -0
  275. package/src/utils/formatters.ts +36 -0
  276. package/src/utils/html.utils.ts +3 -0
  277. package/src/utils/ownEvent.ts +8 -0
  278. package/src/utils/test.ts +19 -0
@@ -0,0 +1,131 @@
1
+ import React, { PropsWithChildren, useMemo, useRef } from "react";
2
+ import useLavaLampSetup from "./LavaLamp.data";
3
+ import Styles from "./LavaLamp.module.scss";
4
+
5
+ type LavaLampProps = {
6
+ /**
7
+ * Required for defining the dimensions the lava lamp should have
8
+ */
9
+ className: string;
10
+ };
11
+
12
+ /**
13
+ * A peaceful component simulating an interactive lavalamp
14
+ **/
15
+ export default function LavaLamp({
16
+ className,
17
+ children,
18
+ }: PropsWithChildren<LavaLampProps>) {
19
+ const circleRef = useRef<SVGCircleElement>(null);
20
+
21
+ const { relativeTo, d, circlesConfig } = useLavaLampSetup(
22
+ (cx, cy) => {
23
+ const style: any = circleRef.current!.style;
24
+ style.cx = cx;
25
+ style.cy = cy;
26
+ },
27
+ (size) => {
28
+ const style: any = circleRef.current!.style;
29
+ style.r = size;
30
+ }
31
+ );
32
+
33
+ const randomCircles = useMemo(() => {
34
+ return circlesConfig.map(
35
+ ({ baseSize, startX, startY, translateX, translateY }) => (
36
+ <circle
37
+ r={baseSize + Math.random() * (baseSize / 2)}
38
+ fill="#fff"
39
+ cx={startX}
40
+ cy={startY}
41
+ >
42
+ <animateTransform
43
+ additive="sum"
44
+ attributeName="transform"
45
+ attributeType="XML"
46
+ type="translate"
47
+ values={`0 0; ${translateX} ${translateY}; 0 0;`}
48
+ dur={`${5 + Math.random() * 5}s`}
49
+ repeatCount="indefinite"
50
+ />
51
+ </circle>
52
+ )
53
+ );
54
+ }, [circlesConfig]);
55
+
56
+ return (
57
+ <div ref={relativeTo} className={`${Styles.root} ${className}`}>
58
+ {d && (
59
+ <svg className={Styles.effect} viewBox={`0 0 ${d.width} ${d.height}`}>
60
+ <filter
61
+ id={`goo-lava-lamp`}
62
+ width="10"
63
+ height="10"
64
+ x="0%"
65
+ y="0%"
66
+ filterRes="1"
67
+ >
68
+ <feGaussianBlur
69
+ in="SourceGraphic"
70
+ result="blur"
71
+ stdDeviation="40"
72
+ />
73
+ <feColorMatrix
74
+ in="blur"
75
+ mode="matrix"
76
+ values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 -7"
77
+ result="goo"
78
+ />
79
+ </filter>
80
+ <mask id={`mask-lava-lamp`}>
81
+ <g filter={`url(#${`goo-lava-lamp`})`} fill="#fff">
82
+ {randomCircles}
83
+ <circle ref={circleRef} fill="#fff" />
84
+ </g>
85
+ </mask>
86
+ <defs>
87
+ <radialGradient
88
+ id="grad1"
89
+ cx="50%"
90
+ cy="50%"
91
+ r="50%"
92
+ fx="50%"
93
+ fy="50%"
94
+ >
95
+ <stop
96
+ offset="0%"
97
+ style={{
98
+ stopColor: "var(--lava-lamp-color-a)",
99
+ stopOpacity: 1,
100
+ }}
101
+ />
102
+ <stop
103
+ offset="67.33%"
104
+ style={{
105
+ stopColor: "var(--lava-lamp-color-b)",
106
+ stopOpacity: 1,
107
+ }}
108
+ />
109
+ <stop
110
+ offset="88.33%"
111
+ style={{
112
+ stopColor: "var(--lava-lamp-color-c)",
113
+ stopOpacity: 1,
114
+ }}
115
+ />
116
+ </radialGradient>
117
+ </defs>
118
+ <rect
119
+ x="-50%"
120
+ y="-50%"
121
+ mask={`url(#${`mask-lava-lamp`})`}
122
+ width="200%"
123
+ height="200%"
124
+ style={{ fill: "url(#grad1)" }}
125
+ ></rect>
126
+ </svg>
127
+ )}
128
+ <div>{children}</div>
129
+ </div>
130
+ );
131
+ }
@@ -0,0 +1 @@
1
+ export { default } from './LavaLamp';
@@ -0,0 +1,23 @@
1
+ @use 'sass:math';
2
+
3
+ $transitionMs: math.div(1000, 5);
4
+ $transitionPositionMs: math.div($transitionMs, 2);
5
+ @value transitionMs #{$transitionMs};
6
+ @value transitionPositionMs #{$transitionPositionMs};
7
+
8
+ .root {
9
+ position: relative;
10
+ > canvas {
11
+ position: absolute;
12
+ top: 0;
13
+ left: 0;
14
+ bottom: 0;
15
+ right: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+ > div {
20
+ position: relative;
21
+ z-index: 1;
22
+ }
23
+ }
@@ -0,0 +1,197 @@
1
+ import React, { PropsWithChildren, useEffect, useMemo, useRef } from "react";
2
+ import useMergeRefs from "../../../hooks/useMergeRefs";
3
+ import useLavaLampSetup, { transitionPositionMs } from "../LavaLamp.data";
4
+ import Styles from "./LavaLamp.module.scss";
5
+ import { GuideOrb, Orb, OrbDrawer } from "../../../models/Orbs";
6
+
7
+ export default function LavaLamp({
8
+ className,
9
+ children,
10
+ }: PropsWithChildren<{ className: string }>) {
11
+ const guideConfig = useRef<{
12
+ x: number;
13
+ y: number;
14
+ posTimestamp: number;
15
+ posIncrement: [x: number, y: number];
16
+
17
+ size: number;
18
+ sizeTimestamp: number;
19
+ sizeIncrement: number;
20
+ }>({
21
+ size: 0,
22
+ sizeTimestamp: Date.now(),
23
+ sizeIncrement: 0,
24
+ x: 0,
25
+ y: 0,
26
+ posTimestamp: Date.now(),
27
+ posIncrement: [0, 0],
28
+ });
29
+ const { relativeTo, circlesConfig, d } = useLavaLampSetup(
30
+ (x, y) => {
31
+ guideConfig.current.posIncrement = [
32
+ x - guideConfig.current.x,
33
+ y - guideConfig.current.y,
34
+ ];
35
+ guideConfig.current.x = x;
36
+ guideConfig.current.y = y;
37
+ guideConfig.current.posTimestamp = Date.now();
38
+ },
39
+ (_size) => {
40
+ const size = _size * 1.2;
41
+ guideConfig.current.sizeIncrement =
42
+ guideConfig.current.size === 0 ? 0 : size - guideConfig.current.size;
43
+ guideConfig.current.size = size;
44
+ guideConfig.current.sizeTimestamp = Date.now();
45
+ }
46
+ );
47
+ const _canvasRef = useRef<HTMLCanvasElement>(null);
48
+ const canvasRef = useMergeRefs(
49
+ _canvasRef,
50
+ relativeTo as unknown as typeof _canvasRef
51
+ );
52
+ useEffect(() => {
53
+ if (!d) return;
54
+ const fc = canvasRef.current!;
55
+
56
+ const baseColor =
57
+ getComputedStyle(relativeTo.current!).getPropertyValue(
58
+ "--digital-blue"
59
+ ) || "#000000";
60
+
61
+ var c = document.createElement("canvas"),
62
+ w = (c.width = fc.width = d.width),
63
+ h = (c.height = fc.height = d.height),
64
+ ctx = c.getContext("2d")!,
65
+ fctx = fc.getContext("2d")!, // f means final
66
+ opts = {
67
+ orbCount: circlesConfig.length,
68
+ baseVel: Math.max(d.width * 0.001, 1),
69
+ addedVel: Math.max(d.width * 0.001, 1),
70
+
71
+ alphaThreshold: 200,
72
+ },
73
+ orbs = [] as (Orb | GuideOrb)[];
74
+ class CanvasOrbDrawer implements OrbDrawer {
75
+ protected gradient?: CanvasGradient;
76
+
77
+ private newGradient(color: string, radius: number) {
78
+ const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, radius);
79
+ gradient.addColorStop(0, `${color}ff`);
80
+ gradient.addColorStop(0.8, `${color}cc`);
81
+ gradient.addColorStop(1, `${color}00`);
82
+
83
+ return gradient;
84
+ }
85
+
86
+ private oldDrawCircle(x: number, y: number, radius: number) {
87
+ ctx.fillStyle = this.gradient ?? this.newGradient(baseColor, radius);
88
+ ctx.translate(x | 0, y | 0);
89
+ ctx.beginPath();
90
+ ctx.arc(0, 0, radius, 0, Math.PI * 2);
91
+ ctx.fill();
92
+ ctx.translate(-x | 0, -y | 0);
93
+ }
94
+ drawOrb(x: number, y: number, radius: number) {
95
+ this.oldDrawCircle(x, y, radius);
96
+ }
97
+
98
+ constructor(gradientRadius?: number) {
99
+ if (gradientRadius)
100
+ this.gradient = this.newGradient(baseColor, gradientRadius);
101
+ }
102
+ }
103
+
104
+ let animFrame: number;
105
+ function anim() {
106
+ animFrame = window.requestAnimationFrame(anim);
107
+
108
+ ctx.clearRect(0, 0, w, h);
109
+ fctx.fillStyle = "#0000";
110
+ fctx.fillRect(0, 0, w, h);
111
+
112
+ for (var i = 0; i < orbs.length; i++) {
113
+ const thisOrb = orbs[i];
114
+ if (thisOrb instanceof Orb) {
115
+ thisOrb.step();
116
+ } else {
117
+ thisOrb.step(
118
+ guideConfig.current!.size,
119
+ guideConfig.current!.sizeIncrement,
120
+ guideConfig.current!.sizeTimestamp,
121
+ guideConfig.current.posTimestamp,
122
+ guideConfig.current!,
123
+ {
124
+ x: guideConfig.current!.posIncrement[0],
125
+ y: guideConfig.current!.posIncrement[1],
126
+ }
127
+ );
128
+ }
129
+ }
130
+
131
+ var image = ctx.getImageData(0, 0, w, h),
132
+ data = new Uint8Array(image.data.buffer);
133
+
134
+ for (var i = 3; i < data.length; i += 4)
135
+ data[i] /= data[i] < opts.alphaThreshold ? 6 : 1;
136
+
137
+ fctx.putImageData(image, 0, 0);
138
+ }
139
+
140
+ function randomVelocity() {
141
+ return (opts.baseVel + opts.addedVel * Math.random()) | 0;
142
+ }
143
+ const orbBounds = { width: w, height: h };
144
+
145
+ for (let circleConfig of circlesConfig) {
146
+ const radius = circleConfig.baseSize * 1.5;
147
+ const randomRadius = (radius + (radius / 2) * Math.random()) | 0;
148
+ const drawerInstance = new CanvasOrbDrawer(randomRadius);
149
+ orbs.push(
150
+ new Orb(drawerInstance, randomVelocity(), orbBounds, randomRadius)
151
+ );
152
+ }
153
+ const guideOrbInstance = new GuideOrb(
154
+ new CanvasOrbDrawer(),
155
+ transitionPositionMs
156
+ );
157
+ let guideOrbAutoInstance: Orb;
158
+ orbs.push(guideOrbInstance);
159
+
160
+ canvasRef.current!.parentElement!.onmouseleave = () => {
161
+ const indexOfGuide = orbs.indexOf(guideOrbInstance);
162
+ if (indexOfGuide !== -1) {
163
+ const drawerInstance = new CanvasOrbDrawer(guideOrbInstance.lastRadius);
164
+ guideOrbAutoInstance = new Orb(
165
+ drawerInstance,
166
+ randomVelocity(),
167
+ orbBounds,
168
+ guideOrbInstance.lastRadius
169
+ );
170
+ guideOrbAutoInstance.radius = guideOrbInstance.lastRadius;
171
+ guideOrbAutoInstance.x = guideOrbInstance.lastX;
172
+ guideOrbAutoInstance.y = guideOrbInstance.lastY;
173
+ orbs.splice(indexOfGuide, 1);
174
+ orbs.push(guideOrbAutoInstance);
175
+ }
176
+ };
177
+ canvasRef.current!.parentElement!.onmouseenter = () => {
178
+ if (orbs.indexOf(guideOrbInstance) === -1) {
179
+ orbs.push(guideOrbInstance);
180
+ orbs.splice(orbs.indexOf(guideOrbAutoInstance), 1);
181
+ }
182
+ };
183
+
184
+ anim();
185
+
186
+ return () => {
187
+ window.cancelAnimationFrame(animFrame);
188
+ };
189
+ }, [circlesConfig]);
190
+
191
+ return (
192
+ <div className={`${className} ${Styles.root}`}>
193
+ <canvas ref={canvasRef} />
194
+ <div>{children}</div>
195
+ </div>
196
+ );
197
+ }
@@ -0,0 +1,4 @@
1
+ .root:hover {
2
+ text-decoration: underline;
3
+ cursor: pointer;
4
+ }
@@ -0,0 +1,51 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import Styles from "./LinkToId.module.scss";
3
+
4
+ export function scrollToId(
5
+ id: OnepercentUtility.PageSections,
6
+ shouldScrollToCenter: boolean = false
7
+ ) {
8
+ const el = document.getElementById(id);
9
+
10
+ if (el) {
11
+ const elStyles = window.getComputedStyle(el);
12
+ const padding = Number(elStyles.paddingTop.replace(/[^0-9]+/g, ""));
13
+ const elementPosition = el.offsetTop;
14
+ const elementHeight = el.clientHeight;
15
+
16
+ window.scrollTo({
17
+ behavior: "smooth",
18
+ //Go to element, scroll half the screen height scrollback half the element height
19
+ top: shouldScrollToCenter
20
+ ? elementPosition + elementHeight / 2 - window.innerHeight / 2
21
+ : elementPosition + padding,
22
+ });
23
+ }
24
+ }
25
+
26
+ /**
27
+ * This component creates an iteractive element and on click, routes to the specified id
28
+ **/
29
+ export default function LinkToId({
30
+ children,
31
+ id,
32
+ link,
33
+ scrollToCenter = false,
34
+ }: PropsWithChildren<{
35
+ id?: OnepercentUtility.PageSections;
36
+ link?: string;
37
+ scrollToCenter?: boolean;
38
+ }>) {
39
+ return link ? (
40
+ <span className={Styles.root} onClick={() => window.open(link, "_blank")}>
41
+ {children}
42
+ </span>
43
+ ) : (
44
+ <span
45
+ className={Styles.root}
46
+ onClick={() => scrollToId(id!, scrollToCenter)}
47
+ >
48
+ {children}
49
+ </span>
50
+ );
51
+ }
@@ -0,0 +1 @@
1
+ export { default, scrollToId } from './LinkToId';
@@ -0,0 +1,40 @@
1
+ @import "../../assets/styles/variables.scss";
2
+
3
+ .indicator {
4
+ white-space: nowrap;
5
+ font-size: 14px;
6
+ & span {
7
+ display: inline-block;
8
+ width: 0.75em;
9
+ height: 0.75em;
10
+ border-radius: 0.375em;
11
+ margin-left: 4px;
12
+ background-color: var(--loader--indicator-bg, $digitalBlue);
13
+ animation-name: transparentToOpaque;
14
+ animation-duration: $normal;
15
+ animation-iteration-count: infinite;
16
+ animation-timing-function: ease-out;
17
+ &:nth-child(1) {
18
+ margin-left: initial;
19
+ animation-delay: 0;
20
+ }
21
+ &:nth-child(2) {
22
+ animation-delay: $veryFast;
23
+ }
24
+ &:nth-child(3) {
25
+ animation-delay: $fast;
26
+ }
27
+ }
28
+ }
29
+
30
+ @keyframes transparentToOpaque {
31
+ 0% {
32
+ opacity: 0;
33
+ }
34
+ 50% {
35
+ opacity: 1;
36
+ }
37
+ 100% {
38
+ opacity: 0;
39
+ }
40
+ }
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import Styles from "./Loader.module.scss";
3
+
4
+ /**
5
+ * A simple loader
6
+ **/
7
+ export default function Loader({
8
+ className = "",
9
+ ...props
10
+ }: { className?: string } & React.HTMLProps<HTMLDivElement>) {
11
+ return (
12
+ <span className={`${Styles.indicator} ${className}`} {...props}>
13
+ <span />
14
+ <span />
15
+ <span />
16
+ </span>
17
+ );
18
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Loader';
@@ -0,0 +1,34 @@
1
+ import React, { useEffect, useState } from "react";
2
+
3
+ /**
4
+ * . .. ... . .. ...
5
+ **/
6
+ export default function LoaderDotsIndicator({
7
+ dotsCount = 3,
8
+ lockSize = false,
9
+ }: {
10
+ dotsCount?: number;
11
+ /** Makes the dots so that they do not affect layout size */
12
+ lockSize?: boolean;
13
+ }) {
14
+ const [text, setText] = useState(".");
15
+ useEffect(() => {
16
+ const fullText = new Array(dotsCount).fill(".").join("");
17
+ const intervalId = setInterval(() => {
18
+ setText((a) => (a === fullText ? "." : a + "."));
19
+ }, 250);
20
+
21
+ return () => clearInterval(intervalId);
22
+ }, [dotsCount]);
23
+
24
+ return (
25
+ <>
26
+ {text}
27
+ {lockSize && (
28
+ <span style={{ color: "#0000" }}>
29
+ {new Array(dotsCount - text.length).fill(".")}
30
+ </span>
31
+ )}
32
+ </>
33
+ );
34
+ }
@@ -0,0 +1 @@
1
+ export { default } from './LoaderDotsIndicator';
@@ -0,0 +1,37 @@
1
+ import React, {
2
+ DetailedHTMLProps,
3
+ HTMLAttributes,
4
+ useLayoutEffect,
5
+ useRef,
6
+ } from "react";
7
+
8
+ /**
9
+ * Plays a video and loops between the end and the timestamp you set
10
+ **/
11
+ export default function LoopableVideo({
12
+ videoSrc,
13
+ percentToBackTo,
14
+ ...props
15
+ }: {
16
+ videoSrc: string;
17
+ /** A value between 0-1 indicating the timestamp to go back to */
18
+ percentToBackTo: number;
19
+ } & DetailedHTMLProps<HTMLAttributes<HTMLVideoElement>, HTMLVideoElement>) {
20
+ if (process.env.NODE_ENV === "development")
21
+ if (percentToBackTo < 0 || percentToBackTo > 1)
22
+ throw new Error(`percentToBackTo should be a value between 0-1`);
23
+ return (
24
+ <video
25
+ autoPlay
26
+ muted
27
+ onEnded={({ currentTarget }) => {
28
+ const el = currentTarget as Omit<HTMLVideoElement, keyof HTMLElement>;
29
+ el.currentTime = el.duration * percentToBackTo;
30
+ el.play();
31
+ }}
32
+ {...props}
33
+ >
34
+ <source src={videoSrc} />
35
+ </video>
36
+ );
37
+ }
@@ -0,0 +1 @@
1
+ export { default } from './LoopableVideo';
@@ -0,0 +1,28 @@
1
+ .container {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ align-items: flex-start;
5
+ justify-content: space-between;
6
+
7
+ // TODO: Priorize reducing width of empty elements insteas of the main container
8
+ > :nth-child(1),
9
+ > :nth-child(3) {
10
+ flex: 1;
11
+ max-width: 250px;
12
+ min-width: 150px;
13
+ }
14
+
15
+ .content {
16
+ min-width: 250px;
17
+ }
18
+
19
+ > :nth-child(2) {
20
+ flex: 1;
21
+ max-width: 1200px;
22
+ }
23
+ }
24
+
25
+ .section {
26
+ align-items: flex-start;
27
+ min-height: initial;
28
+ }
@@ -0,0 +1,68 @@
1
+ import React, {
2
+ ElementRef,
3
+ ForwardedRef,
4
+ forwardRef,
5
+ useImperativeHandle,
6
+ useRef,
7
+ } from "react";
8
+ import UncontrolledTransition from "../UncontrolledTransition";
9
+ import Styles from "./MainGrid.module.scss";
10
+
11
+ function _MainGrid(
12
+ {
13
+ children,
14
+ leftContent,
15
+ rightContent,
16
+ }: {
17
+ leftContent?: React.ReactElement;
18
+ rightContent?: React.ReactElement;
19
+ children: React.ReactElement;
20
+ },
21
+ ref: ForwardedRef<
22
+ Pick<ElementRef<typeof UncontrolledTransition>, "setOrientation">
23
+ >
24
+ ) {
25
+ const refs = [
26
+ useRef<ElementRef<typeof UncontrolledTransition>>(null),
27
+ useRef<ElementRef<typeof UncontrolledTransition>>(null),
28
+ useRef<ElementRef<typeof UncontrolledTransition>>(null),
29
+ ];
30
+
31
+ useImperativeHandle(
32
+ ref,
33
+ () => ({
34
+ setOrientation: (orientation) => {
35
+ refs.forEach((r) => r.current?.setOrientation(orientation));
36
+ },
37
+ }),
38
+ []
39
+ );
40
+
41
+ return (
42
+ <>
43
+ <div className={Styles.container}>
44
+ <div className={leftContent ? Styles.content : ""}>
45
+ <UncontrolledTransition className={Styles.section} ref={refs[0]}>
46
+ {leftContent}
47
+ </UncontrolledTransition>
48
+ </div>
49
+ <div>
50
+ <UncontrolledTransition className={Styles.section} ref={refs[1]}>
51
+ {children}
52
+ </UncontrolledTransition>
53
+ </div>
54
+ <div className={rightContent ? Styles.content : ""}>
55
+ <UncontrolledTransition className={Styles.section} ref={refs[2]}>
56
+ {rightContent}
57
+ </UncontrolledTransition>
58
+ </div>
59
+ </div>
60
+ </>
61
+ );
62
+ }
63
+
64
+ /**
65
+ * This layout divides the screen in 3 fragments and provides a responsive adaptation when on mobile
66
+ **/
67
+ const MainGrid = forwardRef(_MainGrid);
68
+ export default MainGrid;
@@ -0,0 +1 @@
1
+ export { default } from './MainGrid';