diff --git a/src/js/lazily-loaded/Collapsible.js b/src/js/lazily-loaded/Collapsible.js index 588f222..0612695 100644 --- a/src/js/lazily-loaded/Collapsible.js +++ b/src/js/lazily-loaded/Collapsible.js @@ -224,12 +224,12 @@ class Collapsible { if (event.target.playbackRate * (reverse ? 1 : -1) > 0) { this.node.classList.remove(this.constructor.classes.active) - this.node.setAttribute('aria-expanded', false) + this.trigger.setAttribute('aria-expanded', false) this.setStartState() return } this.node.classList.add(this.constructor.classes.active) - this.node.setAttribute('aria-expanded', true) + this.trigger.setAttribute('aria-expanded', true) this.setEndState() } @@ -260,9 +260,11 @@ class Collapsible { if (this.initiallyOpen) { this.node.classList.add(this.constructor.classes.active) - this.node.setAttribute('aria-expanded', true) + this.trigger.setAttribute('aria-expanded', true) this.setEndState() return + } else { + this.trigger.setAttribute('aria-expanded', false) } this.setStartState() } diff --git a/src/js/lazily-loaded/Tabs.js b/src/js/lazily-loaded/Tabs.js index 304733c..6226960 100644 --- a/src/js/lazily-loaded/Tabs.js +++ b/src/js/lazily-loaded/Tabs.js @@ -10,6 +10,11 @@ class Tabs { removeAllActiveTabs(activeTabs) { for (let i = 0; i < activeTabs.length; i++) { const prevActiveTab = activeTabs[i] + if (prevActiveTab.classList.contains('tab-anchor')) { + prevActiveTab.setAttribute('aria-selected', 'false') + } else { + prevActiveTab.setAttribute('aria-hidden', 'true') + } prevActiveTab.classList.remove('activeTab') } } @@ -23,11 +28,14 @@ class Tabs { this.removeAllActiveTabs(activeTabs) anchor.classList.add('activeTab') + anchor.setAttribute('aria-selected', 'true') + const panelID = anchor.dataset.href const panel = parent.querySelector( `:scope > .tabs__content > [data-id="${panelID}"]` ) panel.classList.add('activeTab') + panel.setAttribute('aria-hidden', 'false') } init() { diff --git a/views/parts/_accordion.latte b/views/parts/_accordion.latte index b0451bd..b77e301 100644 --- a/views/parts/_accordion.latte +++ b/views/parts/_accordion.latte @@ -6,6 +6,16 @@ {varType bool $collapse_siblings} {* Whether or not opening one accordion items should close siblings. Default is falses *} {varType int $initially_open_item} {* By default all accordion items are closed. This can be used, and index passed to make one open by default *} + + +{* panels ids - required for a11y purposes *} +{var $panels_ids = []} +{var $random_string = uniqid()} +{foreach $items as $acc_index => $tab_content} + {var $index = $acc_index + 1} + {var $panels_ids[] = "{$random_string}_{$index}"} +{/foreach} +
{block acc_trigger}{/block} -
+
{block acc_content}{/block}
{* inner *} diff --git a/views/parts/_collapsibles.latte b/views/parts/_collapsibles.latte index 61a1b5e..978f768 100644 --- a/views/parts/_collapsibles.latte +++ b/views/parts/_collapsibles.latte @@ -72,7 +72,7 @@ {/embed}
{* col *}
-

1 Level - independed

+

1 Level - independent

{embed tr_part('_accordion'), items: $test_acc_items, diff --git a/views/parts/_tabs.latte b/views/parts/_tabs.latte index 49562d7..810dd50 100644 --- a/views/parts/_tabs.latte +++ b/views/parts/_tabs.latte @@ -1,18 +1,34 @@ {varType string $class} {* optional class to pass to the tabs element *} {varType array $tabs} {* $tabs array. Required. *} + +{* tabs ids - required for a11y purposes *} +{var $tabs_ids = []} +{var $random_string = uniqid()} +{foreach $tabs as $tab_index => $tab_content} + {var $index = $tab_index + 1} + {var $tabs_ids[] = "{$random_string}_{$index}"} +{/foreach} +
-
+
@@ -24,7 +40,11 @@
{block tab_panel}{/block} diff --git a/views/temp/views-parts-_accordion.latte--0114b62ed0.php b/views/temp/views-parts-_accordion.latte--0114b62ed0.php index a1e4d96..c855c24 100644 --- a/views/temp/views-parts-_accordion.latte--0114b62ed0.php +++ b/views/temp/views-parts-_accordion.latte--0114b62ed0.php @@ -13,23 +13,35 @@ final class Template0114b62ed0 extends Latte\Runtime\Template public function main(): array { extract($this->params); - if (!empty($items)) /* line 9 */ { + echo ' + +'; + $panels_ids = [] /* line 12 */; + $random_string = uniqid() /* line 13 */; + $iterations = 0; + foreach ($items as $acc_index => $tab_content) /* line 14 */ { + $index = $acc_index + 1 /* line 15 */; + $panels_ids[] = "{$random_string}_{$index}" /* line 16 */; + $iterations++; + } + echo "\n"; + if (!empty($items)) /* line 19 */ { echo '
'; - $this->renderBlock('acc_trigger', get_defined_vars()) /* line 36 */; + $this->renderBlock('acc_trigger', get_defined_vars()) /* line 47 */; echo ' -
+
'; - $this->renderBlock('acc_content', get_defined_vars()) /* line 42 */; + $this->renderBlock('acc_content', get_defined_vars()) /* line 57 */; echo '
@@ -86,7 +107,7 @@ public function prepare(): void { extract($this->params); if (!$this->getReferringTemplate() || $this->getReferenceType() === "extends") { - foreach (array_intersect_key(['index' => '21', 'item' => '21'], $this->params) as $ʟ_v => $ʟ_l) { + foreach (array_intersect_key(['acc_index' => '14', 'tab_content' => '14', 'index' => '31', 'item' => '31'], $this->params) as $ʟ_v => $ʟ_l) { trigger_error("Variable \$$ʟ_v overwritten in foreach on line $ʟ_l"); } } @@ -94,14 +115,14 @@ public function prepare(): void } - /** {block acc_trigger} on line 36 */ + /** {block acc_trigger} on line 47 */ public function blockAcc_trigger(array $ʟ_args): void { } - /** {block acc_content} on line 42 */ + /** {block acc_content} on line 57 */ public function blockAcc_content(array $ʟ_args): void { diff --git a/views/temp/views-parts-_collapsibles.latte--7b10b89549.php b/views/temp/views-parts-_collapsibles.latte--7b10b89549.php index e54a6a6..9e4605f 100644 --- a/views/temp/views-parts-_collapsibles.latte--7b10b89549.php +++ b/views/temp/views-parts-_collapsibles.latte--7b10b89549.php @@ -92,7 +92,7 @@ class="f-row" echo '
-

1 Level - independed

+

1 Level - independent

'; $this->enterBlockLayer(3, get_defined_vars()) /* line 76 */; if (false) { @@ -325,7 +325,7 @@ class="f-row" style="--i-cols: 3; --i-gap: 15; margin-bottom: 200px;" >
-
Custom Easing:
+
Custom Easing
'; $this->enterBlockLayer(11, get_defined_vars()) /* line 358 */; if (false) { diff --git a/views/temp/views-parts-_tabs.latte--517e083405.php b/views/temp/views-parts-_tabs.latte--517e083405.php index 5cd9d1e..a062188 100644 --- a/views/temp/views-parts-_tabs.latte--517e083405.php +++ b/views/temp/views-parts-_tabs.latte--517e083405.php @@ -13,29 +13,52 @@ final class Template517e083405 extends Latte\Runtime\Template public function main(): array { extract($this->params); - if (!empty($tabs)) /* line 4 */ { + echo "\n"; + $tabs_ids = [] /* line 6 */; + $random_string = uniqid() /* line 7 */; + $iterations = 0; + foreach ($tabs as $tab_index => $tab_content) /* line 8 */ { + $index = $tab_index + 1 /* line 9 */; + $tabs_ids[] = "{$random_string}_{$index}" /* line 10 */; + $iterations++; + } + echo "\n"; + if (!empty($tabs)) /* line 13 */ { echo '
-
+
'; $iterations = 0; - foreach ($iterator = $ʟ_it = new LR\CachingIterator($tabs, $ʟ_it ?? null) as $ta_key => $ta_content) /* line 11 */ { + foreach ($iterator = $ʟ_it = new LR\CachingIterator($tabs, $ʟ_it ?? null) as $ta_key => $ta_content) /* line 23 */ { echo ' '; @@ -49,18 +72,28 @@ class="tab-anchor '; '; $iterations = 0; - foreach ($iterator = $ʟ_it = new LR\CachingIterator($tabs, $ʟ_it ?? null) as $tp_key => $tp_content) /* line 24 */ { + foreach ($iterator = $ʟ_it = new LR\CachingIterator($tabs, $ʟ_it ?? null) as $tp_key => $tp_content) /* line 40 */ { echo '
'; - $this->renderBlock('tab_panel', get_defined_vars()) /* line 30 */; + $this->renderBlock('tab_panel', get_defined_vars()) /* line 50 */; echo '
'; @@ -79,7 +112,7 @@ public function prepare(): void { extract($this->params); if (!$this->getReferringTemplate() || $this->getReferenceType() === "extends") { - foreach (array_intersect_key(['ta_key' => '11', 'ta_content' => '11', 'tp_key' => '24', 'tp_content' => '24'], $this->params) as $ʟ_v => $ʟ_l) { + foreach (array_intersect_key(['tab_index' => '8', 'tab_content' => '8', 'ta_key' => '23', 'ta_content' => '23', 'tp_key' => '40', 'tp_content' => '40'], $this->params) as $ʟ_v => $ʟ_l) { trigger_error("Variable \$$ʟ_v overwritten in foreach on line $ʟ_l"); } } @@ -87,14 +120,14 @@ public function prepare(): void } - /** {block tab_anchor} on line 17 */ + /** {block tab_anchor} on line 33 */ public function blockTab_anchor(array $ʟ_args): void { } - /** {block tab_panel} on line 30 */ + /** {block tab_panel} on line 50 */ public function blockTab_panel(array $ʟ_args): void {