Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make the badges accessible to screenreader #117

@jennybc

Description

@jennybc

It would be nice if the lifecycle badge SVGs included the stage in aria-label or similar.

As the maintainer of usethis and, therefore, the one-who-adds-lots-of-badges, I'm making similar requests in various places.

Gabor already did it (a while ago) in the badges provided by METACRAN:
metacran/metacranweb@8287a21

shields.io badges already are accessible FWIW.

I'm not sure how the .svgs here are actually made but presumably it's not too hard to do this.

library(tidyverse)

show_aria_label <- function(badge) {
  badge %>%
    xml2::read_xml() %>%
    xml2::as_list() %>%
    pluck("svg") %>%
    attributes() %>%
    pluck("aria-label")
}

show_aria_label("https://www.r-pkg.org/badges/version/usethis")
#> [1] "CRAN 2.1.5"

show_aria_label("https://www.r-pkg.org/badges/last-release/usethis")
#> [1] "CRAN 2021-12-09"

show_aria_label("https://cranlogs.r-pkg.org/badges/usethis")
#> [1] "CRAN downloads 270K/month"

show_aria_label("https://img.shields.io/github/workflow/status/r-lib/usethis/R-CMD-check?label=R-CMD-check")
#> [1] "R-CMD-check: passing"

show_aria_label("https://img.shields.io/badge/my__label-my__message-orange")
#> [1] "my_label: my_message"

show_aria_label("https://raw.githubusercontent.com/r-lib/lifecycle/main/man/figures/lifecycle-experimental.svg")
#> NULL

Created on 2021-12-17 by the reprex package (v2.0.1.9000)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions