feat(ui): initialize base nova design system
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { useSyncExternalStore } from "react"
|
||||
|
||||
const MOBILE_BREAKPOINT = 768
|
||||
|
||||
function subscribe(onChange: () => void) {
|
||||
const query = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
||||
query.addEventListener("change", onChange)
|
||||
return () => query.removeEventListener("change", onChange)
|
||||
}
|
||||
|
||||
function getSnapshot() {
|
||||
return window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`).matches
|
||||
}
|
||||
|
||||
export function useIsMobile() {
|
||||
return useSyncExternalStore(subscribe, getSnapshot, () => false)
|
||||
}
|
||||
Reference in New Issue
Block a user