on master help sign in
Add empty element
6992d94Max New
libraries/Graphics/Element.elm+7−3
@@ -13,7 +13,7 @@ combine and position.
13@docs widthOf, heightOf, sizeOf
13@docs widthOf, heightOf, sizeOf
14
14
15# Layout
15# Layout
16−@docs flow, up, down, left, right, inward, outward
16+@docs flow, up, down, left, right, inward, outward, empty
17
17
18## Layout Aliases
18## Layout Aliases
19There are also some convenience functions for working
19There are also some convenience functions for working
@@ -58,6 +58,10 @@ type Properties = {
58
58
59type Element = { props : Properties, element : ElementPrim }
59type Element = { props : Properties, element : ElementPrim }
60
60
61+{-| An Element that takes up no space -}
62+empty : Element
63+empty = spacer 0 0
64+
61{-| Get the width of an Element -}
65{-| Get the width of an Element -}
62widthOf : Element -> Int
66widthOf : Element -> Int
63widthOf e = e.props.width
67widthOf e = e.props.width
@@ -195,7 +199,7 @@ flow dir es =
195 hs = List.map heightOf es
199 hs = List.map heightOf es
196 newFlow w h = newElement w h (Flow dir es)
200 newFlow w h = newElement w h (Flow dir es)
197 in
201 in
198− if es == [] then spacer 0 0 else
202+ if es == [] then empty else
199 case dir of
203 case dir of
200 DUp -> newFlow (List.maximum ws) (List.sum hs)
204 DUp -> newFlow (List.maximum ws) (List.sum hs)
201 DDown -> newFlow (List.maximum ws) (List.sum hs)
205 DDown -> newFlow (List.maximum ws) (List.sum hs)
@@ -302,4 +306,4 @@ inward : Direction
302inward = DIn
306inward = DIn
303
307
304outward : Direction
308outward : Direction
305−outward = DOut
309+outward = DOut