@@ -8,6 +8,8 @@ Elm.Native.Graphics.Input.make = function(elm) {
8 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
8 var Render = ElmRuntime.use(ElmRuntime.Render.Element);
9 var newNode = ElmRuntime.use(ElmRuntime.Render.Utils).newElement;
9 var newNode = ElmRuntime.use(ElmRuntime.Render.Utils).newElement;
11+ var toCss = Elm.Native.Color.make(elm).toCss;
12+ var Text = Elm.Native.Text.make(elm);
11 var Signal = Elm.Signal.make(elm);
13 var Signal = Elm.Signal.make(elm);
12 var newElement = Elm.Graphics.Element.make(elm).newElement;
14 var newElement = Elm.Graphics.Element.make(elm).newElement;
13 var JS = Elm.Native.JavaScript.make(elm);
15 var JS = Elm.Native.JavaScript.make(elm);
@@ -215,11 +217,52 @@ Elm.Native.Graphics.Input.make = function(elm) {
220+ function updateIfNeeded(css, attribute, latestAttribute) {
221+ if (css[attribute] !== latestAttribute) {
222+ css[attribute] = latestAttribute;
225+ function cssDimensions(dimensions) {
226+ return dimensions.top + 'px ' +
227+ dimensions.right + 'px ' +
228+ dimensions.bottom + 'px ' +
229+ dimensions.left + 'px';
231+ function updateFieldStyle(css, style) {
232+ updateIfNeeded(css, 'padding', cssDimensions(style.padding));
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');
239+ var highlight = style.highlight;
240+ if (highlight.width === 0) {
241+ css.outline = 'none';
243+ updateIfNeeded(css, 'outline-width', highlight.width + 'px');
244+ updateIfNeeded(css, 'outline-color', toCss(highlight.color));
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));
252+ if (textStyle.height.ctor !== "Nothing") {
253+ updateIfNeeded(css, 'font-size', textStyle.height._0 + 'px');
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));
218 function renderField(model) {
262 function renderField(model) {
219 var field = newNode('input');
263 var field = newNode('input');
220− field.style.border = 'none';
264+ updateFieldStyle(field.style, model.style);
221− field.style.outline = 'none';
265+ field.style.borderStyle = 'solid';
222− field.style.backgroundColor = 'transparent';
223 field.style.pointerEvents = 'auto';
266 field.style.pointerEvents = 'auto';
225 field.type = model.type;
268 field.type = model.type;
@@ -302,6 +345,9 @@ Elm.Native.Graphics.Input.make = function(elm) {
304 function updateField(field, oldModel, newModel) {
347 function updateField(field, oldModel, newModel) {
348+ if (oldModel.style !== newModel.style) {
349+ updateFieldStyle(field.style, newModel.style);
305 field.elm_signal = newModel.signal;
351 field.elm_signal = newModel.signal;
306 field.elm_handler = newModel.handler;
352 field.elm_handler = newModel.handler;
@@ -316,10 +362,16 @@ Elm.Native.Graphics.Input.make = function(elm) {
318 function mkField(type) {
364 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;
320 return A3(newElement, 200, 30, {
370 return A3(newElement, 200, 30, {
321 ctor: 'Custom',
371 ctor: 'Custom',
322− type: type + 'Input',
372+ type: type + 'Field',
373+ adjustWidth: adjustWidth,
374+ adjustHeight: adjustHeight,
323 render: renderField,
375 render: renderField,
324 update: updateField,
376 update: updateField,
@@ -327,14 +379,14 @@ Elm.Native.Graphics.Input.make = function(elm) {
327 handler:handler,
379 handler:handler,
328 placeHolder:placeHolder,
380 placeHolder:placeHolder,
329 content:content,
381 content:content,
330 type:type
383 type:type
334− return F4(field);
387+ return F5(field);
338 function hoverable(signal, handler, elem) {
390 function hoverable(signal, handler, elem) {
339 function onHover(bool) {
391 function onHover(bool) {
340 elm.notify(signal.id, handler(bool));
392 elm.notify(signal.id, handler(bool));