@radioactive-labs/plutonium 0.1.17 → 0.2.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/dist/css/plutonium.css +1 -1
- package/src/dist/js/plutonium.js +19 -12
- package/src/dist/js/plutonium.js.map +2 -2
- package/src/dist/js/plutonium.min.js +14 -14
- package/src/dist/js/plutonium.min.js.map +3 -3
- package/src/js/controllers/resource_collapse_controller.js +21 -13
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
import { Collapse } from 'flowbite';
|
|
3
|
-
|
|
4
2
|
|
|
5
3
|
// Connects to data-controller="resource-collapse"
|
|
6
4
|
export default class extends Controller {
|
|
@@ -9,22 +7,32 @@ export default class extends Controller {
|
|
|
9
7
|
connect() {
|
|
10
8
|
console.log(`resource-collapse connected: ${this.element}`)
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// Default to false if the data attribute isn't set
|
|
11
|
+
if (!this.element.hasAttribute('data-visible')) {
|
|
12
|
+
this.element.setAttribute('data-visible', 'false')
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
this
|
|
15
|
+
// Set initial state
|
|
16
|
+
this.#updateState()
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
toggle() {
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
show() {
|
|
24
|
-
this.collapse.show()
|
|
20
|
+
const isVisible = this.element.getAttribute('data-visible') === 'true'
|
|
21
|
+
this.element.setAttribute('data-visible', (!isVisible).toString())
|
|
22
|
+
this.#updateState()
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
this.
|
|
25
|
+
#updateState() {
|
|
26
|
+
const isVisible = this.element.getAttribute('data-visible') === 'true'
|
|
27
|
+
|
|
28
|
+
if (isVisible) {
|
|
29
|
+
this.menuTarget.classList.remove('hidden')
|
|
30
|
+
this.triggerTarget.setAttribute('aria-expanded', 'true')
|
|
31
|
+
this.dispatch('expand')
|
|
32
|
+
} else {
|
|
33
|
+
this.menuTarget.classList.add('hidden')
|
|
34
|
+
this.triggerTarget.setAttribute('aria-expanded', 'false')
|
|
35
|
+
this.dispatch('collapse')
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
}
|