UNPKG

1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.makeDefaultCSS = exports.injectCSS = void 0;
4const injected = {};
5const injectCSS = (css) => {
6 // Skip in node
7 if (typeof document === 'undefined') {
8 return;
9 }
10 if (injected[css]) {
11 return;
12 }
13 const head = document.head || document.getElementsByTagName('head')[0];
14 const style = document.createElement('style');
15 style.appendChild(document.createTextNode(css));
16 head.appendChild(style);
17 injected[css] = true;
18};
19exports.injectCSS = injectCSS;
20const makeDefaultCSS = (scope, backgroundColor) => {
21 if (!scope) {
22 return `
23 * {
24 box-sizing: border-box;
25 }
26 body {
27 margin: 0;
28 background-color: ${backgroundColor};
29 }
30 `;
31 }
32 return `
33 ${scope} * {
34 box-sizing: border-box;
35 }
36 ${scope} *:-webkit-full-screen {
37 width: 100%;
38 height: 100%;
39 }
40 `;
41};
42exports.makeDefaultCSS = makeDefaultCSS;