Files
upstream-yaak/apps/yaak-client/hooks/useZoom.ts
upstream-mirror 906fb231cc
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped
snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 17:39:41 +05:00

28 lines
781 B
TypeScript

import { patchModel, settingsAtom } from "@yaakapp-internal/models";
import { useAtomValue } from "jotai";
import { useCallback } from "react";
export function useZoom() {
const settings = useAtomValue(settingsAtom);
const zoomIn = useCallback(async () => {
if (!settings) return;
await patchModel(settings, {
interfaceScale: Math.min(1.8, settings.interfaceScale * 1.1),
});
}, [settings]);
const zoomOut = useCallback(async () => {
if (!settings) return;
await patchModel(settings, {
interfaceScale: Math.max(0.4, settings.interfaceScale * 0.9),
});
}, [settings]);
const zoomReset = useCallback(async () => {
await patchModel(settings, { interfaceScale: 1 });
}, [settings]);
return { zoomIn, zoomOut, zoomReset };
}