Created
January 19, 2020 10:01
-
-
Save maxfarseer/b753d33d2e8edb406fca78c702c1cfbb to your computer and use it in GitHub Desktop.
Narrowing-types_scaling_elm_apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- наш чекбокс (стандартный input type="checkbox") | |
checkbox : (Bool -> msg) -> Bool -> Html msg | |
checkbox toMsg isChecked = | |
input | |
[ type_ "checkbox" | |
, checked isChecked | |
, onCheck toMsg | |
] | |
[] | |
-- чекбокс из bootstrap (div под капотом), такое же API: (Bool -> msg) -> Bool -> Html msg | |
checkbox : (Bool -> msg) -> Bool -> Html msg | |
checkbox toMsg isChecked = | |
div | |
[ classList [ ( "chk", isChecked ) ] | |
, onClick (toMsg (not isChecked)) | |
] | |
[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment