css-zero 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b786d5d38b248a7289f4dcce1246ddcdffebc21deb4327dc8ac575c1466ba5b9
|
4
|
+
data.tar.gz: 4364538047fdcd11f323687ed346662b334651404bdabf2c125d822c3f96cc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9efa1df9e4643f47ef0dd2cf9d334a02ddfcbfcf1979819acdada8068aefe81c22347180d392151b6d8699ca6022253763cb7438bba59c20fec123f5d7ff0d8
|
7
|
+
data.tar.gz: fd75ca1525671ceb6ffcb24c3fd4291e0f044366999c2958c3fb33c84973fff0ca32e35c509cfce4b7e5ead3218706787fc29763096a1b30ad8c438d281a76ed
|
data/app/helpers/tabs_helper.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module TabsHelper
|
2
|
-
def tab_button(content = nil, value:, **, &)
|
3
|
-
tag.button(content, class: "btn", data: { tabs_target: "button", action: "tabs#select", value: }, **, &)
|
2
|
+
def tab_button(content = nil, id:, value:, **, &)
|
3
|
+
tag.button(content, id:, class: "btn", role: "tab", aria: { controls: value }, data: { tabs_target: "button", action: "tabs#select", value: }, **, &)
|
4
|
+
end
|
5
|
+
|
6
|
+
def tab_panel(id, labelled_by:, **, &)
|
7
|
+
tag.div(id:, role: "tabpanel", aria: { labelledby: labelled_by }, data: { tabs_target: "tab" }, **, &)
|
4
8
|
end
|
5
9
|
end
|
data/lib/css_zero/version.rb
CHANGED
@@ -2,24 +2,24 @@ import { Controller } from "@hotwired/stimulus"
|
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
4
|
static targets = [ "button", "tab" ]
|
5
|
-
static values
|
5
|
+
static values = { selected: String }
|
6
6
|
|
7
7
|
initialize() {
|
8
8
|
this.#showSelectedTab()
|
9
9
|
}
|
10
10
|
|
11
|
-
select(
|
12
|
-
this.selectedValue =
|
11
|
+
select({ target }) {
|
12
|
+
this.selectedValue = target.dataset.value
|
13
13
|
this.#showSelectedTab()
|
14
14
|
}
|
15
15
|
|
16
16
|
#showSelectedTab() {
|
17
17
|
this.buttonTargets.forEach(element => {
|
18
|
-
element.
|
18
|
+
element.ariaSelected = element.dataset.value === this.selectedValue
|
19
19
|
})
|
20
20
|
|
21
21
|
this.tabTargets.forEach(element => {
|
22
|
-
element.hidden = element.
|
22
|
+
element.hidden = element.id !== this.selectedValue
|
23
23
|
})
|
24
24
|
}
|
25
25
|
}
|