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

Disclosure examples for FAQ and image description: Update accessibility features documentation and implement coding practices in latest code guide #1814

Merged
merged 29 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88cf863
updated JS for disclosure buttons
jongund Mar 10, 2021
18990ed
updated documentation for using SVG graphics
jongund Mar 10, 2021
52a9b2e
fixing liniting errors
jongund Mar 10, 2021
d597e38
updated file names
jongund Mar 10, 2021
24f4f3c
fixed file reference issue
jongund Mar 10, 2021
468416e
fixed disclosure button and added pointer cursor on hover
jongund Jul 27, 2021
d2472b3
fixed code pen button and added pointer cursor on hover
jongund Jul 27, 2021
4372458
updated reference table
jongund Sep 21, 2021
b05cace
Merge branch 'main' of github.com:w3c/aria-practices
jongund Sep 28, 2021
6044a71
Merge branch 'main' of github.com:w3c/aria-practices
jongund Oct 5, 2021
0a9d289
merged main
jongund Oct 11, 2021
0a8d441
updated accessibility features documentation, the styling to match ot…
jongund Oct 11, 2021
7ad021b
updated documentation and use an external SVG for the image example
jongund Oct 11, 2021
95930b7
updated documentation
jongund Oct 11, 2021
e94a75f
fixed spelling error
jongund Oct 11, 2021
58625a5
updated documentation
jongund Oct 11, 2021
3852e65
udpated resolution of Minards chart
jongund Oct 11, 2021
73c53d8
updated documentation and restored using inline SVG for compatibility…
jongund Oct 11, 2021
47041ce
Merge branch 'main' of github.com:w3c/aria-practices
jongund Oct 18, 2021
dddfc5e
Merge branch 'main' into update-disclosure-button
jongund Oct 18, 2021
99fb5de
added region roles to the faq descriptions
jongund Oct 18, 2021
24a6be9
removed region additions
jongund Oct 19, 2021
1bc2c0b
Merge remote-tracking branch 'origin/main' into update-disclosure-button
mcking65 Nov 1, 2021
32d3121
Editorial revisions to accessibility features documentation
mcking65 Nov 1, 2021
4f9e186
Editorial revisions to states and props table
mcking65 Nov 1, 2021
ffa1067
editorial changes to accesibility features documentation
mcking65 Nov 1, 2021
c4dc8ba
Editorial revisions to states and props table
mcking65 Nov 1, 2021
b2915b4
removed keyboard event for Enter key., not needed
jongund Nov 1, 2021
15f12cc
added visual separator between questions/answers
jongund Nov 2, 2021
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
2 changes: 1 addition & 1 deletion aria-practices.html
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ <h3>Disclosure (Show/Hide)</h3>
<section class="notoc">
<h4>Examples</h4>
<ul>
<li><a href="examples/disclosure/disclosure-img-long-description.html">Disclosure (Show/Hide) of Image Description</a></li>
<li><a href="examples/disclosure/disclosure-image-description.html">Disclosure (Show/Hide) of Image Description</a></li>
<li><a href="examples/disclosure/disclosure-faq.html">Disclosure (Show/Hide) of Answers to Frequently Asked Questions</a></li>
<li><a href="examples/disclosure/disclosure-navigation.html">Disclosure (Show/Hide) Navigation Menu</a></li>
<li><a href="examples/disclosure/disclosure-navigation-hybrid.html">Disclosure (Show/Hide) Navigation Menu with Top-Level Links</a></li>
Expand Down
39 changes: 17 additions & 22 deletions examples/disclosure/css/disclosure-faq.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dl.faq button {
margin: 0;
padding: 0;
margin-top: 1em;
padding: 4px 8px;
font-weight: bold;
font-size: 110%;
border: thin solid transparent;
border: none;
background-color: transparent;
padding-left: 0.125em;
border-radius: 5px;
}

