UNPKG

@coin-voyage/paykit

Version:

Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.

40 lines 1.43 kB
import { useEffect } from "react"; export function useGoogleFont(font) { useEffect(() => { if (!font) { return; } font = font.replace(/ /g, "+"); const googleapis = document.createElement("link"); googleapis.href = "https://fonts.googleapis.com"; googleapis.rel = "preconnect"; const gstatic = document.createElement("link"); gstatic.href = "https://fonts.gstatic.com"; gstatic.rel = "preconnect"; gstatic.crossOrigin = "true"; const link = document.createElement("link"); link.href = `https://fonts.googleapis.com/css2?family=${font}:wght@400;500;600&display=swap`; link.rel = "stylesheet"; document.head.appendChild(googleapis); document.head.appendChild(gstatic); document.head.appendChild(link); return () => { document.head.removeChild(googleapis); document.head.removeChild(gstatic); document.head.removeChild(link); }; }, [font]); } // TODO: This could be dynamic if theming wasn't set up as css variables export function useThemeFont(theme) { const themeFonts = { web95: "Lato", retro: "Nunito", midnight: "Inter", minimal: "Inter", rounded: "Nunito", }; const font = themeFonts[theme] ?? null; useGoogleFont(font ?? ""); } //# sourceMappingURL=useGoogleFont.js.map