Files
supabase/packages/common/helpers.ts
T
Francesco Sansalvadore e76aa11508 homepage cleanup (#29295)
* new homepage logos marquee

* add products claim

* logos spacing

* dashboard table editor demo

* dashboard table editor demo

* dashboard recordings

* rls policies

* update hp frameworks

* add dataAPIs to homepage bento

* tweet section update

* padding

* hp products update

* new customer stories hp section

* height

* finish homepage details

* update logos

* fix database visual

* improve functions visual ux

* animate data-apis visual

* realtime visual update

* reduce-motion and update chatbase logo

* lighter heading paragraph

* improve video tabs components

* add priority to offsetted images

* video plays inline

* fix mobile tweets spacing

* smoll

* load video slightly before the component enters the viewport

* fix product pointer-events

* theme based and light weight dashboard video

* testimonials margin

* remove yellow tint from light mode recordings

* fix vitest window-matchMedia error

* fix vitest window-matchMedia error

* fix url type

* remove tweet
2024-09-17 11:07:38 +02:00

36 lines
1.0 KiB
TypeScript

import { useSyncExternalStore } from 'react'
export const detectBrowser = () => {
if (!navigator) return undefined
if (navigator.userAgent.indexOf('Chrome') !== -1) {
return 'Chrome'
} else if (navigator.userAgent.indexOf('Firefox') !== -1) {
return 'Firefox'
} else if (navigator.userAgent.indexOf('Safari') !== -1) {
return 'Safari'
}
}
export const isBrowser = typeof window !== 'undefined'
const prefersReducedMotionMediaQuery =
isBrowser && window.matchMedia('(prefers-reduced-motion: reduce)')
/**
* @returns boolean value If the user has expressed their preference for reduced motion.
*/
export const useReducedMotion = (): boolean => {
if (!prefersReducedMotionMediaQuery) return false
return useSyncExternalStore(
(callback) => {
prefersReducedMotionMediaQuery.addEventListener('change', callback)
return () => {
prefersReducedMotionMediaQuery.removeEventListener('change', callback)
}
},
() => prefersReducedMotionMediaQuery.matches,
() => false
)
}