summaryrefslogtreecommitdiff
path: root/elm/Lib/Html.elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-28 10:54:15 +0100
committerYorhel <git@yorhel.nl>2019-11-10 12:44:55 +0100
commitdc243fb2d89c69611e3c2a154749c14643a69db0 (patch)
treeea63ed1fcb0fa1403781ca60f5344e17d965a671 /elm/Lib/Html.elm
parent279c4c9f82b45863f91a16867e4830695de7e0ce (diff)
ulist: Inline editable votes
Diffstat (limited to 'elm/Lib/Html.elm')
-rw-r--r--elm/Lib/Html.elm7
1 files changed, 7 insertions, 0 deletions
diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm
index edf0a0c5..d9c0594a 100644
--- a/elm/Lib/Html.elm
+++ b/elm/Lib/Html.elm
@@ -12,6 +12,13 @@ import Lib.Api as Api
onClickN : m -> Attribute m
onClickN action = custom "click" (JD.succeed { message = action, stopPropagation = True, preventDefault = True})
+-- onInput that also tells us whether the input is valid
+onInputValidation : (String -> Bool -> msg) -> Attribute msg
+onInputValidation msg = custom "input" <|
+ JD.map2 (\value valid -> { preventDefault = False, stopPropagation = True, message = msg value valid })
+ targetValue
+ (JD.at ["target", "validity", "valid"] JD.bool)
+
-- Multi-<br> (ugly but oh, so, convenient)
br_ : Int -> Html m