@radioactive-labs/plutonium 0.4.10 → 0.31.0
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/package.json +1 -1
- package/src/css/core.css +2 -2
- package/src/css/easymde.css +8 -8
- package/src/css/intl_tel_input.css +7 -7
- package/src/css/slim_select.css +5 -5
- package/src/dist/css/plutonium.css +2 -2
- package/src/dist/js/plutonium.js +35 -16
- package/src/dist/js/plutonium.js.map +3 -3
- package/src/dist/js/plutonium.min.js +1 -1
- package/src/dist/js/plutonium.min.js.map +3 -3
- package/src/js/controllers/color_mode_controller.js +48 -22
|
@@ -1,40 +1,66 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
3
2
|
|
|
4
3
|
// Connects to data-controller="color-mode"
|
|
5
4
|
export default class extends Controller {
|
|
6
|
-
|
|
5
|
+
static values = { current: String };
|
|
7
6
|
|
|
8
7
|
connect() {
|
|
9
|
-
|
|
8
|
+
// Set initial mode from localStorage or default
|
|
9
|
+
const mode = localStorage.getItem('theme') || "light";
|
|
10
|
+
this.setMode(mode);
|
|
11
|
+
|
|
12
|
+
// Listen for cross-tab theme changes
|
|
13
|
+
this.handleStorageChange = (e) => {
|
|
14
|
+
console.log('Storage event received in color-mode controller:', e.key, e.newValue, e.oldValue)
|
|
15
|
+
if (e.key === 'theme' && e.newValue) {
|
|
16
|
+
console.log('Updating color-mode theme to:', e.newValue)
|
|
17
|
+
this.setMode(e.newValue);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
window.addEventListener('storage', this.handleStorageChange);
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
disconnect() {
|
|
24
|
+
// Clean up event listener
|
|
25
|
+
window.removeEventListener('storage', this.handleStorageChange);
|
|
13
26
|
}
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
toggleMode() {
|
|
29
|
+
const current = this.currentValue || "light";
|
|
30
|
+
const next = current === "light" ? "dark" : "light";
|
|
31
|
+
this.setMode(next);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setMode(mode) {
|
|
35
|
+
// Update html class
|
|
36
|
+
if (mode === "dark") {
|
|
37
|
+
document.documentElement.classList.add("dark");
|
|
18
38
|
} else {
|
|
19
|
-
document.documentElement.classList.remove(
|
|
39
|
+
document.documentElement.classList.remove("dark");
|
|
20
40
|
}
|
|
21
|
-
}
|
|
22
41
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
// Update button state
|
|
43
|
+
this.currentValue = mode;
|
|
44
|
+
|
|
45
|
+
// Show/hide icons
|
|
46
|
+
this.toggleIcons(mode);
|
|
28
47
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
localStorage.theme = 'dark'
|
|
32
|
-
this.updateColorMode()
|
|
48
|
+
// Store in localStorage to trigger storage events in other tabs
|
|
49
|
+
localStorage.setItem('theme', mode);
|
|
33
50
|
}
|
|
34
51
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
toggleIcons(mode) {
|
|
53
|
+
const sun = this.element.querySelector(".color-mode-icon-light");
|
|
54
|
+
const moon = this.element.querySelector(".color-mode-icon-dark");
|
|
55
|
+
|
|
56
|
+
if (sun && moon) {
|
|
57
|
+
if (mode === "light") {
|
|
58
|
+
sun.classList.remove("hidden");
|
|
59
|
+
moon.classList.add("hidden");
|
|
60
|
+
} else {
|
|
61
|
+
sun.classList.add("hidden");
|
|
62
|
+
moon.classList.remove("hidden");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
39
65
|
}
|
|
40
66
|
}
|