Some checks failed
tests / ci (pull_request) Has been cancelled
- Refactored imports in Select, Separator, Sheet, Sidebar, Skeleton, Sonner, Toggle, and Tooltip components to use new radix-ui package. - Enhanced styling for various components, including SelectTrigger, SelectContent, and TooltipContent for better visual consistency. - Introduced a new hook `useIsMobile` to manage mobile state detection. - Adjusted class names and styles for better responsiveness and accessibility across components. - Added support for custom spacing in ToggleGroup component.
20 lines
565 B
TypeScript
20 lines
565 B
TypeScript
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
|
|
}
|