From 356c275df5f91464309d78c509be9aa4c734ed05 Mon Sep 17 00:00:00 2001 From: j-mendez Date: Thu, 12 Oct 2023 13:03:40 -0400 Subject: [PATCH] chore(guideline): add simple index handling --- README.md | 6 +++ RULES.md | 38 ++++++++----------- .../src/engine/rules/wcag_base.rs | 24 ++++++------ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 61065ac..93f7e91 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ The Rust web accessibility engine. ```rs +// pass in raw html and css if coming from a headless browser let audit = accessibility_rs::audit(&AuditConfig::new(&html, &css, false, "en")); ``` @@ -26,6 +27,11 @@ To help improve the rules the following needs to be done: 1. Add the logic of handling the rule to [wcag_rule_map](./accessibility-rs/src/engine/rules/wcag_rule_map.rs) and the [techniques](./accessibility-rs/src/engine/rules/techniques.rs). 1. Add a unit test. +## Examples + +1. Wasm example checkout [kayle_innate](https://github.com/a11ywatch/kayle/blob/main/kayle_innate/kayle_innate/src/lib.rs#L35). +1. Example integrating with a [headless browser](https://github.com/a11ywatch/kayle/blob/main/kayle/tests/innate.ts#L14). + ### License This project is licensed under either of diff --git a/RULES.md b/RULES.md index 4864543..d15ae24 100644 --- a/RULES.md +++ b/RULES.md @@ -1,27 +1,21 @@ # web-accessibility-rules -List of techniques we want to have and whether we have it handled or not for WCAG. +List of techniques we want to have and whether we have it handled or not for [WCAG2.1](https://www.w3.org/TR/WCAG21/). -## WCAG 2.0 +## WCAG 2.1 -### WCAGA +| Technique | Description | WCAG | | Type | Complete | +| -------------------------------------------------- | ------------------------------------ | ----- | ----- | -------- | +| [H25](https://www.w3.org/TR/WCAG20-TECHS/H25.html) | empty titles | A-AAA | error | ✅ | +| [H30](https://www.w3.org/TR/WCAG20-TECHS/H30.html) | text alternative img | A-AAA | error | ✅ | +| [H32](https://www.w3.org/TR/WCAG20-TECHS/H32.html) | missing form submit button | A-AAA | error | ✅ | +| [H36](https://www.w3.org/TR/WCAG20-TECHS/H36.html) | missing form img alt | A-AAA | error | ✅ | +| [H37](https://www.w3.org/TR/WCAG20-TECHS/H37.html) | missing img alt | A-AAA | error | ✅ | +| [H42](https://www.w3.org/TR/WCAG20-TECHS/H42.html) | heading found with no content | A-AAA | error | ✅ | +| [H57](https://www.w3.org/TR/WCAG20-TECHS/H57.html) | html contains valid lang | A-AAA | error | ✅ | +| [H64](https://www.w3.org/TR/WCAG20-TECHS/H64.html) | iframe missing title | A-AAA | error | ✅ | +| [F40](https://www.w3.org/TR/WCAG20-TECHS/F40.html) | meta redirect used with a time limit | A-AAA | error | ✅ | +| [F40](https://www.w3.org/TR/WCAG20-TECHS/F41.html) | meta refresh used to reload the page | A-AAA | error | ✅ | +| [F47](https://www.w3.org/TR/WCAG20-TECHS/F47.html) | blink element used for attention | A-AAA | error | ✅ | -| Technique | Description | Type | Complete | -| -------------------------------------------------- | ------------------------------------ | ----- | -------- | -| [H25](https://www.w3.org/TR/WCAG20-TECHS/H25.html) | empty titles | error | ✅ | -| [H30](https://www.w3.org/TR/WCAG20-TECHS/H30.html) | text alternative img | error | ✅ | -| [H32](https://www.w3.org/TR/WCAG20-TECHS/H32.html) | missing form submit button | error | ✅ | -| [H36](https://www.w3.org/TR/WCAG20-TECHS/H36.html) | missing form img alt | error | ✅ | -| [H37](https://www.w3.org/TR/WCAG20-TECHS/H37.html) | missing img alt | error | ✅ | -| [H42](https://www.w3.org/TR/WCAG20-TECHS/H42.html) | heading found with no content | error | ✅ | -| [H57](https://www.w3.org/TR/WCAG20-TECHS/H57.html) | html contains valid lang | error | ✅ | -| [H64](https://www.w3.org/TR/WCAG20-TECHS/H64.html) | iframe missing title | error | ✅ | -| [F40](https://www.w3.org/TR/WCAG20-TECHS/F40.html) | meta redirect used with a time limit | error | ✅ | -| [F40](https://www.w3.org/TR/WCAG20-TECHS/F41.html) | meta refresh used to reload the page | error | ✅ | -| [F47](https://www.w3.org/TR/WCAG20-TECHS/F47.html) | blink element used for attention | error | ✅ | - -### WCAGAA - -### WCAGAAA - -## WCAG 3.0 +Errors that can be to be tested with automation `11/70`. \ No newline at end of file diff --git a/accessibility-rs/src/engine/rules/wcag_base.rs b/accessibility-rs/src/engine/rules/wcag_base.rs index c52e524..613fce9 100644 --- a/accessibility-rs/src/engine/rules/wcag_base.rs +++ b/accessibility-rs/src/engine/rules/wcag_base.rs @@ -59,16 +59,20 @@ impl Principle { pub enum Guideline { /// Provide text alternatives for any non-text content so that it can be changed into other forms people need. TextAlternatives, + /// Create content that can be presented in different ways (for example simpler layout) without losing information or structure. + Adaptable, + /// Make it easier for users to see and hear content including separating foreground from background. + Distinguishable, + /// Provide users enough time to read and use content. + EnoughTime, + /// Do not design content in a way that is known to cause seizures. + Seizures, /// Provide ways to help users navigate, find content, and determine where they are. Navigable, /// Make text content readable and understandable. Readable, /// Make Web pages appear and operate in predictable ways. Predictable, - /// Provide users enough time to read and use content. - EnoughTime, - /// Create content that can be presented in different ways (for example simpler layout) without losing information or structure. - Adaptable, } impl Guideline { @@ -77,7 +81,9 @@ impl Guideline { match self { Guideline::TextAlternatives => "Guideline1_1", Guideline::Adaptable => "Guideline1_3", + Guideline::Distinguishable => "Guideline1_4", Guideline::EnoughTime => "Guideline2_2", + Guideline::Seizures => "Guideline2_3", Guideline::Navigable => "Guideline2_4", Guideline::Readable => "Guideline3_1", Guideline::Predictable => "Guideline3_2", @@ -85,13 +91,7 @@ impl Guideline { } /// the principle index pub fn as_index(&self) -> &'static str { - match self { - Guideline::TextAlternatives => "1_1", - Guideline::Adaptable => "1_3", - Guideline::EnoughTime => "2_2", - Guideline::Navigable => "2_4", - Guideline::Readable => "3_1", - Guideline::Predictable => "3_2", - } + let s = self.as_str(); + &s[9..s.len()] } }