Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve accordion accessibility #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dist/spectre.css
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,23 @@ video.video-responsive::before {
text-decoration: none;
}

.accordion [type=radio],
.accordion [type=checkbox] {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

.accordion [type=radio]:focus + label,
.accordion [type=checkbox]:focus + label {
box-shadow: 0 0 0 .1rem rgba(87, 85, 217, .2);
}

.accordion input:checked ~ .accordion-header .icon,
.accordion[open] .accordion-header .icon {
transform: rotate(90deg);
Expand Down
2 changes: 1 addition & 1 deletion dist/spectre.min.css

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/components.html
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
<div class="columns">
<div class="column col-6 col-md-12">
<div class="accordion">
<input type="radio" id="accordion-1" name="accordion-radio" hidden checked>
<input type="radio" id="accordion-1" name="accordion-radio" checked>
<label class="accordion-header c-hand" for="accordion-1">
<i class="icon icon-arrow-right mr-1"></i>
Elements
Expand All @@ -316,7 +316,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
</div>
</div>
<div class="accordion">
<input type="radio" id="accordion-2" name="accordion-radio" hidden>
<input type="radio" id="accordion-2" name="accordion-radio">
<label class="accordion-header c-hand" for="accordion-2">
<i class="icon icon-arrow-right mr-1"></i>
Layout
Expand All @@ -333,7 +333,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
</div>
</div>
<div class="accordion">
<input type="radio" id="accordion-3" name="accordion-radio" hidden>
<input type="radio" id="accordion-3" name="accordion-radio">
<label class="accordion-header c-hand" for="accordion-3">
<i class="icon icon-arrow-right mr-1"></i>
Components
Expand All @@ -352,7 +352,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
</div>
<div class="column col-6 col-md-12">
<div class="accordion">
<input type="checkbox" id="accordion-4" name="accordion-checkbox" hidden checked>
<input type="checkbox" id="accordion-4" name="accordion-checkbox" checked>
<label class="accordion-header c-hand" for="accordion-4">
Elements
</label>
Expand All @@ -368,7 +368,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
</div>
</div>
<div class="accordion">
<input type="checkbox" id="accordion-5" name="accordion-checkbox" hidden>
<input type="checkbox" id="accordion-5" name="accordion-checkbox">
<label class="accordion-header c-hand" for="accordion-5">
Layout
</label>
Expand All @@ -384,7 +384,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
</div>
</div>
<div class="accordion">
<input type="checkbox" id="accordion-6" name="accordion-checkbox" hidden>
<input type="checkbox" id="accordion-6" name="accordion-checkbox">
<label class="accordion-header c-hand" for="accordion-6">
Components
</label>
Expand All @@ -405,7 +405,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a
<!-- accordions -->
<pre class="code" data-lang="HTML"><code><span class="com">&lt;!-- standard Accordions example --&gt;</span>
&lt;<span class="tag">div</span> <span class="atn">class</span>=<span class="atv">&quot;accordion&quot;</span>&gt;
&lt;<span class="tag">input</span> <span class="atn">type</span>=<span class="atv">&quot;checkbox&quot;</span> <span class="atn">id</span>=<span class="atv">&quot;accordion-1&quot;</span> <span class="atn">name</span>=<span class="atv">&quot;accordion-checkbox&quot;</span> <span class="atn">hidden</span>&gt;
&lt;<span class="tag">input</span> <span class="atn">type</span>=<span class="atv">&quot;checkbox&quot;</span> <span class="atn">id</span>=<span class="atv">&quot;accordion-1&quot;</span> <span class="atn">name</span>=<span class="atv">&quot;accordion-checkbox&quot;</span>&gt;
&lt;<span class="tag">label</span> <span class="atn">class</span>=<span class="atv">&quot;accordion-header&quot;</span>&gt;
&lt;<span class="tag">i</span> <span class="atn">class</span>=<span class="atv">&quot;icon icon-arrow-right mr-1&quot;</span>&gt;&lt;<span class="tag">/i</span>&gt;
Title
Expand All @@ -417,7 +417,7 @@ <h3 class="s-title"><a href="#accordions" class="anchor" aria-hidden="true">#</a

<span class="com">&lt;!-- mutually exclusive Accordions example (with same input names) --&gt;</span>
&lt;<span class="tag">div</span> <span class="atn">class</span>=<span class="atv">&quot;accordion&quot;</span>&gt;
&lt;<span class="tag">input</span> <span class="atn">type</span>=<span class="atv">&quot;radio&quot;</span> <span class="atn">id</span>=<span class="atv">&quot;accordion-1&quot;</span> <span class="atn">name</span>=<span class="atv">&quot;accordion-radio&quot;</span> <span class="atn">hidden</span>&gt;
&lt;<span class="tag">input</span> <span class="atn">type</span>=<span class="atv">&quot;radio&quot;</span> <span class="atn">id</span>=<span class="atv">&quot;accordion-1&quot;</span> <span class="atn">name</span>=<span class="atv">&quot;accordion-radio&quot;</span>&gt;
&lt;<span class="tag">label</span> <span class="atn">class</span>=<span class="atv">&quot;accordion-header&quot;</span>&gt;
Title
&lt;<span class="tag">/label</span>&gt;
Expand Down
17 changes: 17 additions & 0 deletions docs/dist/spectre-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,23 @@ video.video-responsive::before {
text-decoration: none;
}

.accordion [type=radio],
.accordion [type=checkbox] {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

.accordion [type=radio]:focus + label,
.accordion [type=checkbox]:focus + label {
box-shadow: 0 0 0 .1rem rgba(87, 85, 217, .2);
}

.accordion input:checked ~ .accordion-header .icon,
.accordion[open] .accordion-header .icon {
transform: rotate(90deg);
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/spectre-rtl.min.css

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions docs/dist/spectre.css
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,23 @@ video.video-responsive::before {
text-decoration: none;
}

.accordion [type=radio],
.accordion [type=checkbox] {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

.accordion [type=radio]:focus + label,
.accordion [type=checkbox]:focus + label {
box-shadow: 0 0 0 .1rem rgba(87, 85, 217, .2);
}

.accordion input:checked ~ .accordion-header .icon,
.accordion[open] .accordion-header .icon {
transform: rotate(90deg);
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/spectre.min.css

Large diffs are not rendered by default.

Loading