Title: | Accessibility Toolbox for 'R' Users |
---|---|
Description: | Provides a toolbox that allows the user to implement accessibility related concepts. |
Authors: | Mohamed El Fodil Ihaddaden [aut, cre] |
Maintainer: | Mohamed El Fodil Ihaddaden <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-11-11 02:58:23 UTC |
Source: | https://github.com/feddelegrand7/savonliquide |
Add a description to an HTML element
add_description(element, descID, description, visible = FALSE)
add_description(element, descID, description, visible = FALSE)
element |
an HTML element to describe |
descID |
the ID of the div that will describe the HTML element |
description |
the description of the HTML element |
visible |
should the description be visible ? Defaults to FALSE |
an HTML element with a description attached to it
if (interactive()) { ui <- fluidPage( h2("Using a screen reader hit <Tab> or <Shift + Tab> to navigate between the buttons and stop at button 5 to see the difference"), actionButton( inputId = "inp1", label = "button 1" ), actionButton( inputId = "inp2", label = "button 2" ), actionButton( inputId = "inp3", label = "button 3" ), actionButton( inputId = "inp4", label = "button 4" ), actionButton( inputId = "inp5", label = "button 5" ) %>% add_description( description = "hello this is a button when you click it you'll have a thing, when you don't click it you'll have another thing", descID = "chkoup" ) ) server <- function(input, output, session) {} shinyApp(ui, server) }
if (interactive()) { ui <- fluidPage( h2("Using a screen reader hit <Tab> or <Shift + Tab> to navigate between the buttons and stop at button 5 to see the difference"), actionButton( inputId = "inp1", label = "button 1" ), actionButton( inputId = "inp2", label = "button 2" ), actionButton( inputId = "inp3", label = "button 3" ), actionButton( inputId = "inp4", label = "button 4" ), actionButton( inputId = "inp5", label = "button 5" ) %>% add_description( description = "hello this is a button when you click it you'll have a thing, when you don't click it you'll have another thing", descID = "chkoup" ) ) server <- function(input, output, session) {} shinyApp(ui, server) }
returns a report from the Contrast Checker API about color contrast for accessibility
check_contrast(fg_col, bg_col)
check_contrast(fg_col, bg_col)
fg_col |
the Foreground Color |
bg_col |
the Background Color |
Color Contrast Report
check_contrast(fg_col = "#21EA06", bg_col = "#483D3D")
check_contrast(fg_col = "#21EA06", bg_col = "#483D3D")
returns a report from the Contrast Checker API about color contrast for accessibility in a list format so that the information provided can be extracted and piped into other functions.
check_contrast_raw(fg_col, bg_col)
check_contrast_raw(fg_col, bg_col)
fg_col |
the Foreground Color |
bg_col |
the Background Color |
Color Contrast Report in a raw format
check_contrast_raw(fg_col = "#21EA06", bg_col = "#483D3D")
check_contrast_raw(fg_col = "#21EA06", bg_col = "#483D3D")
Make an element invisible so that it can only be read by screen readers
create_invisible_anchor(id, text, href = NULL)
create_invisible_anchor(id, text, href = NULL)
id |
id of the anchor |
text |
text of the anchor |
href |
of the anchor. Defaults to NULL. |
an invisible HTML anchor element
Describe an HTML element by another one
describe_using(element, descID)
describe_using(element, descID)
element |
the HTML element to describe |
descID |
one or a vector of many HTML elements' <IDs> that will be used to describe the 'element' parameter |
an HTML element described by another HTML element
if (interactive()) { ui <- fluidPage( h2("Using a screen reader hit Tab and Shift + Tab to navigate between the buttons and stop at button 2 to see the difference"), div( id = "paragraph", p("The following paragraph tag will be used as a descriptor") ), actionButton( inputId = "inp1", label = "button 1" ), actionButton( inputId = "inp2", label = "button 2" ) %>% describe_using( descID = "paragraph" ) ) server <- function(input, output, session) {} shinyApp(ui, server) }
if (interactive()) { ui <- fluidPage( h2("Using a screen reader hit Tab and Shift + Tab to navigate between the buttons and stop at button 2 to see the difference"), div( id = "paragraph", p("The following paragraph tag will be used as a descriptor") ), actionButton( inputId = "inp1", label = "button 1" ), actionButton( inputId = "inp2", label = "button 2" ) %>% describe_using( descID = "paragraph" ) ) server <- function(input, output, session) {} shinyApp(ui, server) }
Transform an HTML element to a Skip Link
make_skiplinks(element, skip_to, bg_color = "#002240", col = "#FFFFFF")
make_skiplinks(element, skip_to, bg_color = "#002240", col = "#FFFFFF")
element |
the element to use as a Skip Link |
skip_to |
the HTML element to skip to |
bg_color |
the background color of the element to use as a Skip Link |
col |
the color of the element to use as a Skip Link |
a Skip Link HTML element
if (interactive()) { ui <- fluidPage( tags$a("do you want to be redirected to google.com ?", id = "skip-link" ) %>% make_skiplinks( skip_to = "https://google.com", bg_color = "red", col = "white" ), h1("accessibility is not a detail") ) server <- function(input, output, session) {} shinyApp(ui, server) }
if (interactive()) { ui <- fluidPage( tags$a("do you want to be redirected to google.com ?", id = "skip-link" ) %>% make_skiplinks( skip_to = "https://google.com", bg_color = "red", col = "white" ), h1("accessibility is not a detail") ) server <- function(input, output, session) {} shinyApp(ui, server) }
Make HTML elements tabable
make_tabable(element, tab_index = 0)
make_tabable(element, tab_index = 0)
element |
the HTML element to be tabable (if not by default) |
tab_index |
takes either 0, a negative or a positive value according to the required state of the element. 0 will make the element tabable with its relative order defined by the platform convention. a negative value will make the element untabable. a positive value will make the element tabable and its relative order defined by the provided value. |
a tabable HTML element
if (interactive()) { ui <- fluidPage( textInput(inputId = "inp1", label = "input"), div(h1("Not tabable")) %>% make_tabable(tab_index = -1), div(h2("Tabable ! with priority")) %>% make_tabable(tab_index = 1), div(h2("Simply Tabable")) %>% make_tabable(tab_index = 0) ) server <- function(input, output, session) {} shinyApp(ui = ui, server = server) }
if (interactive()) { ui <- fluidPage( textInput(inputId = "inp1", label = "input"), div(h1("Not tabable")) %>% make_tabable(tab_index = -1), div(h2("Tabable ! with priority")) %>% make_tabable(tab_index = 1), div(h2("Simply Tabable")) %>% make_tabable(tab_index = 0) ) server <- function(input, output, session) {} shinyApp(ui = ui, server = server) }