dl dd {
Expand All @@ -17,35 +17,30 @@ dl dd {

dl.faq .desc {
margin: 0;
padding: 0.5em;
margin-top: 0.25em;
padding: 0.25em;
font-size: 110%;
display: none;
background-color: #fffedb;
background-color: #fed;
}

dl.faq button:hover,
dl.faq button:focus {
background-color: #eee;
}

dl.faq button:focus {
border-color: #630;
}

dl.faq button:hover {
text-decoration: underline;
}

dl.faq button:active {
background-color: #bbb;
padding: 2px 6px;
background-color: #def;
border: 2px solid #005a9c;
cursor: pointer;
}

dl.faq button[aria-expanded="false"]::before {
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpolygon points='1 1, 1 11, 8 6' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E%0A");
padding-right: 0.35em;
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' style='forced-color-adjust: auto;'%3E%3Cpolygon points='1 1, 1 11, 8 6' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E%0A");
position: relative;
left: -2px;
}

dl.faq button[aria-expanded="true"]::before {
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpolygon points='1 1, 11 1, 6 8' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E ");
padding-right: 0.35em;
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' style='forced-color-adjust: auto;'%3E%3Cpolygon points='1 1, 11 1, 6 8' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E ");
position: relative;
left: -4px;
top: 2px;
}
45 changes: 45 additions & 0 deletions examples/disclosure/css/disclosure-image-description.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
figure button {
margin: 0;
margin-top: 1em;
padding: 4px 8px;
font-weight: bold;
font-size: 110%;
border: none;
background-color: transparent;
border-radius: 5px;
}

figure button:hover,
figure button:focus {
padding: 2px 6px;
background-color: #def;
border: 2px solid #005a9c;
cursor: pointer;
}

figure button[aria-expanded="false"]::before {
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' style='forced-color-adjust: auto;'%3E%3Cpolygon points='1 1, 1 11, 8 6' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E%0A");
position: relative;
left: -2px;
}

figure button[aria-expanded="true"]::before {
content: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' style='forced-color-adjust: auto;'%3E%3Cpolygon points='1 1, 11 1, 6 8' fill='currentColor' stroke= 'currentColor' /%3E%3C/svg%3E ");
position: relative;
left: -4px;
top: 2px;
}

figure figcaption {
text-align: left;
}

figure h3 {
margin: 0;
padding: 0;
margin-top: 1em;
}

figure .long_desc table tr:nth-child(even) {
background-color: #fed;
}
43 changes: 0 additions & 43 deletions examples/disclosure/css/disclosure-img-long-description.css

This file was deleted.

31 changes: 20 additions & 11 deletions examples/disclosure/disclosure-faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<!-- js and css for the disclosure example. -->
<link href="css/disclosure-faq.css" rel="stylesheet">
<script src="js/disclosureButton.js" type="text/javascript"></script>
<script src="js/disclosure-button.js" type="text/javascript"></script>

</head>
<body>
Expand All @@ -35,7 +35,7 @@ <h1>Example Disclosure (Show/Hide) for Answers to Frequently Asked Questions</h1
<p>Similar examples include:</p>
<ul>
<li>
<a href="disclosure-img-long-description.html">Example Disclosure (Show/Hide) for an Image Description</a>
<a href="disclosure-image-description.html">Example Disclosure (Show/Hide) for an Image Description</a>
</li>
<li>
<a href="disclosure-navigation.html">Example Disclosure Navigation Menu</a>
Expand Down Expand Up @@ -96,20 +96,29 @@ <h2 id="ex_label">Example</h2>

<section>
<h2>Accessibility Features</h2>
<ol>
<ul>
<li>
The semantic structure of the FAQ is conveyed with native <code>dl</code>, <code>dt</code> and <code>dd</code> elements.
So that the list structure is communicated to assistive technologies, instead of applying a button role to the <code>dt</code> element, a <code>button</code> element is contained within the <code>dd</code> element.
Similarly, the container for the answer content that is shown and hidden is inside of the <code>dd</code> element so the <code>dl</code> structure is complete even when the answers are all hidden.
</li>
<li> The visual indication of expanded and collapsed states is synchronized with the value of <code>aria-expanded</code> using a CSS attribute selector and <code>:before</code> pseudo element that generates an image with the <code>content</code> property.</li>
<li>The interactivity of the question is visually indicated on focus and hover:
<ul>
<li>The CSS <code>:focus</code> pseudo class is used to change the background and border colors.</li>
<li>The CSS <code>:hover</code> pseudo class is used to change the background color and underline the text.</li>
</ul>
<li>
To provide a visual indication the labels can also be used to change the state of the button, the background color changes, a border appears and the cursor changes to a pointer when a pointer hovers over the button. The border and pointer changes help people with visual impairments identify the element as interactive.
</li>
<li>
Because transparent borders are visible on some systems with operating system high contrast settings enabled, transparency cannot be used to create a visual difference between the element that is focused an other elements. Instead of using transparency, the focused element has a thicker border and less padding. When an element receives focus, its border changes from 0 to 2 pixels and padding is reduced by 2 pixels. When an element loses focus, its border changes from 2 pixels to 0 and padding is increased by 2 pixels.
</li>
<li>
The visual indication of expanded and collapsed states is synchronized with the value of <code>aria-expanded</code> using a CSS attribute selector and <code>:before</code> pseudo element that defines an SVG graphic to visually identify the state of a disclosure button using the <code>content</code> property.
</li>
</ol>
<li>
To ensure the inline SVG arrow graphics in the CSS have sufficient contrast with the background when high contrast settings invert colors, the color of the arrows are synchronized with the color of the text content.
For example, the color of the arrow is set to match the foreground color of high contrast mode text by specifying the CSS <code>currentColor</code> value for the <code>stroke</code> and <code>fill</code> properties of the <code>polygon</code> elements used to draw the arrows.
If specific colors were instead used to specify the <code>polygon</code> properties, those colors would remain the same in high contrast mode, which could lead to insufficient contrast between the arrows and the background or even make the arrows invisible if the color matched the high contrast mode background.<br>
Note: The SVG element needs to have the CSS <code>forced-color-adjust</code> property set to <code>auto</code> for the <code>currentColor</code> value to be updated in high contrast mode.
Some browsers do not use <code>auto</code> for the default value.
</li>
</ul>
</section>

<section>
Expand Down Expand Up @@ -232,7 +241,7 @@ <h2>Javascript and CSS Source Code</h2>
</li>
<li>
Javascript:
<a href="js/disclosureButton.js" type="text/javascript">disclosureButton.js</a>
<a href="js/disclosure-button.js" type="text/javascript">disclosureButton.js</a>
</li>
</ul>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<script src="../js/highlight.pack.js"></script>
<script src="../js/app.js"></script>

<link href="css/disclosure-img-long-description.css" rel="stylesheet">
<script src="js/disclosureButton.js" type="text/javascript"></script>
<link href="css/disclosure-image-description.css" rel="stylesheet">
<script src="js/disclosure-button.js" type="text/javascript"></script>

</head>
<body>
Expand Down Expand Up @@ -68,8 +68,10 @@ <h2 id="ex_label">Example</h2>
In order to facilitate the judgement of the eye regarding the diminution of the army, I supposed that the troops under Prince Jèrôme and under Marshal Davoust, who were sent to Minsk and Mobilow and who rejoined near Orscha and Witebsk, had always marched with the army.
</p>
<p><strong>Note: A French translation from Wikipedia.</strong></p>
<button type="button" aria-expanded="true" aria-controls="id_long_desc">Data Table for Minard's Chart</button>
<div id="id_long_desc">
<button type="button" aria-expanded="true" aria-controls="id_long_desc">
Data Table for Minard's Chart
</button>
<div class="long_desc" id="id_long_desc">
<h3 id="id_data_label">Data for Charles Minard's Chart of Napoleon's Invasion of Russia</h3>
<table aria-labelledby="id_data_label" class="data">
<thead>
Expand Down Expand Up @@ -246,15 +248,24 @@ <h3 id="id_data_label">Data for Charles Minard's Chart of Napoleon's Invasion of

<section>
<h2>Accessibility Features</h2>
<ol>
<li> The visual indication of expanded and collapsed states is synchronized with the value of <code>aria-expanded</code> using a CSS attribute selector and <code>:before</code> pseudo element that generates an image with the <code>content</code> property.</li>
<li>The interactivity of the disclosure button is visually indicated on focus and hover:
<ul>
<li>The CSS <code>:focus</code> pseudo class is used to change the background and border colors.</li>
<li>The CSS <code>:hover</code> pseudo class is used to change the background color and underline the text.</li>
</ul>
<ul>
<li>
To provide a visual indication the labels can also be used to change the state of the button, the background color changes, a border appears and the cursor changes to a pointer when a pointer hovers over the button. The border and pointer changes help people with visual impairments identify the element as interactive.
</li>
<li>
Because transparent borders are visible on some systems with operating system high contrast settings enabled, transparency cannot be used to create a visual difference between the element that is focused an other elements. Instead of using transparency, the focused element has a thicker border and less padding. When an element receives focus, its border changes from 0 to 2 pixels and padding is reduced by 2 pixels. When an element loses focus, its border changes from 2 pixels to 0 and padding is increased by 2 pixels.
</li>
</ol>
<li>
The visual indication of expanded and collapsed states is synchronized with the value of <code>aria-expanded</code> using a CSS attribute selector and <code>:before</code> pseudo element that defines an SVG graphic to visually identify the state of a disclosure button using the <code>content</code> property.
</li>
<li>
To ensure the SVG arrow graphic has sufficient contrast with the background when high contrast settings invert colors, the color of the arrow is synchronized with the color of the text content.
For example, the color of the arrow is set to match the foreground color of high contrast mode text by specifying the CSS <code>currentColor</code> value for the <code>polygon</code> properties of the <code>polygon</code> elements used to draw the arrows.
If specific colors were instead used to specify the <code>polygon</code> properties, those colors would remain the same in high contrast mode, which could lead to insufficient contrast between the arrow and the background or even make the arrow invisible if the color matched the high contrast mode background.<br>
Note: The SVG element needs to have the CSS <code>forced-color-adjust</code> property set to <code>auto</code> for the <code>currentColor</code> value to be updated in high contrast mode.
Some browsers do not use <code>auto</code> for the default value.
</li>
</ul>
</section>

<section>
Expand Down Expand Up @@ -374,11 +385,11 @@ <h2>Javascript and CSS Source Code</h2>
<ul id="css_js_files">
<li>
CSS:
<a href="css/disclosure-img-long-description.css" type="tex/css">disclosure-img-long-description.css</a>
<a href="css/disclosure-image-description.css" type="tex/css">disclosure-img-long-description.css</a>
</li>
<li>
Javascript:
<a href="js/disclosureButton.js" type="text/javascript">disclosureButton.js</a>
<a href="js/disclosure-button.js" type="text/javascript">disclosureButton.js</a>
</li>
</ul>
</section>
Expand Down
2 changes: 1 addition & 1 deletion examples/disclosure/disclosure-navigation-hybrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>Example Disclosure Navigation Menu with Top-Level Links</h1>
<ul>
<li><a href="disclosure-navigation.html">Example Disclosure Navigation Menu</a></li>
<li><a href="disclosure-faq.html">Example Disclosure (Show/Hide) for Answers to Frequently Asked Questions</a></li>
<li><a href="disclosure-img-long-description.html">Example Disclosure (Show/Hide) for an Image Description</a></li>
<li><a href="disclosure-image-description.html">Example Disclosure (Show/Hide) for an Image Description</a></li>
<li><a href="../menubar/menubar-navigation.html">Navigation Menubar Example</a></li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion examples/disclosure/disclosure-navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1>Example Disclosure Navigation Menu</h1>
<p>Similar examples include:</p>
<ul>
<li><a href="disclosure-faq.html">Example Disclosure (Show/Hide) for Answers to Frequently Asked Questions</a></li>
<li><a href="disclosure-img-long-description.html">Example Disclosure (Show/Hide) for an Image Description</a></li>
<li><a href="disclosure-image-description.html">Example Disclosure (Show/Hide) for an Image Description</a></li>
<li><a href="disclosure-navigation-hybrid.html">Example Disclosure Navigation Menu with Top-Level Links</a></li>
<li><a href="../menubar/menubar-navigation.html">Navigation Menubar Example</a></li>
</ul>
Expand Down
Loading