@@ -8,6 +8,8 @@ Elm.Native.Graphics.Input.make = function(elm) {
88 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
99 var newNode = ElmRuntime.use(ElmRuntime.Render.Utils).newElement;
1010
11+ var toCss = Elm.Native.Color.make(elm).toCss;
12+ var Text = Elm.Native.Text.make(elm);
1113 var Signal = Elm.Signal.make(elm);
1214 var newElement = Elm.Graphics.Element.make(elm).newElement;
1315 var JS = Elm.Native.JavaScript.make(elm);
@@ -215,11 +217,52 @@ Elm.Native.Graphics.Input.make = function(elm) {
215217 }
216218 }
217219
220+ function updateIfNeeded(css, attribute, latestAttribute) {
221+ if (css[attribute] !== latestAttribute) {
222+ css[attribute] = latestAttribute;
223+ }
224+ }
225+ function cssDimensions(dimensions) {
226+ return dimensions.top + 'px ' +
227+ dimensions.right + 'px ' +
228+ dimensions.bottom + 'px ' +
229+ dimensions.left + 'px';
230+ }
231+ function updateFieldStyle(css, style) {
232+ updateIfNeeded(css, 'padding', cssDimensions(style.padding));
233+
234+ var outline = style.outline;
235+ updateIfNeeded(css, 'border-width', cssDimensions(outline.width));
236+ updateIfNeeded(css, 'border-color', toCss(outline.color));
237+ updateIfNeeded(css, 'border-radius', outline.radius + 'px');
238+
239+ var highlight = style.highlight;
240+ if (highlight.width === 0) {
241+ css.outline = 'none';
242+ } else {
243+ updateIfNeeded(css, 'outline-width', highlight.width + 'px');
244+ updateIfNeeded(css, 'outline-color', toCss(highlight.color));
245+ }
246+
247+ var textStyle = style.style;
248+ updateIfNeeded(css, 'color', toCss(textStyle.color));
249+ if (textStyle.typeface.ctor !== '[]') {
250+ updateIfNeeded(css, 'font-family', Text.toTypefaces(textStyle.typeface));
251+ }
252+ if (textStyle.height.ctor !== "Nothing") {
253+ updateIfNeeded(css, 'font-size', textStyle.height._0 + 'px');
254+ }
255+ updateIfNeeded(css, 'font-weight', textStyle.bold ? 'bold' : 'normal');
256+ updateIfNeeded(css, 'font-style', textStyle.italic ? 'italic' : 'normal');
257+ if (textStyle.line.ctor !== 'Nothing') {
258+ updateIfNeeded(css, 'text-decoration', Text.toLine(textStyle.line._0));
259+ }
260+ }
261+
218262 function renderField(model) {
219263 var field = newNode('input');
220− field.style.border = 'none';
221− field.style.outline = 'none';
222− field.style.backgroundColor = 'transparent';
264+ updateFieldStyle(field.style, model.style);
265+ field.style.borderStyle = 'solid';
223266 field.style.pointerEvents = 'auto';
224267
225268 field.type = model.type;
@@ -302,6 +345,9 @@ Elm.Native.Graphics.Input.make = function(elm) {
302345 }
303346
304347 function updateField(field, oldModel, newModel) {
348+ if (oldModel.style !== newModel.style) {
349+ updateFieldStyle(field.style, newModel.style);
350+ }
305351 field.elm_signal = newModel.signal;
306352 field.elm_handler = newModel.handler;
307353
@@ -316,10 +362,16 @@ Elm.Native.Graphics.Input.make = function(elm) {
316362 }
317363
318364 function mkField(type) {
319− function field(signal, handler, placeHolder, content) {
365+ function field(signal, handler, style, placeHolder, content) {
366+ var padding = style.padding;
367+ var outline = style.outline.width;
368+ var adjustWidth = padding.left + padding.right + outline.left + outline.right;
369+ var adjustHeight = padding.top + padding.bottom + outline.top + outline.bottom;
320370 return A3(newElement, 200, 30, {
321371 ctor: 'Custom',
322− type: type + 'Input',
372+ type: type + 'Field',
373+ adjustWidth: adjustWidth,
374+ adjustHeight: adjustHeight,
323375 render: renderField,
324376 update: updateField,
325377 model: {
@@ -327,14 +379,14 @@ Elm.Native.Graphics.Input.make = function(elm) {
327379 handler:handler,
328380 placeHolder:placeHolder,
329381 content:content,
382+ style:style,
330383 type:type
331384 }
332385 });
333386 }
334− return F4(field);
387+ return F5(field);
335388 }
336389
337−
338390 function hoverable(signal, handler, elem) {
339391 function onHover(bool) {
340392 elm.notify(signal.id, handler(bool));