37 lines
915 B
TypeScript
37 lines
915 B
TypeScript
export const breakpoints = {
|
|
sm: 640,
|
|
md: 768,
|
|
lg: 1024,
|
|
xl: 1280,
|
|
'2xl': 1536
|
|
}
|
|
|
|
export function isMobile(): boolean {
|
|
if (typeof window === 'undefined') return false
|
|
return window.innerWidth < breakpoints.md
|
|
}
|
|
|
|
export function isTablet(): boolean {
|
|
if (typeof window === 'undefined') return false
|
|
return window.innerWidth >= breakpoints.md && window.innerWidth < breakpoints.lg
|
|
}
|
|
|
|
export function isDesktop(): boolean {
|
|
if (typeof window === 'undefined') return false
|
|
return window.innerWidth >= breakpoints.lg
|
|
}
|
|
|
|
export function getTouchTargetSize(size: 'sm' | 'md' | 'lg'): string {
|
|
const sizes = {
|
|
sm: 'min-w-[44px] min-h-[44px]',
|
|
md: 'min-w-[48px] min-h-[48px]',
|
|
lg: 'min-w-[56px] min-h-[56px]'
|
|
}
|
|
return sizes[size]
|
|
}
|
|
|
|
export function useMediaQuery(query: string): boolean {
|
|
if (typeof window === 'undefined') return false
|
|
return window.matchMedia(query).matches
|
|
}
|