From 8e3a030633f5de081937a37200174e08a10d6472 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 --- accessibility-rs/src/engine/rules/wcag_base.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/accessibility-rs/src/engine/rules/wcag_base.rs b/accessibility-rs/src/engine/rules/wcag_base.rs index c52e524..56c7ef2 100644 --- a/accessibility-rs/src/engine/rules/wcag_base.rs +++ b/accessibility-rs/src/engine/rules/wcag_base.rs @@ -59,6 +59,10 @@ 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 ways to help users navigate, find content, and determine where they are. Navigable, /// Make text content readable and understandable. @@ -67,8 +71,6 @@ pub enum Guideline { 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,6 +79,7 @@ impl Guideline { match self { Guideline::TextAlternatives => "Guideline1_1", Guideline::Adaptable => "Guideline1_3", + Guideline::Distinguishable => "Guideline1_4", Guideline::EnoughTime => "Guideline2_2", Guideline::Navigable => "Guideline2_4", Guideline::Readable => "Guideline3_1", @@ -85,13 +88,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()] } }