Skip to content

Commit

Permalink
Button Example: Add AT support tables from ARIA-AT (pull #2569)
Browse files Browse the repository at this point in the history
Adds a section to the button example page after the source code section that shows a table of screen reader support levels for the example. The data is pulled from the aria-at project (aria-at.w3.org) and displayed in an iframe.

---------

Co-authored-by: Howard Edwards <[email protected]>
Co-authored-by: Matt King <[email protected]>
  • Loading branch information
3 people committed Mar 27, 2023
1 parent d02c812 commit 914bcb9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions content/patterns/button/examples/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ <h2 id="sc1_label">HTML Source Code</h2>
sourceCode.make();
</script>
</section>

<section id="at-support">
<h2>Assistive Technology Support</h2>
<h3>Command Button</h3>
<iframe
class="support-levels-command-button"
src="https://aria-at.w3.org/embed/reports/command-button"
height="100"
allow="clipboard-write"
style="border-style: none; width: 100%;">
</iframe>

<h3>Toggle Button</h3>
<iframe
class="support-levels-toggle-button"
src="https://aria-at.w3.org/embed/reports/toggle-button"
height="100"
allow="clipboard-write"
style="border-style: none; width: 100%;">
</iframe>
</section>
</main>
</body>
</html>
14 changes: 14 additions & 0 deletions content/shared/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// Rewrite links so they point to the proper spec document
window.addEventListener('DOMContentLoaded', resolveSpecLinks, false);

// Support levels iframes should not show scrollbars, so a message with the
// correct height will be posted from the iframe.
window.addEventListener('message', fixIframeHeight);

async function addExampleUsageWarning() {
// Determine we are on an example page
if (!document.location.href.match(/examples\/[^/]+\.html/)) return;
Expand Down Expand Up @@ -43,4 +47,14 @@
const fixSpecLink = specLinks({ specStatus: 'ED' });
document.querySelectorAll('a[href]').forEach(fixSpecLink);
}

function fixIframeHeight(event) {
const data = event.data;
if (!data.iframe || !data.height || isNaN(data.height)) {
return;
}
const iframe = document.querySelector(`.${data.iframe}`);
if (!iframe) return;
iframe.style.height = data.height + 'px';
}
})();
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"Hoyt",
"IDREF",
"IDREFS",
"iframes",
"imgs",
"Iskandar",
"issie",
Expand Down

0 comments on commit 914bcb9

Please sign in to comment.