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

70 lines
1.7 KiB
Elm
Raw Normal View History

2020-12-10 20:56:52 +03:00
module Examples.Switch exposing (Msg, State, example)
{-|
@docs Msg, State, example
-}
import Category
import Example exposing (Example)
import Html.Styled as Html
import Nri.Ui.Heading.V2 as Heading
import Nri.Ui.Switch.V1 as Switch
{-| -}
type alias State =
Bool
{-| -}
type Msg
= Switch Bool
example : Example State Msg
example =
{ name = "Switch"
, version = 1
, state = True
, update = \(Switch new) _ -> ( new, Cmd.none )
, subscriptions = \_ -> Sub.none
, preview =
[ Switch.view [ Switch.label (Html.text "Toggle On") ] False
, Switch.view [ Switch.label (Html.text "Toggle Off") ] True
]
2020-12-10 20:56:52 +03:00
, view =
\interactiveIsOn ->
[ Heading.h3 [] [ Html.text "Interactive" ]
, Switch.view
[ Switch.onSwitch Switch
, Switch.id "switch-interactive"
, Switch.label
(if interactiveIsOn then
Html.text "On"
2020-12-10 20:56:52 +03:00
else
Html.text "Off"
)
2020-12-10 20:56:52 +03:00
]
interactiveIsOn
, Heading.h3 [] [ Html.text "Disabled (On)" ]
, Switch.view
[ Switch.disabled
, Switch.id "switch-disabled-on"
, Switch.label (Html.text "Permanently on")
2020-12-10 20:56:52 +03:00
]
True
, Heading.h3 [] [ Html.text "Disabled (Off)" ]
, Switch.view
[ Switch.disabled
, Switch.id "switch-disabled-off"
, Switch.label (Html.text "Permanently off")
2020-12-10 20:56:52 +03:00
]
False
2020-12-10 20:56:52 +03:00
]
, categories = [ Category.Inputs ]
, keyboardSupport = [{- TODO -}]
}