UNPKG

react-font-tools

Version:

Tools to help you with font of your app.

32 lines (27 loc) 963 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var react = require('react'); var useFontSize = function () { var _a = react.useState("1rem"), finalFontSize = _a[0], setFinalFontSize = _a[1]; react.useEffect(function () { setFontSize(getFontSize() || "1rem"); }, []); react.useEffect(function () { if (document) document.body.style.fontSize = finalFontSize; }, [finalFontSize]); var getFontSize = function () { if (typeof window === 'undefined') return null; return window.localStorage.getItem("font-size"); }; var setFontSize = function (value) { if (typeof window === 'undefined') return; window.localStorage.setItem("font-size", value); setFinalFontSize(value); }; return [finalFontSize, setFontSize]; }; exports.useFontSize = useFontSize; //# sourceMappingURL=index.js.map