forked from TEN-framework/ten-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
22 lines (17 loc) · 671 Bytes
/
Copy pathutils.ts
File metadata and controls
22 lines (17 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as React from "react"
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function useIsMobileScreen(breakpoint?: string) {
const [isMobileScreen, setIsMobileScreen] = React.useState(false)
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${breakpoint ?? "768px"})`)
setIsMobileScreen(mql.matches)
const listener = () => setIsMobileScreen(mql.matches)
mql.addEventListener("change", listener)
return () => mql.removeEventListener("change", listener)
}, [breakpoint])
return isMobileScreen
}