@kupola/kupola 1.7.2 → 1.7.4
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/css/kupola.css +20 -0
- package/dist/css/kupola.css +20 -0
- package/dist/kupola.cjs.js +19 -19
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.esm.js +820 -838
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.umd.js +21 -21
- package/dist/kupola.umd.js.map +1 -1
- package/js/theme.js +16 -43
- package/package.json +1 -1
package/js/theme.js
CHANGED
|
@@ -40,13 +40,7 @@ function setTheme(theme) {
|
|
|
40
40
|
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
41
41
|
if (toggleBtn) {
|
|
42
42
|
toggleBtn.setAttribute('data-current-theme', theme);
|
|
43
|
-
|
|
44
|
-
if (icon) {
|
|
45
|
-
const iconPath = icon.src.substring(0, icon.src.lastIndexOf('/') + 1);
|
|
46
|
-
icon.src = theme === 'dark'
|
|
47
|
-
? iconPath + 'sun.svg'
|
|
48
|
-
: iconPath + 'moon.svg';
|
|
49
|
-
}
|
|
43
|
+
updateThemeIcon(toggleBtn);
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
46
|
|
|
@@ -95,6 +89,13 @@ function updateThemeIcon(toggleBtn) {
|
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
|
|
92
|
+
function _themeToggleHandler(e) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
const currentTheme = getTheme();
|
|
95
|
+
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
96
|
+
setTheme(newTheme);
|
|
97
|
+
}
|
|
98
|
+
|
|
98
99
|
function initTheme() {
|
|
99
100
|
|
|
100
101
|
const toggleBtn = document.querySelector('[data-theme-toggle]');
|
|
@@ -102,46 +103,18 @@ function initTheme() {
|
|
|
102
103
|
if (!_themeInitialized) {
|
|
103
104
|
_themeInitialized = true;
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const iconPath = iconEl.src.substring(0, iconEl.src.lastIndexOf('/') + 1);
|
|
111
|
-
const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
112
|
-
const relativeIconsPath = iconPath.replace(window.location.origin + basePath, '');
|
|
113
|
-
if (relativeIconsPath !== iconPath) {
|
|
114
|
-
setConfig({
|
|
115
|
-
paths: {
|
|
116
|
-
icons: relativeIconsPath,
|
|
117
|
-
base: basePath
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
106
|
+
const savedTheme = getTheme();
|
|
107
|
+
setTheme(savedTheme);
|
|
108
|
+
|
|
109
|
+
const savedBrand = getBrand();
|
|
110
|
+
setBrand(savedBrand);
|
|
124
111
|
}
|
|
125
112
|
|
|
126
|
-
const savedTheme = getTheme();
|
|
127
|
-
setTheme(savedTheme);
|
|
128
|
-
|
|
129
|
-
const savedBrand = getBrand();
|
|
130
|
-
setBrand(savedBrand);
|
|
131
|
-
|
|
132
113
|
if (toggleBtn) {
|
|
133
114
|
updateThemeIcon(toggleBtn);
|
|
134
|
-
|
|
135
|
-
toggleBtn.
|
|
136
|
-
|
|
137
|
-
const currentTheme = getTheme();
|
|
138
|
-
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
139
|
-
setTheme(newTheme);
|
|
140
|
-
updateThemeIcon(toggleBtn);
|
|
141
|
-
if (typeof existingOnClick === 'function') {
|
|
142
|
-
existingOnClick.call(this, e);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
115
|
+
|
|
116
|
+
toggleBtn.removeEventListener('click', _themeToggleHandler);
|
|
117
|
+
toggleBtn.addEventListener('click', _themeToggleHandler);
|
|
145
118
|
}
|
|
146
119
|
|
|
147
120
|
let brandPicker = document.getElementById('brand-picker');
|
package/package.json
CHANGED