diff --git a/web/components/widgets/loading-indicator.tsx b/web/components/widgets/loading-indicator.tsx index 77d18006..3fc81566 100644 --- a/web/components/widgets/loading-indicator.tsx +++ b/web/components/widgets/loading-indicator.tsx @@ -1,34 +1,68 @@ import clsx from 'clsx' +import {useEffect, useRef} from 'react' +import FavIcon from "web/public/FavIcon"; + export type SpinnerSize = 'sm' | 'md' | 'lg' -function getSizeClass(size: SpinnerSize) { - switch (size) { - case 'sm': - return 'h-4 w-4 border-2' - case 'md': - return 'h-6 w-6 border-4' - case 'lg': - default: - return 'h-8 w-8 border-4' - } -} +// function getSizeClass(size: SpinnerSize) { +// switch (size) { +// case 'sm': +// return 'h-4 w-4 border-2' +// case 'md': +// return 'h-6 w-6 border-4' +// case 'lg': +// default: +// return 'h-8 w-8 border-4' +// } +// } + export function LoadingIndicator(props: { className?: string spinnerClassName?: string - size?: SpinnerSize + size?: 'sm' | 'md' | 'lg' }) { - const { className, spinnerClassName, size = 'lg' } = props + const {className, spinnerClassName} = props + const compassRef = useRef(null) + + useEffect(() => { + const el = compassRef.current + if (!el) return + + let angle = 0 + let timeoutId: number + + const randomTurn = () => { + // Randomly choose direction and angle + const direction = Math.random() > 0.5 ? 1 : -1 + const delta = Math.random() * 75 + 5 + angle = direction * delta + + el.style.transform = `rotate(${angle}deg)` + + // Random delay before next movement + const delay = Math.random() * 400 + 400 + timeoutId = window.setTimeout(randomTurn, delay) + } + + randomTurn() + return () => clearTimeout(timeoutId) + }, []) + return ( -
+
+ > + +
) } + diff --git a/web/pages/loading.tsx b/web/pages/loading.tsx new file mode 100644 index 00000000..8f93552f --- /dev/null +++ b/web/pages/loading.tsx @@ -0,0 +1,10 @@ +"use client"; + +import {LoadingIndicator} from "web/components/widgets/loading-indicator"; +import {LovePage} from "web/components/love-page"; + +export default function Loading() { + return + + ; +}