Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement anchor variants #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"test-dependencies": {
"elm-explorations/test": "2.0.0 <= v < 3.0.0"
}
}
}
26 changes: 20 additions & 6 deletions src/Accessibility.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Accessibility exposing
, text
, h1, h2, h3, h4, h5, h6
, div, p, hr, pre, blockquote
, span, a, code, em, strong, i, b, u, sub, sup, br
, span, a, placeholderA, code, em, strong, i, b, u, sub, sup, br
, ol, ul, li, dl, dt, dd
, iframe, canvas, math
, form, formWithListeners, option
Expand Down Expand Up @@ -121,7 +121,7 @@ These elements will prevent you from adding event listeners.
@docs text
@docs h1, h2, h3, h4, h5, h6
@docs div, p, hr, pre, blockquote
@docs span, a, code, em, strong, i, b, u, sub, sup, br
@docs span, a, placeholderA, code, em, strong, i, b, u, sub, sup, br
@docs ol, ul, li, dl, dt, dd
@docs iframe, canvas, math
@docs form, formWithListeners, option
Expand Down Expand Up @@ -152,8 +152,8 @@ import Accessibility.Key as Key
import Accessibility.Role as Role
import Accessibility.Style as Style
import Accessibility.Utils exposing (nonInteractive)
import Html as Html
import Html.Attributes
import Html
import Html.Attributes exposing (href)


{-| All inputs must be associated with a `label`.
Expand Down Expand Up @@ -620,8 +620,22 @@ As you add links in your web application, please also consider reading through [
an event listener, use the elm/html library instead.

-}
a : List (Attribute Never) -> List (Html msg) -> Html msg
a attributes =
a : String -> List (Attribute Never) -> List (Html msg) -> Html msg
a href_ attributes =
Html.a (href href_ :: nonInteractive attributes)


{-|

An anchor tag doesn't always have an href applied to it and this is part of the HTML spec.

As seen in [this comment](https://github.com/tesk9/accessible-html/pull/20#issuecomment-1138738396), we should be implicitely able to support this.

There is an open issue in [elm/browser#34](https://github.com/elm/browser/issues/34) that should be taken into account when using this placeholderA element.

-}
placeholderA : List (Attribute Never) -> List (Html msg) -> Html msg
placeholderA attributes =
Html.a (nonInteractive attributes)


Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility/Aria.elm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ See [the spec](https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup).
-}

import Accessibility.Utils exposing (..)
import Html as Html
import Html
import Html.Attributes exposing (..)
import Json.Encode

Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility/Landmark.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The landmark you're most likely to need to set directly is `search`, as it does
-}

import Accessibility.Utils exposing (Role(..), role)
import Html as Html
import Html


{-| Creates a [`role="banner"`](https://www.w3.org/TR/wai-aria-1.1/#banner) attribute.
Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility/Live.elm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Learn more about how to use live regions [here](https://www.w3.org/TR/wai-aria-p
-}

import Accessibility.Utils exposing (..)
import Html as Html
import Html


{-| Supported for all elements.
Expand Down
13 changes: 1 addition & 12 deletions src/Accessibility/Role.elm
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,7 @@ module Accessibility.Role exposing
-}

import Accessibility.Utils exposing (Role(..), role)
import Html as Html
import Html.Attributes


{-| Set the role of a given element to be a given string.

div [ custom "tablist" ] [ tab1, tab2 ]

-}
custom : String -> Html.Attribute msg
custom =
Html.Attributes.attribute "role"
import Html


{-| Add [`role="alert"`](https://www.w3.org/TR/wai-aria-1.1/#alert) to the attributes of an element.
Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility/Style.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For more information on hiding/semi-hiding elements, please see [the a11y projec

-}

import Html as Html
import Html
import Html.Attributes


Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility/Utils.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Accessibility.Utils exposing (Role(..), aria, nonInteractive, role, roleToString, toBoolString, toListString, toTriStateString)
module Accessibility.Utils exposing (Role(..), aria, nonInteractive, role, toBoolString, toListString, toTriStateString)

import Html
import Html.Attributes exposing (..)
Expand Down