-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): add aria-* visualizer plugin
- Loading branch information
1 parent
0876b3f
commit 2582da9
Showing
8 changed files
with
108 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Allows users to see what screen readers would see. | ||
*/ | ||
|
||
let Plugin = require("../base"); | ||
|
||
// this will let us get a shorter info panel that just | ||
// lets the user know we are tracking their focus | ||
const PANEL_OPTIONS = { | ||
statusPanelView: true, | ||
disableAnnotation: true, | ||
}; | ||
|
||
require("./style.less"); | ||
|
||
class AriaVisualizer extends Plugin { | ||
constructor(...args) { | ||
const options = Object.assign({}, args, { panel: PANEL_OPTIONS }); | ||
|
||
super(options); | ||
} | ||
|
||
getTitle() { | ||
return "aria-* Visualizer"; | ||
} | ||
|
||
getDescription() { | ||
return "See the effects of your aria-* attributes"; | ||
} | ||
|
||
run() { | ||
// pop up our info panel to let the user know what we're doing | ||
this.summary("Visualizing aria-*"); | ||
this.panel.render(); | ||
|
||
[...document.querySelectorAll("[aria-hidden=\"true\"]:not(.tota11y)")].forEach((element) => { | ||
if (!element.closest(".tota11y")) { | ||
element.classList.add("tota11y-aria-hidden-visualized"); | ||
} | ||
}); | ||
} | ||
|
||
cleanup() { | ||
[...document.querySelectorAll(".tota11y-aria-hidden-visualized")].forEach((element) => { | ||
element.classList.remove("tota11y-aria-hidden-visualized"); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = AriaVisualizer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import "../../less/variables.less"; | ||
|
||
.tota11y-aria-hidden-visualized { | ||
visibility: hidden !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters