git.iko.soy/typeable/elm-ui
on master help sign in
symmetrical model for wrapped row padding
6f0a718Matthew Griffith
src/Element.elm+37−18
@@ -647,21 +647,14 @@ wrappedRow attrs children =
647 newPadding =
647 newPadding =
648 case padded of
648 case padded of
649 Just (Internal.Padding name t r b l) ->
649 Just (Internal.Padding name t r b l) ->
650− if r >= x && b >= y then
650+ if r >= (x // 2) && b >= (y // 2) then
651 Just <|
651 Just <|
652− Internal.StyleClass
652+ paddingEach
653− Flag.padding
653+ { top = t - (y // 2)
654− (Internal.PaddingStyle
655− (Internal.paddingName t
656− (r - x)
657− (b - y)
658− l
659− )
660− t
661− (r - x)
654+ , right = r - (x // 2)
662− (b - y)
655+ , bottom = b - (y // 2)
663− l
656+ , left = l - (x // 2)
664− )
657+ }
665
658
666 else
659 else
667 Nothing
660 Nothing
@@ -690,6 +683,13 @@ wrappedRow attrs children =
690
683
691 Nothing ->
684 Nothing ->
692 -- Not enough space in padding to compensate for spacing
685 -- Not enough space in padding to compensate for spacing
686+ let
687+ halfX =
688+ negate (toFloat x / 2)
689+
690+ halfY =
691+ negate (toFloat y / 2)
692+ in
693 Internal.element
693 Internal.element
694 Internal.asEl
694 Internal.asEl
695 Internal.div
695 Internal.div
@@ -706,9 +706,28 @@ wrappedRow attrs children =
706 ++ classes.wrapped
706 ++ classes.wrapped
707 )
707 )
708 :: Internal.Attr
708 :: Internal.Attr
709− (Html.Attributes.style "margin-bottom" (String.fromInt (negate y) ++ "px"))
709+ (Html.Attributes.style "margin"
710− :: width fill
710+ (String.fromFloat halfY
711− :: height fill
711+ ++ "px"
712+ ++ " "
713+ ++ String.fromFloat halfX
714+ ++ "px"
715+ )
716+ )
717+ :: Internal.Attr
718+ (Html.Attributes.style "width"
719+ ("calc(100% + "
720+ ++ String.fromInt x
721+ ++ "px)"
722+ )
723+ )
724+ :: Internal.Attr
725+ (Html.Attributes.style "height"
726+ ("calc(100% + "
727+ ++ String.fromInt y
728+ ++ "px)"
729+ )
730+ )
712 :: Internal.StyleClass Flag.spacing (Internal.SpacingStyle spaceName x y)
731 :: Internal.StyleClass Flag.spacing (Internal.SpacingStyle spaceName x y)
713 :: []
732 :: []
714 )
733 )
@@ -730,7 +749,7 @@ type alias Todo =
730 el
749 el
731 [ Element.explain Debug.todo
750 [ Element.explain Debug.todo
732 ]
751 ]
733− (text "Help! I'm being debugged!")
752+ (text "Help, I'm being debugged!")
734
753
735-}
754-}
736explain : Todo -> Attribute msg
755explain : Todo -> Attribute msg
src/Internal/Model.elm+13−8
@@ -2563,6 +2563,12 @@ toStyleSheetString options stylesheet =
2563 class =
2563 class =
2564 "." ++ cls
2564 "." ++ cls
2565
2565
2566+ halfX =
2567+ String.fromFloat (toFloat x / 2) ++ "px"
2568+
2569+ halfY =
2570+ String.fromFloat (toFloat y / 2) ++ "px"
2571+
2566 xPx =
2572 xPx =
2567 String.fromInt x ++ "px"
2573 String.fromInt x ++ "px"
2568
2574
@@ -2597,21 +2603,20 @@ toStyleSheetString options stylesheet =
2597 "." ++ Internal.Style.classes.single
2603 "." ++ Internal.Style.classes.single
2598 in
2604 in
2599 String.concat
2605 String.concat
2600− [ renderStyle maybePseudo (class ++ row ++ " > " ++ any) [ Property "margin-right" xPx ]
2606+ [ renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ " + " ++ any) [ Property "margin-left" xPx ]
2601
2607
2602 -- margins don't apply to last element of normal, unwrapped rows
2608 -- margins don't apply to last element of normal, unwrapped rows
2603− , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":last-child") [ Property "margin" "0" ]
2609+ -- , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":first-child") [ Property "margin" "0" ]
2604−
2605 -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2610 -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2606 , renderStyle maybePseudo
2611 , renderStyle maybePseudo
2607 (class ++ wrappedRow ++ " > " ++ any)
2612 (class ++ wrappedRow ++ " > " ++ any)
2608− [ Property "margin" ("0 " ++ xPx ++ " " ++ yPx ++ " 0")
2613+ [ Property "margin" (halfY ++ " " ++ halfX)
2609− ]
2610− , renderStyle maybePseudo
2611− (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2612− [ Property "margin-right" "0"
2613 ]
2614 ]
2614
2615
2616+ -- , renderStyle maybePseudo
2617+ -- (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2618+ -- [ Property "margin-right" "0"
2619+ -- ]
2615 -- columns
2620 -- columns
2616 , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2621 , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2617 , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2622 , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]