on master help sign in
Move Field.Style to be the first argument to field, password, and email.
4fcc11aEvan Czaplicki
libraries/Graphics/Input/Field.elm+14−4
@@ -140,20 +140,30 @@ to match what they have entered.
140 name = input noContent
140 name = input noContent
141
141
142 nameField : Signal Element
142 nameField : Signal Element
143− nameField = field name.handle id defaultStyle "Name" <~ name.signal
143+ nameField = field defaultStyle name.handle id "Name" <~ name.signal
144+
145+When we use the `field` function, we first give it a visual style. This is
146+the first argument so that it is easier to define your own custom field
147+(`myField = field myStyle`). The next two arguments are a `Handle` and a
148+handler function that processes or augments events before sending them along
149+to the associated `Input`. In the example above we use the `id` function to
150+pass events along unchanged to the `name` `Input`. We then provide the
151+place-holder message to use when no input has been provided yet. Finally,
152+we give the current `Content` of the field. This argument is last because
153+it is most likely to change frequently, making function composition easier.
144-}
154-}
145−field : Handle a -> (Content -> a) -> Style -> String -> Content -> Element
155+field : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
146field = Native.Graphics.Input.field
156field = Native.Graphics.Input.field
147
157
148{-| Same as `field` but the UI element blocks out each characters. -}
158{-| Same as `field` but the UI element blocks out each characters. -}
149−password : Handle a -> (Content -> a) -> Style -> String -> Content -> Element
159+password : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
150password = Native.Graphics.Input.password
160password = Native.Graphics.Input.password
151
161
152{-| Same as `field` but it adds an annotation that this field is for email
162{-| Same as `field` but it adds an annotation that this field is for email
153addresses. This is helpful for auto-complete and for mobile users who may
163addresses. This is helpful for auto-complete and for mobile users who may
154get a custom keyboard with an `@` and `.com` button.
164get a custom keyboard with an `@` and `.com` button.
155-}
165-}
156−email : Handle a -> (Content -> a) -> Style -> String -> Content -> Element
166+email : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
157email = Native.Graphics.Input.email
167email = Native.Graphics.Input.email
158
168
159-- area : Handle a -> (Content -> a) -> Handle b -> ((Int,Int) -> b) -> (Int,Int) -> String -> Content -> Element
169-- area : Handle a -> (Content -> a) -> Handle b -> ((Int,Int) -> b) -> (Int,Int) -> String -> Content -> Element
libraries/Native/Graphics/Input.js+1−1
@@ -367,7 +367,7 @@ Elm.Native.Graphics.Input.make = function(elm) {
367 }
367 }
368
368
369 function mkField(type) {
369 function mkField(type) {
370− function field(signal, handler, style, placeHolder, content) {
370+ function field(style, signal, handler, placeHolder, content) {
371 var padding = style.padding;
371 var padding = style.padding;
372 var outline = style.outline.width;
372 var outline = style.outline.width;
373 var adjustWidth = padding.left + padding.right + outline.left + outline.right;
373 var adjustWidth = padding.left + padding.right + outline.left + outline.right;