git.iko.soy/typeable/elm-ui
on master help sign in
Give border a unique constructor
d4175a3Matthew Griffith
src/Element/Border.elm+90−21
@@ -41,38 +41,81 @@ import Internal.Style as Style exposing (classes)
41{-| -}
41{-| -}
42color : Color -> Attr decorative msg
42color : Color -> Attr decorative msg
43color clr =
43color clr =
44+ Internal.StyleClass
45+ Flag.borderColor
46+ (Internal.Colored
44− Internal.StyleClass Flag.borderColor (Internal.Colored ("border-color-" ++ Internal.formatColorClass clr) "border-color" clr)
47+ ("bc-" ++ Internal.formatColorClass clr)
48+ "border-color"
49+ clr
50+ )
45
51
46
52
47{-| -}
53{-| -}
48width : Int -> Attribute msg
54width : Int -> Attribute msg
49width v =
55width v =
50− Internal.StyleClass Flag.borderWidth (Internal.Single ("border-" ++ String.fromInt v) "border-width" (String.fromInt v ++ "px"))
56+ Internal.StyleClass
57+ Flag.borderWidth
58+ (Internal.BorderWidth
59+ ("b-" ++ String.fromInt v)
60+ v
61+ v
62+ v
63+ v
64+ )
51
65
52
66
53{-| Set horizontal and vertical borders.
67{-| Set horizontal and vertical borders.
54-}
68-}
55widthXY : Int -> Int -> Attribute msg
69widthXY : Int -> Int -> Attribute msg
56widthXY x y =
70widthXY x y =
57− Internal.StyleClass Flag.borderWidth (Internal.Single ("border-" ++ String.fromInt x ++ "-" ++ String.fromInt y) "border-width" (String.fromInt y ++ "px " ++ String.fromInt x ++ "px"))
71+ Internal.StyleClass
72+ Flag.borderWidth
73+ (Internal.BorderWidth
74+ ("b-"
75+ ++ String.fromInt x
76+ ++ "-"
77+ ++ String.fromInt y
78+ )
79+ y
80+ x
81+ y
82+ x
83+ )
58
84
59
85
60{-| -}
86{-| -}
61−widthEach : { bottom : Int, left : Int, right : Int, top : Int } -> Attribute msg
87+widthEach :
88+ { bottom : Int
89+ , left : Int
90+ , right : Int
91+ , top : Int
92+ }
93+ -> Attribute msg
62widthEach { bottom, top, left, right } =
94widthEach { bottom, top, left, right } =
95+ if top == bottom && left == right then
96+ if top == right then
97+ width top
98+
99+ else
100+ widthXY left top
101+
102+ else
63− Internal.StyleClass Flag.borderWidth
103+ Internal.StyleClass Flag.borderWidth
64− (Internal.Single ("border-" ++ String.fromInt top ++ "-" ++ String.fromInt right ++ String.fromInt bottom ++ "-" ++ String.fromInt left)
104+ (Internal.BorderWidth
65− "border-width"
105+ ("b-"
66− (String.fromInt top
106+ ++ String.fromInt top
67− ++ "px "
107+ ++ "-"
108+ ++ String.fromInt right
109+ ++ "-"
110+ ++ String.fromInt bottom
111+ ++ "-"
112+ ++ String.fromInt left
113+ )
114+ top
68− ++ String.fromInt right
115+ right
69− ++ "px "
70− ++ String.fromInt bottom
116+ bottom
71− ++ "px "
117+ left
72− ++ String.fromInt left
73− ++ "px"
74 )
118 )
75− )
76
119
77
120
78
121
@@ -105,14 +148,34 @@ dotted =
105-}
148-}
106rounded : Int -> Attribute msg
149rounded : Int -> Attribute msg
107rounded radius =
150rounded radius =
108− Internal.StyleClass Flag.borderRound (Internal.Single ("border-radius-" ++ String.fromInt radius) "border-radius" (String.fromInt radius ++ "px"))
151+ Internal.StyleClass
152+ Flag.borderRound
153+ (Internal.Single
154+ ("br-" ++ String.fromInt radius)
155+ "border-radius"
156+ (String.fromInt radius ++ "px")
157+ )
109
158
110
159
111{-| -}
160{-| -}
112−roundEach : { topLeft : Int, topRight : Int, bottomLeft : Int, bottomRight : Int } -> Attribute msg
161+roundEach :
162+ { topLeft : Int
163+ , topRight : Int
164+ , bottomLeft : Int
165+ , bottomRight : Int
166+ }
167+ -> Attribute msg
113roundEach { topLeft, topRight, bottomLeft, bottomRight } =
168roundEach { topLeft, topRight, bottomLeft, bottomRight } =
114 Internal.StyleClass Flag.borderRound
169 Internal.StyleClass Flag.borderRound
115− (Internal.Single ("border-radius-" ++ String.fromInt topLeft ++ "-" ++ String.fromInt topRight ++ String.fromInt bottomLeft ++ "-" ++ String.fromInt bottomRight)
170+ (Internal.Single
171+ ("br-"
172+ ++ String.fromInt topLeft
173+ ++ "-"
174+ ++ String.fromInt topRight
175+ ++ String.fromInt bottomLeft
176+ ++ "-"
177+ ++ String.fromInt bottomRight
178+ )
116 "border-radius"
179 "border-radius"
117 (String.fromInt topLeft
180 (String.fromInt topLeft
118 ++ "px "
181 ++ "px "
@@ -168,7 +231,10 @@ shadow almostShade =
168 }
231 }
169 in
232 in
170 Internal.StyleClass Flag.shadows <|
233 Internal.StyleClass Flag.shadows <|
234+ Internal.Single
235+ (Internal.boxShadowName shade)
236+ "box-shadow"
171− Internal.Single (Internal.boxShadowName shade) "box-shadow" (Internal.formatBoxShadow shade)
237+ (Internal.formatBoxShadow shade)
172
238
173
239
174{-| -}
240{-| -}
@@ -190,7 +256,10 @@ innerShadow almostShade =
190 }
256 }
191 in
257 in
192 Internal.StyleClass Flag.shadows <|
258 Internal.StyleClass Flag.shadows <|
259+ Internal.Single
260+ (Internal.boxShadowName shade)
261+ "box-shadow"
193− Internal.Single (Internal.boxShadowName shade) "box-shadow" (Internal.formatBoxShadow shade)
262+ (Internal.formatBoxShadow shade)
194
263
195
264
196
265
src/Internal/Model.elm+26
@@ -181,6 +181,7 @@ type Style
181 | Single String String String
181 | Single String String String
182 | Colored String String Color
182 | Colored String String Color
183 | SpacingStyle String Int Int
183 | SpacingStyle String Int Int
184+ | BorderWidth String Int Int Int Int
184 | PaddingStyle String Int Int Int Int
185 | PaddingStyle String Int Int Int Int
185 | GridTemplateStyle
186 | GridTemplateStyle
186 { spacing : ( Length, Length )
187 { spacing : ( Length, Length )
@@ -329,6 +330,7 @@ unstyled =
329 Unstyled << always
330 Unstyled << always
330
331
331
332
333+
332finalizeNode has node attributes children embedMode parentContext =
334finalizeNode has node attributes children embedMode parentContext =
333 let
335 let
334 createNode nodeName attrs =
336 createNode nodeName attrs =
@@ -2446,6 +2448,27 @@ toStyleSheetString options stylesheet =
2446 )
2448 )
2447 ]
2449 ]
2448
2450
2451+ BorderWidth cls top right bottom left ->
2452+ let
2453+ class =
2454+ "."
2455+ ++ cls
2456+ in
2457+ renderStyle
2458+ maybePseudo
2459+ class
2460+ [ Property "border-width"
2461+ (String.fromInt top
2462+ ++ "px "
2463+ ++ String.fromInt right
2464+ ++ "px "
2465+ ++ String.fromInt bottom
2466+ ++ "px "
2467+ ++ String.fromInt left
2468+ ++ "px"
2469+ )
2470+ ]
2471+
2449 GridTemplateStyle template ->
2472 GridTemplateStyle template ->
2450 let
2473 let
2451 class =
2474 class =
@@ -2793,6 +2816,9 @@ getStyleName style =
2793 PaddingStyle cls top right bottom left ->
2816 PaddingStyle cls top right bottom left ->
2794 cls
2817 cls
2795
2818
2819+ BorderWidth cls top right bottom left ->
2820+ cls
2821+
2796 GridTemplateStyle template ->
2822 GridTemplateStyle template ->
2797 "grid-rows-"
2823 "grid-rows-"
2798 ++ String.join "-" (List.map lengthClassName template.rows)
2824 ++ String.join "-" (List.map lengthClassName template.rows)