git.iko.soy/typeable/elm-ui
on master help sign in
add wrapper to attribute redistribution for text inputs
commit0d1005b3b030b7f0c036a064299b9870e422001a authorMatthew Griffith <mdg.griffith@gmail.com> dateThu 20 Jun 2019, 08:32 (7 years ago) parent41bbf88
1 file changed+35−29
src/Element/Input.elm+35−29
src/Element/Input.elm+35−29
@@ -690,17 +690,24 @@ textHelper textInput attrs textOptions =
690690 _ ->
691691 False
692692
693+ isHeightContent attr =
694+ case attr of
695+ Internal.Height Internal.Content ->
696+ True
697+
698+ _ ->
699+ False
700+
693701 bottomPadding attr =
694702 case attr of
695703 Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
696− Just
697− (Element.paddingEach
704+ Just <|
705+ Element.paddingEach
698706 { top = 0
699707 , right = 0
700708 , bottom = b
701709 , left = 0
702710 }
703− )
704711
705712 _ ->
706713 Nothing
@@ -711,7 +718,7 @@ textHelper textInput attrs textOptions =
711718 False
712719
713720 TextArea ->
714− Maybe.withDefault False redistributed.heightContent
721+ List.any isHeightContent withDefaults
715722
716723 inputElement =
717724 Internal.element
@@ -775,11 +782,10 @@ textHelper textInput attrs textOptions =
775782 :: Internal.htmlClass classes.inputMultiline
776783 :: List.concat
777784 [ if heightContent then
778− List.filter onlySpacing redistributed.parent
779− -- redistributed.parent
785+ redistributed.wrapper
780786
781787 else
782− List.filter onlySpacing redistributed.parent
788+ redistributed.wrapper
783789 ++ List.filterMap bottomPadding redistributed.parent
784790 , case textOptions.placeholder of
785791 Nothing ->
@@ -887,7 +893,8 @@ calcMoveToCompensateForPadding attrs =
887893redistribute them to the parent, the input, or the cover.
888894
889895 - fullParent -> Wrapper around label and input
890− - parent -> wrapper around input
896+ - parent -> parent of wrapper
897+ - wrapper -> the element that is here to take up space.
891898 - cover -> things like placeholders or text areas which are layered on top of input.
892899 - input -> actual input element
893900
@@ -895,20 +902,27 @@ redistribute them to the parent, the input, or the cover.
895902redistribute :
896903 List (Attribute msg)
897904 ->
898− { parent : List (Attribute msg)
899− , fullParent : List (Attribute msg)
905+ { fullParent : List (Attribute msg)
906+ , parent : List (Attribute msg)
907+ , wrapper : List (Attribute msg)
900908 , input : List (Attribute msg)
901909 , cover : List (Attribute msg)
902− , heightContent : Maybe Bool
903910 }
904911redistribute attrs =
905− List.foldl redistributeOver { fullParent = [], parent = [], input = [], cover = [], heightContent = Nothing } attrs
912+ List.foldl redistributeOver
913+ { fullParent = []
914+ , parent = []
915+ , input = []
916+ , cover = []
917+ , wrapper = []
918+ }
919+ attrs
906920 |> (\redist ->
907921 { parent = List.reverse redist.parent
908922 , fullParent = List.reverse redist.fullParent
923+ , wrapper = List.reverse redist.wrapper
909924 , input = List.reverse redist.input
910925 , cover = List.reverse redist.cover
911− , heightContent = redist.heightContent
912926 }
913927 )
914928
@@ -931,22 +945,9 @@ redistributeOver attr els =
931945 }
932946
933947 Internal.Height h ->
934− case h of
935− Internal.Content ->
936− { els
937− | parent = attr :: els.parent
938− , heightContent =
939− els.heightContent
940− |> orElse True
941− }
942−
943− _ ->
944− { els
945− | parent = attr :: els.parent
946− , heightContent =
947− els.heightContent
948− |> orElse False
949− }
948+ { els
949+ | parent = attr :: els.parent
950+ }
950951
951952 Internal.AlignX _ ->
952953 { els | fullParent = attr :: els.fullParent }
@@ -959,11 +960,16 @@ redistributeOver attr els =
959960 | fullParent = attr :: els.fullParent
960961 , parent = attr :: els.parent
961962 , input = attr :: els.input
963+ , wrapper = attr :: els.wrapper
962964 }
963965
964966 Internal.StyleClass _ (Internal.PaddingStyle _ _ _ _ _) ->
965967 { els
966968 | parent = attr :: els.parent
969+
970+ -- input = attr :: els.input
971+ -- , wrapper = attr :: els.wrapper
972+ , cover = attr :: els.cover
967973 }
968974
969975 Internal.StyleClass _ (Internal.BorderWidth _ _ _ _ _) ->