@kupola/kupola 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,13 @@
1
- (function () {
2
- if (document.documentElement.hasAttribute('data-kupola-theme-preloaded')) {
3
- return;
4
- }
5
-
6
- var k = 'kupola-theme';
7
- var d = 'dark';
8
-
9
- function getTheme() {
10
- var s = localStorage.getItem(k);
11
- if (s === 'dark' || s === 'light') {
12
- return s;
13
- }
14
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
15
- return 'light';
16
- }
17
- return d;
18
- }
19
-
20
- var theme = getTheme();
21
- document.documentElement.setAttribute('data-theme', theme);
22
-
23
- var root = document.documentElement;
24
- root.style.setProperty('--bg-base-default', theme === 'dark' ? '#0C0C0D' : '#FFFFFF');
25
- root.style.setProperty('--text-default', theme === 'dark' ? '#E5E7EB' : '#0F1117');
26
-
27
- document.documentElement.setAttribute('data-kupola-theme-preloaded', 'true');
28
- })();
1
+ (function(){
2
+ if(document.documentElement.hasAttribute("data-kupola-theme-preloaded"))return;
3
+ var h=document.documentElement,
4
+ t=localStorage.getItem("kupola-theme")||(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");
5
+ h.setAttribute("data-theme",t);
6
+ var d=t==="dark";
7
+ h.style.backgroundColor=d?"#0C0C0D":"#FFFFFF";
8
+ h.style.color=d?"#E5E7EB":"#0F1117";
9
+ var s=document.createElement("style");
10
+ s.textContent=d?"body,header,aside,footer{background:#1A1B1D;color:#E5E7EB}":"body,header,aside,footer{background:#F5F5F5;color:#0F1117}";
11
+ document.head.appendChild(s);
12
+ h.setAttribute("data-kupola-theme-preloaded","true")
13
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kupola/kupola",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "A lightweight UI toolkit for any web project. No heavy frontend frameworks required.",
5
5
  "main": "dist/kupola.cjs.js",
6
6
  "module": "dist/kupola.esm.js",
@@ -80,7 +80,7 @@ export function kupola(options = {}) {
80
80
 
81
81
  // Inject theme preload script
82
82
  if (themePreload && !transformed.includes('data-kupola-theme-preloaded')) {
83
- const preloadScript = '<script>(function(){if(document.documentElement.hasAttribute(\'data-kupola-theme-preloaded\'))return;var k=\'kupola-theme\',d=\'dark\';function g(){var s=localStorage.getItem(k);if(s===\'dark\'||s===\'light\')return s;if(window.matchMedia&&window.matchMedia(\'(prefers-color-scheme: light)\').matches)return\'light\';return d}var theme=g();document.documentElement.setAttribute(\'data-theme\',theme);var root=document.documentElement;root.style.setProperty(\'--bg-base-default\',theme===\'dark\'?\'#0C0C0D\':\'#FFFFFF\');root.style.setProperty(\'--text-default\',theme===\'dark\'?\'#E5E7EB\':\'#0F1117\');document.documentElement.setAttribute(\'data-kupola-theme-preloaded\',\'true\')})();</script>';
83
+ const preloadScript = '<script>(function(){if(document.documentElement.hasAttribute("data-kupola-theme-preloaded"))return;var h=document.documentElement,t=localStorage.getItem("kupola-theme")||(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");h.setAttribute("data-theme",t);var d=t==="dark";h.style.backgroundColor=d?"#0C0C0D":"#FFFFFF";h.style.color=d?"#E5E7EB":"#0F1117";var s=document.createElement("style");s.textContent=d?"body,header,aside,footer{background:#1A1B1D;color:#E5E7EB}":"body,header,aside,footer{background:#F5F5F5;color:#0F1117}";document.head.appendChild(s);h.setAttribute("data-kupola-theme-preloaded","true")})();</script>';
84
84
 
85
85
  transformed = transformed.replace(
86
86
  '<head>',
@@ -27,7 +27,7 @@ class KupolaWebpackPlugin {
27
27
 
28
28
  // Inject theme preload script
29
29
  if (this.options.themePreload && !html.includes('data-kupola-theme-preloaded')) {
30
- const preloadScript = '<script>(function(){if(document.documentElement.hasAttribute(\'data-kupola-theme-preloaded\'))return;var k=\'kupola-theme\',d=\'dark\';function g(){var s=localStorage.getItem(k);if(s===\'dark\'||s===\'light\')return s;if(window.matchMedia&&window.matchMedia(\'(prefers-color-scheme: light)\').matches)return\'light\';return d}var theme=g();document.documentElement.setAttribute(\'data-theme\',theme);var root=document.documentElement;root.style.setProperty(\'--bg-base-default\',theme===\'dark\'?\'#0C0C0D\':\'#FFFFFF\');root.style.setProperty(\'--text-default\',theme===\'dark\'?\'#E5E7EB\':\'#0F1117\');document.documentElement.setAttribute(\'data-kupola-theme-preloaded\',\'true\')})();</script>';
30
+ const preloadScript = '<script>(function(){if(document.documentElement.hasAttribute("data-kupola-theme-preloaded"))return;var h=document.documentElement,t=localStorage.getItem("kupola-theme")||(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark");h.setAttribute("data-theme",t);var d=t==="dark";h.style.backgroundColor=d?"#0C0C0D":"#FFFFFF";h.style.color=d?"#E5E7EB":"#0F1117";var s=document.createElement("style");s.textContent=d?"body,header,aside,footer{background:#1A1B1D;color:#E5E7EB}":"body,header,aside,footer{background:#F5F5F5;color:#0F1117}";document.head.appendChild(s);h.setAttribute("data-kupola-theme-preloaded","true")})();</script>';
31
31
 
32
32
  html = html.replace(
33
33
  '<head>',