okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
e5476b0e1
main
1import { useEffect , useState } from 'react' ; 2 3export function useMedia ( query :string ) { 4const [ matches , setMatches ] = useState (() => window . matchMedia ( query ). matches ); 5useEffect (() => { 6const media = window . matchMedia ( query ); 7const update = () => setMatches ( media . matches ); 8update (); 9media . addEventListener ( 'change' , update ); 10return () => media . removeEventListener ( 'change' , update ); 11}, [ query ]); 12return matches ; 13} 14 15export function scrollBehavior () :ScrollBehavior { 16const override = document . documentElement . dataset . motion ; 17return override === 'reduced' || ( override !== 'full' && window . matchMedia ( '(prefers-reduced-motion: reduce)' ). matches ) ?'instant' :'smooth' ; 18} 19 20/** The tallest the message box may grow: 30% of the window, between 44 and 180 pixels (the rest of the window keeps the toolbar and Send in view). */ 21export function composerCap ( windowHeight :number ) :number { 22return Math . max ( 44 , Math . min ( 180 , Math . floor ( windowHeight * 0.3 ))); 23}