@kupola/kupola 1.6.7 → 1.6.8
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.
- package/dist/kupola.cjs.js +16 -16
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +583 -572
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.umd.js +16 -16
- package/dist/kupola.umd.js.map +1 -1
- package/js/theme.js +22 -5
- package/package.json +1 -1
package/js/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconsPath, getDefaultTheme, getDefaultBrand } from './kupola-config.js';
|
|
1
|
+
import { getIconsPath, getDefaultTheme, getDefaultBrand, setConfig } from './kupola-config.js';
|
|
2
2
|
|
|
3
3
|
const THEME_KEY = 'kupola-theme';
|
|
4
4
|
const BRAND_KEY = 'kupola-brand';
|
|
@@ -78,22 +78,39 @@ function updateThemeIcon(toggleBtn) {
|
|
|
78
78
|
const iconEl = toggleBtn.querySelector('.theme-icon');
|
|
79
79
|
if (iconEl) {
|
|
80
80
|
const currentTheme = getTheme();
|
|
81
|
-
const
|
|
81
|
+
const iconsPath = getIconsPath();
|
|
82
82
|
iconEl.src = currentTheme === 'dark'
|
|
83
|
-
?
|
|
84
|
-
:
|
|
83
|
+
? iconsPath + 'sun.svg'
|
|
84
|
+
: iconsPath + 'moon.svg';
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function initTheme() {
|
|
89
89
|
|
|
90
|
+
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
91
|
+
if (toggleBtn) {
|
|
92
|
+
const iconEl = toggleBtn.querySelector('.theme-icon');
|
|
93
|
+
if (iconEl && iconEl.src) {
|
|
94
|
+
const iconPath = iconEl.src.substring(0, iconEl.src.lastIndexOf('/') + 1);
|
|
95
|
+
const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
96
|
+
const relativeIconsPath = iconPath.replace(window.location.origin + basePath, '');
|
|
97
|
+
if (relativeIconsPath !== iconPath) {
|
|
98
|
+
setConfig({
|
|
99
|
+
paths: {
|
|
100
|
+
icons: relativeIconsPath,
|
|
101
|
+
base: basePath
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
const savedTheme = getTheme();
|
|
91
109
|
setTheme(savedTheme);
|
|
92
110
|
|
|
93
111
|
const savedBrand = getBrand();
|
|
94
112
|
setBrand(savedBrand);
|
|
95
113
|
|
|
96
|
-
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
97
114
|
if (toggleBtn) {
|
|
98
115
|
updateThemeIcon(toggleBtn);
|
|
99
116
|
const existingOnClick = toggleBtn.onclick;
|
package/package.json
CHANGED