mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-11 14:36:38 +03:00
Switch to Accessibility.Styled
This commit is contained in:
parent
f5a39abedf
commit
d2fdd69b6f
@ -28,10 +28,10 @@ module Nri.Ui.Tabs.V4 exposing
|
||||
|
||||
-}
|
||||
|
||||
import Accessibility.Aria
|
||||
import Accessibility.Key
|
||||
import Accessibility.Role
|
||||
import Accessibility.Widget
|
||||
import Accessibility.Styled.Aria as Aria
|
||||
import Accessibility.Styled.Key as Key
|
||||
import Accessibility.Styled.Role as Role
|
||||
import Accessibility.Styled.Widget as Widget
|
||||
import Css exposing (..)
|
||||
import EventExtras
|
||||
import Html.Styled as Html exposing (Attribute, Html)
|
||||
@ -112,14 +112,14 @@ viewCustom config viewInnerTab =
|
||||
|> Maybe.withDefault (Html.text "")
|
||||
, Html.styled Html.ul
|
||||
(stylesTabsAligned config.alignment)
|
||||
[ Attributes.fromUnstyled <| Accessibility.Role.tabList
|
||||
[ Role.tabList
|
||||
]
|
||||
viewTabs
|
||||
]
|
||||
, Html.div
|
||||
[ Attributes.fromUnstyled <| Accessibility.Role.tabPanel
|
||||
, Attributes.fromUnstyled <| Accessibility.Aria.labelledBy (tabToId selected)
|
||||
, Attributes.fromUnstyled <| Accessibility.Widget.hidden False
|
||||
[ Role.tabPanel
|
||||
, Aria.labelledBy (tabToId selected)
|
||||
, Widget.hidden False
|
||||
, Attributes.id (tabToBodyId selected)
|
||||
]
|
||||
[ config.content selected.id ]
|
||||
@ -151,13 +151,13 @@ viewTab { onSelect, tabs } viewInnerTab selected tab =
|
||||
Html.styled Html.li
|
||||
(stylesTabSelectable isSelected)
|
||||
[ Events.onClick (onSelect tab.id)
|
||||
, Attributes.fromUnstyled <| Accessibility.Key.onKeyDown [ Accessibility.Key.enter (onSelect tab.id) ]
|
||||
, Key.onKeyDown [ Key.enter (onSelect tab.id) ]
|
||||
, Events.onFocus (onSelect tab.id)
|
||||
, Attributes.tabindex 0
|
||||
, Attributes.fromUnstyled <| Accessibility.Role.presentation
|
||||
, Role.presentation
|
||||
, Attributes.id (tabToId tab)
|
||||
, Attributes.fromUnstyled <| Accessibility.Aria.controls (tabToBodyId tab)
|
||||
, Attributes.fromUnstyled <| Accessibility.Widget.selected (selected.id == tab.id)
|
||||
, Aria.controls (tabToBodyId tab)
|
||||
, Widget.selected (selected.id == tab.id)
|
||||
, Events.on "keyup" <|
|
||||
Json.Decode.andThen
|
||||
(\keyCode ->
|
||||
@ -189,7 +189,7 @@ viewTab { onSelect, tabs } viewInnerTab selected tab =
|
||||
, Css.fontSize Css.inherit
|
||||
, Css.cursor Css.pointer
|
||||
]
|
||||
[ Attributes.fromUnstyled <| Accessibility.Role.tab
|
||||
[ Role.tab
|
||||
, Attributes.tabindex -1
|
||||
]
|
||||
[ viewInnerTab tab ]
|
||||
@ -247,7 +247,7 @@ links config =
|
||||
|> Maybe.withDefault (Html.text "")
|
||||
, Html.styled Html.ul
|
||||
(stylesTabsAligned config.alignment)
|
||||
[ Attributes.fromUnstyled <| Accessibility.Role.tabList
|
||||
[ Role.tabList
|
||||
]
|
||||
(config.tabs
|
||||
|> mapWithCurrent (viewTabLink config)
|
||||
@ -274,14 +274,14 @@ viewTabLink config isSelected tabConfig =
|
||||
|
||||
currentPage =
|
||||
if isSelected then
|
||||
[ Attributes.fromUnstyled <| Accessibility.Aria.currentPage ]
|
||||
[ Aria.currentPage ]
|
||||
|
||||
else
|
||||
[]
|
||||
in
|
||||
Html.styled Html.li
|
||||
(stylesTabSelectable isSelected)
|
||||
[ Attributes.fromUnstyled <| Accessibility.Role.presentation
|
||||
[ Role.presentation
|
||||
, Attributes.id (tabToId { label = tabLabel })
|
||||
]
|
||||
[ case tabHref of
|
||||
@ -300,7 +300,7 @@ viewTabLink config isSelected tabConfig =
|
||||
]
|
||||
(List.concat
|
||||
[ [ Attributes.href href
|
||||
, Attributes.fromUnstyled <| Accessibility.Role.tab
|
||||
, Role.tab
|
||||
]
|
||||
, preventDefault
|
||||
, currentPage
|
||||
@ -321,7 +321,7 @@ viewTabLink config isSelected tabConfig =
|
||||
, Css.lineHeight (Css.num 1)
|
||||
]
|
||||
(List.concat
|
||||
[ [ Attributes.fromUnstyled <| Accessibility.Role.tab ]
|
||||
[ [ Role.tab ]
|
||||
, currentPage
|
||||
]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user