noredink-ui/styleguide-app/Examples/Tabs.elm

78 lines
2.0 KiB
Elm
Raw Normal View History

module Examples.Tabs exposing
( example
2020-03-31 22:43:32 +03:00
, State, Msg
)
{-|
@docs example
2020-03-31 22:43:32 +03:00
@docs State, Msg
-}
import Category exposing (Category(..))
2020-03-31 23:20:03 +03:00
import Example exposing (Example)
import Html.Styled as Html
import List.Zipper
2019-05-23 01:25:30 +03:00
import Nri.Ui.Tabs.V4 as Tabs
2020-03-31 22:43:32 +03:00
type State
= First
| Second
2020-03-31 22:43:32 +03:00
type alias Msg =
State
2020-03-31 23:20:03 +03:00
example : Example State Msg
2020-03-31 22:43:32 +03:00
example =
{ name = "Nri.Ui.Tabs.V4"
, categories = [ Layout ]
, state = First
, update = \newTab oldTab -> ( newTab, Cmd.none )
2020-03-31 22:48:26 +03:00
, subscriptions = \_ -> Sub.none
2020-03-31 22:43:32 +03:00
, view =
\tab ->
[ Tabs.view
{ title = Nothing
, onSelect = identity
, tabs =
case tab of
First ->
List.Zipper.from
[]
2020-03-31 22:43:32 +03:00
(Tabs.Tab "First tab" First)
[ Tabs.Tab "Second tab" Second ]
Second ->
List.Zipper.from
2020-03-31 22:43:32 +03:00
[ Tabs.Tab "First tab" First ]
(Tabs.Tab "Second tab" Second)
[]
2020-03-31 22:43:32 +03:00
, 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 }
]
}
]
}