on master help sign in
Stop using JavaScript module
549c2aaEvan Czaplicki
libraries/Graphics/Element.elm+10−13
@@ -39,8 +39,6 @@ If you need more precision, you can create custom positions.
39
39
40import Basics (..)
40import Basics (..)
41import Native.Utils
41import Native.Utils
42−import JavaScript as JS
43−import JavaScript (JSString)
44import List as List
42import List as List
45import Color (..)
43import Color (..)
46import Maybe (Maybe, Just, Nothing)
44import Maybe (Maybe, Just, Nothing)
@@ -51,8 +49,8 @@ type Properties = {
51 height : Int,
49 height : Int,
52 opacity : Float,
50 opacity : Float,
53 color : Maybe Color,
51 color : Maybe Color,
54− href : JSString,
52+ href : String,
55− tag : JSString,
53+ tag : String,
56 hover : (),
54 hover : (),
57 click : ()
55 click : ()
58 }
56 }
@@ -120,21 +118,20 @@ with a link like this: `/facts-about-animals.elm#all-about-badgers`
120-}
118-}
121tag : String -> Element -> Element
119tag : String -> Element -> Element
122tag name e = let p = e.props in
120tag name e = let p = e.props in
123− { element=e.element, props={p | tag <- JS.fromString name} }
121+ { element=e.element, props={p | tag <- name} }
124
122
125{-| Create an `Element` that is a hyper-link. -}
123{-| Create an `Element` that is a hyper-link. -}
126link : String -> Element -> Element
124link : String -> Element -> Element
127link href e = let p = e.props in
125link href e = let p = e.props in
128− { element=e.element, props={p | href <- JS.fromString href} }
126+ { element=e.element, props={p | href <- href} }
129
127
130−emptyStr = JS.fromString ""
131newElement w h e =
128newElement w h e =
132− { props = Properties (Native.Utils.guid ()) w h 1 Nothing emptyStr emptyStr () ()
129+ { props = Properties (Native.Utils.guid ()) w h 1 Nothing "" "" () ()
133 , element = e
130 , element = e
134 }
131 }
135
132
136data ElementPrim
133data ElementPrim
137− = Image ImageStyle Int Int JSString
134+ = Image ImageStyle Int Int String
138 | Container Position Element
135 | Container Position Element
139 | Flow Direction [Element]
136 | Flow Direction [Element]
140 | Spacer
137 | Spacer
@@ -145,13 +142,13 @@ data ImageStyle = Plain | Fitted | Cropped (Int,Int) | Tiled
145
142
146{-| Create an image given a width, height, and image source. -}
143{-| Create an image given a width, height, and image source. -}
147image : Int -> Int -> String -> Element
144image : Int -> Int -> String -> Element
148−image w h src = newElement w h (Image Plain w h (JS.fromString src))
145+image w h src = newElement w h (Image Plain w h src)
149
146
150{-| Create a fitted image given a width, height, and image source.
147{-| Create a fitted image given a width, height, and image source.
151This will crop the picture to best fill the given dimensions.
148This will crop the picture to best fill the given dimensions.
152-}
149-}
153fittedImage : Int -> Int -> String -> Element
150fittedImage : Int -> Int -> String -> Element
154−fittedImage w h src = newElement w h (Image Fitted w h (JS.fromString src))
151+fittedImage w h src = newElement w h (Image Fitted w h src)
155
152
156{-| Create a cropped image. Take a rectangle out of the picture starting
153{-| Create a cropped image. Take a rectangle out of the picture starting
157at the given top left coordinate. If you have a 140-by-140 image,
154at the given top left coordinate. If you have a 140-by-140 image,
@@ -161,11 +158,11 @@ the following will cut a 100-by-100 square out of the middle of it.
161-}
158-}
162croppedImage : (Int,Int) -> Int -> Int -> String -> Element
159croppedImage : (Int,Int) -> Int -> Int -> String -> Element
163croppedImage pos w h src =
160croppedImage pos w h src =
164− newElement w h (Image (Cropped pos) w h (JS.fromString src))
161+ newElement w h (Image (Cropped pos) w h src)
165
162
166tiledImage : Int -> Int -> String -> Element
163tiledImage : Int -> Int -> String -> Element
167tiledImage w h src =
164tiledImage w h src =
168− newElement w h (Image Tiled w h (JS.fromString src))
165+ newElement w h (Image Tiled w h src)
169
166
170data Three = P | Z | N
167data Three = P | Z | N
171data Pos = Absolute Int | Relative Float
168data Pos = Absolute Int | Relative Float