🎨 pull out checkbox helper

This commit is contained in:
Tessa Kelly 2019-04-04 11:35:54 -07:00
parent 28396866ad
commit ef219d7259

View File

@ -162,16 +162,7 @@ toClassList =
List.map (\a -> ( "checkbox-V3__" ++ a, True )) >> Attributes.classList
viewSquareCheckbox :
{ a
| identifier : String
, label : String
, setterMsg : Bool -> msg
, selected : IsSelected
, disabled : Bool
}
-> (String -> Html.Html msg)
-> Html.Html msg
viewSquareCheckbox : Model msg -> (String -> Html.Html msg) -> Html.Html msg
viewSquareCheckbox model labelView =
let
icon =
@ -186,12 +177,7 @@ viewSquareCheckbox model labelView =
checkboxCheckedPartially
in
checkboxContainer model
[ Html.checkbox model.identifier
(selectedToMaybe model.selected)
[ Events.onCheck (\_ -> onCheck model)
, Attributes.id model.identifier
, Attributes.disabled model.disabled
]
[ viewCheckbox model
, if model.disabled then
viewDisabledLabel model labelView icon
@ -200,24 +186,10 @@ viewSquareCheckbox model labelView =
]
viewLockedCheckbox :
{ a
| identifier : String
, label : String
, setterMsg : Bool -> msg
, selected : IsSelected
, disabled : Bool
}
-> (String -> Html.Html msg)
-> Html.Html msg
viewLockedCheckbox : Model msg -> (String -> Html.Html msg) -> Html.Html msg
viewLockedCheckbox model labelView =
checkboxContainer model
[ Html.checkbox model.identifier
(selectedToMaybe model.selected)
[ Events.onCheck (\_ -> onCheck model)
, Attributes.id model.identifier
, Attributes.disabled model.disabled
]
[ viewCheckbox model
, if model.disabled then
viewDisabledLabel model labelView checkboxLockOnInside
@ -239,6 +211,23 @@ checkboxContainer model =
]
viewCheckbox :
{ a
| identifier : String
, setterMsg : Bool -> msg
, selected : IsSelected
, disabled : Bool
}
-> Html.Html msg
viewCheckbox model =
Html.checkbox model.identifier
(selectedToMaybe model.selected)
[ Events.onCheck (\_ -> onCheck model)
, Attributes.id model.identifier
, Attributes.disabled model.disabled
]
viewEnabledLabel :
{ a
| identifier : String