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

120 lines
2.2 KiB
Elm
Raw Normal View History

2018-09-26 17:02:10 +03:00
module Examples.Select exposing
( Msg
, State
, Value
, example
, init
, update
, State2, example2, init2, update2
2018-09-26 17:02:10 +03:00
)
2018-04-17 01:39:57 +03:00
{-|
@docs Msg
@docs State
@docs Value
@docs example
@docs init
@docs update
-}
2018-07-11 03:50:39 +03:00
import Html.Styled
2018-04-17 01:39:57 +03:00
import ModuleExample exposing (Category(..), ModuleExample)
import Nri.Ui.Select.V5 as Select
import Nri.Ui.Select.V6 as Select6
2018-04-17 01:39:57 +03:00
{-| -}
type alias Value =
String
{-| -}
type Msg
= ConsoleLog String
{-| -}
type alias State value =
2018-07-11 03:50:39 +03:00
Select.Config value
2018-04-17 01:39:57 +03:00
type alias State2 value =
Select6.Config value
2018-04-17 01:39:57 +03:00
{-| -}
example : (Msg -> msg) -> State Value -> ModuleExample msg
example parentMessage state =
2019-05-10 21:11:44 +03:00
{ name = "Nri.Ui.Select.V5"
2018-04-17 01:39:57 +03:00
, category = Inputs
, content =
2018-07-11 03:50:39 +03:00
[ Html.Styled.map (parentMessage << ConsoleLog) (Select.view state)
2018-04-17 01:39:57 +03:00
]
}
{-| -}
example2 : (Msg -> msg) -> State2 Value -> ModuleExample msg
example2 parentMessage state =
{ name = "Nri.Ui.Select.V6"
, category = Inputs
, content =
[ Html.Styled.map (parentMessage << ConsoleLog) (Select6.view state)
]
}
2018-04-17 01:39:57 +03:00
{-| -}
init : State Value
init =
{ current = ""
, choices =
[ { label = "Tacos", value = "Tacos" }
, { label = "Burritos", value = "Burritos" }
, { label = "Enchiladas", value = "Enchiladas" }
]
, id = Nothing
, valueToString = identity
2018-04-17 01:39:57 +03:00
}
{-| -}
init2 : State2 Value
init2 =
2019-05-18 01:38:47 +03:00
{ current = Nothing
, choices =
[ { label = "Tacos", value = "Tacos" }
, { label = "Burritos", value = "Burritos" }
, { label = "Enchiladas", value = "Enchiladas" }
]
, id = Nothing
, valueToString = identity
2019-05-18 01:38:47 +03:00
, defaultDisplayText = Nothing
}
2018-04-17 01:39:57 +03:00
{-| -}
update : Msg -> State Value -> ( State Value, Cmd Msg )
update msg state =
case msg of
ConsoleLog message ->
let
_ =
Debug.log "SelectExample" message
in
( state, Cmd.none )
{-| -}
update2 : Msg -> State2 Value -> ( State2 Value, Cmd Msg )
update2 msg state =
case msg of
ConsoleLog message ->
let
_ =
Debug.log "SelectExample" message
in
( state, Cmd.none )