diff options
author | Joris | 2016-06-12 23:54:17 +0200 |
---|---|---|
committer | Joris | 2016-06-12 23:54:17 +0200 |
commit | 6a0c5087f716ed6c876a666db6573491bfd3e094 (patch) | |
tree | bf439109143c7a1749c2661fc8b805b83a993027 /src/client/elm/View | |
parent | 38896af4281d2e191cbde15836a23e4c0274fff6 (diff) |
Design income form
Diffstat (limited to 'src/client/elm/View')
-rw-r--r-- | src/client/elm/View/Color.elm | 8 | ||||
-rw-r--r-- | src/client/elm/View/Form.elm | 53 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/client/elm/View/Color.elm b/src/client/elm/View/Color.elm new file mode 100644 index 0000000..882dd69 --- /dev/null +++ b/src/client/elm/View/Color.elm @@ -0,0 +1,8 @@ +module View.Color exposing + ( chestnutRose + ) + +import Color exposing (Color) + +chestnutRose : Color +chestnutRose = Color.rgb 207 92 86 diff --git a/src/client/elm/View/Form.elm b/src/client/elm/View/Form.elm new file mode 100644 index 0000000..fd21a2c --- /dev/null +++ b/src/client/elm/View/Form.elm @@ -0,0 +1,53 @@ +module View.Form exposing + ( textInput + ) + +import Html exposing (..) +import Html.Attributes exposing (..) + +import Form exposing (Form) +import Form.Input as Input +import Form.Error as FormError exposing (Error(..)) + +import Msg exposing (Msg) + +import LoggedData exposing (LoggedData) + +import Model.Translations as Translations exposing (Translations) + +import Utils.Maybe exposing (isJust) + +textInput : Translations -> Form String a -> (Html Form.Msg -> Html msg) -> String -> Html msg +textInput translations form htmlMap fieldName = + let field = Form.getFieldAsString fieldName form + in div + [ classList + [ ("textInput", True) + , ("error", isJust field.liveError) + ] + ] + [ htmlMap <| + Input.textInput + field + [ id fieldName + , classList [ ("filled", isJust field.value) ] + ] + , label + [ for fieldName ] + [ text (Translations.getMessage fieldName translations) ] + , case field.liveError of + Just error -> errorElement translations error + Nothing -> text "" + ] + +errorElement : Translations -> FormError.Error String -> Html msg +errorElement translations error = + case error of + CustomError key -> + div [ class "errorMessage" ] [ text (Translations.getMessage key translations) ] + SmallerIntThan n -> + div [ class "errorMessage" ] [ text (Translations.getParamMessage [toString n] "SmallerIntThan" translations) ] + GreaterIntThan n -> + div [ class "errorMessage" ] [ text (Translations.getParamMessage [toString n] "GreaterIntThan" translations) ] + error -> + div [ class "errorMessage" ] [ text (Translations.getMessage (toString error) translations) ] |