You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
35 lines
1.1 KiB
import { clsx, type ClassValue } from 'clsx' |
|
import { twMerge } from 'tailwind-merge' |
|
|
|
export function cn(...inputs: ClassValue[]) { |
|
return twMerge(clsx(inputs)) |
|
} |
|
|
|
export function isSafari() { |
|
if (typeof window === 'undefined' || !window.navigator) return false |
|
const ua = window.navigator.userAgent |
|
const vendor = window.navigator.vendor |
|
return /Safari/.test(ua) && /Apple Computer/.test(vendor) && !/Chrome/.test(ua) |
|
} |
|
|
|
export function isAndroid() { |
|
if (typeof window === 'undefined' || !window.navigator) return false |
|
const ua = window.navigator.userAgent |
|
return /android/i.test(ua) |
|
} |
|
|
|
export function isTorBrowser() { |
|
if (typeof window === 'undefined' || !window.navigator) return false |
|
const ua = window.navigator.userAgent |
|
return /torbrowser/i.test(ua) |
|
} |
|
|
|
export function isInViewport(el: HTMLElement) { |
|
const rect = el.getBoundingClientRect() |
|
return ( |
|
rect.top >= 0 && |
|
rect.left >= 0 && |
|
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && |
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth) |
|
) |
|
}
|
|
|