mirror of
https://github.com/layer-systems/website.git
synced 2026-09-15 15:59:41 +02:00
chore: update Radix UI dependencies and add mobile hook
- Updated @radix-ui/react-dialog from ^1.1.2 to ^1.1.15 - Updated @radix-ui/react-separator from ^1.1.0 to ^1.1.8 - Updated @radix-ui/react-slot from ^1.1.0 to ^1.2.4 - Updated @radix-ui/react-tooltip from ^1.1.4 to ^1.2.8 - Added a new hook `useIsMobile` to determine if the viewport is mobile-sized - Refactored tailwind.config.ts for better readability and maintainability
This commit is contained in:
19
src/hooks/use-mobile.tsx
Normal file
19
src/hooks/use-mobile.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as React from "react"
|
||||
|
||||
const MOBILE_BREAKPOINT = 768
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
}
|
||||
mql.addEventListener("change", onChange)
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
||||
return () => mql.removeEventListener("change", onChange)
|
||||
}, [])
|
||||
|
||||
return !!isMobile
|
||||
}
|
||||
Reference in New Issue
Block a user