mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-21 04:31:30 +03:00
098bdcce0c
And also applies the guidelines from https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role#Best_practices
78 lines
2.0 KiB
Elm
78 lines
2.0 KiB
Elm
module Examples.Tabs exposing
|
|
( example
|
|
, State, Msg
|
|
)
|
|
|
|
{-|
|
|
|
|
@docs example
|
|
@docs State, Msg
|
|
|
|
-}
|
|
|
|
import Category exposing (Category(..))
|
|
import Example exposing (Example)
|
|
import Html.Styled as Html
|
|
import List.Zipper
|
|
import Nri.Ui.Tabs.V4 as Tabs
|
|
|
|
|
|
type State
|
|
= First
|
|
| Second
|
|
|
|
|
|
type alias Msg =
|
|
State
|
|
|
|
|
|
example : Example State Msg
|
|
example =
|
|
{ name = "Nri.Ui.Tabs.V4"
|
|
, categories = [ Layout ]
|
|
, state = First
|
|
, update = \newTab oldTab -> ( newTab, Cmd.none )
|
|
, subscriptions = \_ -> Sub.none
|
|
, view =
|
|
\tab ->
|
|
[ Tabs.view
|
|
{ title = Nothing
|
|
, onSelect = identity
|
|
, tabs =
|
|
case tab of
|
|
First ->
|
|
List.Zipper.from
|
|
[]
|
|
(Tabs.Tab "First tab" First)
|
|
[ Tabs.Tab "Second tab" Second ]
|
|
|
|
Second ->
|
|
List.Zipper.from
|
|
[ Tabs.Tab "First tab" First ]
|
|
(Tabs.Tab "Second tab" Second)
|
|
[]
|
|
, content =
|
|
\id ->
|
|
case id of
|
|
First ->
|
|
Html.text "First"
|
|
|
|
Second ->
|
|
Html.text "Second"
|
|
, alignment = Tabs.Center
|
|
}
|
|
, Tabs.links
|
|
{ title = Nothing
|
|
, content = Html.text "Links"
|
|
, alignment = Tabs.Left
|
|
, tabs =
|
|
List.Zipper.from
|
|
[]
|
|
(Tabs.NormalLink { label = "Nowhere", href = Nothing })
|
|
[ Tabs.NormalLink { label = "Elm", href = Just "http://elm-lang.org" }
|
|
, Tabs.SpaLink { label = "Spa", href = "/#category/Layout", msg = Second }
|
|
]
|
|
}
|
|
]
|
|
}
|