okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-int (c157ea373) into f-split-qa1: my new strings renumbered after s3236 (s3237-s3255)e5476b0e1

main
987 B23 linesraw
1import { useEffect, useState } from 'react';
2
3export function useMedia(query: string) {
4  const [matches, setMatches] = useState(() => window.matchMedia(query).matches);
5  useEffect(() => {
6    const media = window.matchMedia(query);
7    const update = () => setMatches(media.matches);
8    update();
9    media.addEventListener('change', update);
10    return () => media.removeEventListener('change', update);
11  }, [query]);
12  return matches;
13}
14
15export function scrollBehavior(): ScrollBehavior {
16  const override = document.documentElement.dataset.motion;
17  return 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 {
22  return Math.max(44, Math.min(180, Math.floor(windowHeight * 0.3)));
23}