UNPKG

@whop/react

Version:

React SDK for building embedded apps on Whop

29 lines (28 loc) 802 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "script", { enumerable: true, get: function() { return script; } }); function script() { const cookie = document.cookie.match(/whop-frosted-theme=appearance:(?<appearance>light|dark)/)?.groups; const el = document.documentElement; const classes = [ "light", "dark" ]; const theme = cookie ? cookie.appearance : getSystemTheme(); function updateDOM(theme) { el.classList.remove(...classes); el.classList.add(theme); el.style.colorScheme = theme; } function getSystemTheme() { return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } updateDOM(theme); }