UNPKG

@web3auth/no-modal

Version:
16 lines (13 loc) 564 B
import { THEME_MODES } from '@web3auth/auth'; const htmlToElement = html => { const template = window.document.createElement("template"); const trimmedHtml = html.trim(); // Never return a text node of whitespace as the result template.innerHTML = trimmedHtml; return template.content.firstChild; }; const getTheme = theme => { if (theme === THEME_MODES.light) return "light"; if (theme === THEME_MODES.dark) return "dark"; return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; }; export { getTheme, htmlToElement };