git.iko.soy/typeable/elm-ui
on master help sign in
Multiline fixes - add nbsp at the end of filler element to prevent newline being chomped. Wrap filler text for textarea so that it can be styled without affecting inheritance of font color
commit75974ccfef181671fb8af5fef63582b85fa21992 authorMatthew Griffith <mdg.griffith@gmail.com> dateSat 27 Jul 2019, 09:36 (7 years ago) parentb9f5df9
3 files changed+17−28
src/Element/Input.elm+8−2 src/Internal/Model.elm+7−25 src/Internal/Style.elm+2−1
src/Element/Input.elm+8−2
@@ -1002,7 +1002,13 @@ textHelper textInput attrs textOptions =
10021002 ]
10031003
10041004 else
1005− [ Internal.unstyled (Html.text textOptions.text) ]
1005+ [ Internal.unstyled
1006+ (Html.span [ Html.Attributes.class classes.inputMultilineFiller ]
1007+ -- We append a non-breaking space to the end of the content so that newlines don't get chomped.
1008+ [ Html.text (textOptions.text ++ "\u{00A0}")
1009+ ]
1010+ )
1011+ ]
10061012 )
10071013 )
10081014 ]
@@ -1323,7 +1329,7 @@ redistributeOver isMultiline stacked attr els =
13231329 Internal.StyleClass _ (Internal.FontFamily _ _) ->
13241330 { els | fullParent = attr :: els.fullParent }
13251331
1326− Internal.StyleClass _ _ ->
1332+ Internal.StyleClass flag cls ->
13271333 { els | parent = attr :: els.parent }
13281334
13291335 Internal.NoAttribute ->
src/Internal/Model.elm+7−25
@@ -2166,8 +2166,8 @@ rootStyle =
21662166 , SansSerif
21672167 ]
21682168 in
2169− [ StyleClass Flag.bgColor (Colored ("bg-color-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2170− , StyleClass Flag.fontColor (Colored ("font-color-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
2169+ [ StyleClass Flag.bgColor (Colored ("bg-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2170+ , StyleClass Flag.fontColor (Colored ("fc-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
21712171 , StyleClass Flag.fontSize (FontSize 20)
21722172 , StyleClass Flag.fontFamily <|
21732173 FontFamily (List.foldl renderFontClassName "font-" families)
@@ -2727,29 +2727,11 @@ renderStyleRule options rule maybePseudo =
27272727 ]
27282728
27292729 Colored class prop color ->
2730− -- This is because the trick we're using to make a txtarea be height:content
2731− -- stops the inheritance chain for font color.
2732− -- So we need to pack our bags, hike up our socks and jump over the break.
2733− if prop == "color" then
2734− List.concat
2735− [ renderStyle options
2736− maybePseudo
2737− ("." ++ class)
2738− [ Property prop (formatColor color)
2739− ]
2740− , renderStyle options
2741− maybePseudo
2742− ("." ++ class ++ " ." ++ classes.inputMultilineParent ++ " ." ++ classes.inputMultiline)
2743− [ Property prop (formatColor color)
2744− ]
2745− ]
2746−
2747− else
2748− renderStyle options
2749− maybePseudo
2750− ("." ++ class)
2751− [ Property prop (formatColor color)
2752− ]
2730+ renderStyle options
2731+ maybePseudo
2732+ ("." ++ class)
2733+ [ Property prop (formatColor color)
2734+ ]
27532735
27542736 SpacingStyle cls x y ->
27552737 let
src/Internal/Style.elm+2−1
@@ -254,6 +254,7 @@ classes =
254254 , inputText = "it"
255255 , inputMultiline = "iml"
256256 , inputMultilineParent = "imlp"
257+ , inputMultilineFiller = "imlf"
257258
258259 -- link
259260 , link = "lnk"
@@ -1564,7 +1565,7 @@ baseSheet =
15641565 , Descriptor (dot classes.inputMultilineParent)
15651566 [ Prop "white-space" "pre-wrap"
15661567 , Prop "cursor" "text"
1567− , Descriptor (dot classes.paragraph)
1568+ , Child (dot classes.inputMultilineFiller)
15681569 [ Prop "white-space" "pre-wrap"
15691570 , Prop "color" "transparent"
15701571 ]