diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx index a0847a1..d9a84b3 100644 --- a/components/ui/badge.tsx +++ b/components/ui/badge.tsx @@ -1,25 +1,25 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from 'react' +import { cva, type VariantProps } from 'class-variance-authority' -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils' const badgeVariants = cva( - "inline-flex items-center border rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", + 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', { variants: { variant: { default: - "bg-primary hover:bg-primary/80 border-transparent text-primary-foreground", + 'border-transparent bg-primary text-primary-foreground hover:bg-primary/80', secondary: - "bg-secondary hover:bg-secondary/80 border-transparent text-secondary-foreground", + 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', destructive: - "bg-destructive hover:bg-destructive/80 border-transparent text-destructive-foreground", - outline: "text-foreground", - }, + 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80', + outline: 'text-foreground' + } }, defaultVariants: { - variant: "default", - }, + variant: 'default' + } } ) diff --git a/lib/hooks/use-follow-scroll.ts b/lib/hooks/use-follow-scroll.ts deleted file mode 100644 index 47a5c29..0000000 --- a/lib/hooks/use-follow-scroll.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { useEffect, useRef } from 'react' - -const scrollToEnd = () => { - window.scrollTo({ - top: document.body.scrollHeight, - left: 0 - }) -} - -export function useFollowScroll(shouldFollow: boolean) { - const shouldFollowRef = useRef(shouldFollow) - const scrollRef = useRef(false) - const triggeredBySelfRef = useRef(false) - - useEffect(() => { - const handleScroll = () => { - if (triggeredBySelfRef.current) { - triggeredBySelfRef.current = false - return - } - scrollRef.current = true - } - window.addEventListener('scroll', handleScroll) - return () => window.removeEventListener('scroll', handleScroll) - }, []) - - useEffect(() => { - if (!scrollRef.current && shouldFollowRef.current) { - setTimeout(() => { - triggeredBySelfRef.current = true - scrollToEnd() - }) - } - }) - - useEffect(() => { - shouldFollowRef.current = shouldFollow - if (!shouldFollow) { - // Reset scrollRef - scrollRef.current = false - } - }, [shouldFollow]) -} diff --git a/lib/hooks/use-local-storage.ts b/lib/hooks/use-local-storage.ts deleted file mode 100644 index 15c4291..0000000 --- a/lib/hooks/use-local-storage.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { useEffect, useState } from 'react' - -const useLocalStorage = ( - key: string, - initialValue: T -): [T, (value: T) => void] => { - const [storedValue, setStoredValue] = useState(initialValue) - - useEffect(() => { - // Retrieve from localStorage - const item = window.localStorage.getItem(key) - if (item) { - setStoredValue(JSON.parse(item)) - } - }, [key]) - - const setValue = (value: T) => { - // Save state - setStoredValue(value) - // Save to localStorage - window.localStorage.setItem(key, JSON.stringify(value)) - } - return [storedValue, setValue] -} - -export default useLocalStorage diff --git a/lib/hooks/use-scroll.ts b/lib/hooks/use-scroll.ts deleted file mode 100644 index 30b841a..0000000 --- a/lib/hooks/use-scroll.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useCallback, useEffect, useState } from 'react' - -export default function useScroll(threshold: number) { - const [scrolled, setScrolled] = useState(false) - - const onScroll = useCallback(() => { - setScrolled(window.pageYOffset > threshold) - }, [threshold]) - - useEffect(() => { - window.addEventListener('scroll', onScroll) - return () => window.removeEventListener('scroll', onScroll) - }, [onScroll]) - - return scrolled -} diff --git a/lib/hooks/use-window-size.ts b/lib/hooks/use-window-size.ts deleted file mode 100644 index 9a3661d..0000000 --- a/lib/hooks/use-window-size.ts +++ /dev/null @@ -1,39 +0,0 @@ -'use client' - -import { useEffect, useState } from 'react' - -export default function useWindowSize() { - const [windowSize, setWindowSize] = useState<{ - width: number | undefined - height: number | undefined - }>({ - width: undefined, - height: undefined - }) - - useEffect(() => { - // Handler to call on window resize - function handleResize() { - // Set window width/height to state - setWindowSize({ - width: window.innerWidth, - height: window.innerHeight - }) - } - - // Add event listener - window.addEventListener('resize', handleResize) - - // Call handler right away so state gets updated with initial window size - handleResize() - - // Remove event listener on cleanup - return () => window.removeEventListener('resize', handleResize) - }, []) // Empty array ensures that effect is only run on mount - - return { - windowSize, - isMobile: typeof windowSize?.width === 'number' && windowSize?.width < 768, - isDesktop: typeof windowSize?.width === 'number' && windowSize?.width >= 768 - } -}