A2UICore.Accessibility (A2UICore v0.1.1)

Copy Markdown View Source

What a component tells assistive technology.

The protocol guide ("Catalog-Agnostic Accessibility Requirements") asks catalogs and renderers to plumb the accessibility object of a component — label, description, live, hidden — into the platform's accessibility API, to infer sensible defaults from the component's visible text, and to let explicit attributes override what was inferred. attributes/2 computes exactly that, from the component definition and the data it is bound to:

  • label — the explicit accessibility.label, else the first non-empty string among the component's title, text and label properties;
  • description — the explicit accessibility.description;
  • live — "off", "polite" or "assertive" ("off" unless declared);
  • hidden — whether the component (and so its subtree) is hidden from assistive technology;
  • role and checked — for the basic catalog's interactive types: Button is a "button", TextField a "textbox", CheckBox a "checkbox" (with its state in checked) and ChoicePicker a "radiogroup".

lint/1 is the catalog-side requirement: interactive components must declare some way to label them.

iex> alias A2UICore.State.Component
iex> button = Component.new("go", "Button", %{
...>   "title" => "Submit",
...>   "accessibility" => %{"label" => "Send form", "live" => "polite"}
...> })
iex> {attributes, []} = A2UICore.Accessibility.attributes(button, A2UICore.Resolution.DataContext.new())
iex> {attributes.label, attributes.live, attributes.hidden, attributes.role}
{"Send form", "polite", false, "button"}

Summary

Types

A catalog component that cannot be labelled.

Functions

The accessibility attributes of component in context.

Checks a catalog against the requirement that components accepting actions or input bindings declare how they are labelled.

Types

attributes()

(since 0.1.0)
@type attributes() :: %{
  label: String.t() | nil,
  description: String.t() | nil,
  live: String.t(),
  hidden: boolean(),
  role: String.t() | nil,
  checked: boolean() | nil
}

finding()

(since 0.1.0)
@type finding() :: %{component: String.t(), reason: String.t()}

A catalog component that cannot be labelled.

Functions

attributes(component, context)

(since 0.1.0)

The accessibility attributes of component in context.

Dynamic values ({"path": …} / {"@path": …} bindings, function calls) are resolved against the context's data model; resolution warnings come back as effects.

lint(catalog)

(since 0.1.0)
@spec lint(A2UICore.Catalog.t()) :: [finding()]

Checks a catalog against the requirement that components accepting actions or input bindings declare how they are labelled.

A component is interactive when one of its properties is an Action or when it has a value property bound to a dynamic type. It is labellable when it declares a label, title, text or child property (required or not — an optional one is a fallback). Every component carries accessibility from the component envelope, so an explicit label is always possible; this checks that the catalog itself gives the component a visible one to fall back on.

Returns a list of findings; an empty list means the catalog conforms.