mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-29 16:44:41 +03:00
Require an id
I think, since we should label our selects, that it's not unreasonable to require an id
This commit is contained in:
parent
44bbf5272a
commit
c2f0f883bd
@ -31,7 +31,7 @@ type alias Choice a =
|
||||
view :
|
||||
{ choices : List (Choice a)
|
||||
, current : Maybe a
|
||||
, id : Maybe String
|
||||
, id : String
|
||||
, valueToString : a -> String
|
||||
, defaultDisplayText : Maybe String
|
||||
}
|
||||
@ -64,11 +64,6 @@ view config =
|
||||
|> Maybe.map (viewDefaultChoice config.current >> List.singleton)
|
||||
|> Maybe.withDefault []
|
||||
|
||||
extraAttrs =
|
||||
config.id
|
||||
|> Maybe.map (\id -> [ Attributes.id id ])
|
||||
|> Maybe.withDefault []
|
||||
|
||||
currentVal =
|
||||
if config.current == Nothing && config.defaultDisplayText == Nothing then
|
||||
config.choices
|
||||
@ -92,7 +87,9 @@ view config =
|
||||
, Css.height (Css.px 45)
|
||||
, Css.width (Css.pct 100)
|
||||
]
|
||||
([ onSelectHandler ] ++ extraAttrs)
|
||||
[ onSelectHandler
|
||||
, Attributes.id config.id
|
||||
]
|
||||
|
||||
|
||||
viewDefaultChoice : Maybe a -> String -> Html a
|
||||
|
@ -39,7 +39,7 @@ example parentMessage state =
|
||||
, { label = "Burritos", value = "Burritos" }
|
||||
, { label = "Enchiladas", value = "Enchiladas" }
|
||||
]
|
||||
, id = Just "tortilla-selector"
|
||||
, id = "tortilla-selector"
|
||||
, valueToString = identity
|
||||
, defaultDisplayText = Just "Select a tasty tortilla based treat!"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user