From 8f20353e3b3ac915fb33e0a22e7c564261063a4c Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Jun 2017 14:01:05 +0300 Subject: [PATCH 1/8] Animate input border color change --- src/marketplace.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/marketplace.css b/src/marketplace.css index 75b7c01a..50a31f2b 100644 --- a/src/marketplace.css +++ b/src/marketplace.css @@ -258,6 +258,8 @@ input { border-bottom-color: var(--marketplaceColor); border-radius: 0; + transition: border-bottom-color ease-in 0.2s; + &::placeholder { color: var(--matterColorAnti); } From b83dd5859fc9fc6751b1c5cf614726093ae8b499 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Jun 2017 14:01:19 +0300 Subject: [PATCH 2/8] Change input success state definition --- src/components/InputField/InputField.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/InputField/InputField.js b/src/components/InputField/InputField.js index 58ec3895..fae0f2b2 100644 --- a/src/components/InputField/InputField.js +++ b/src/components/InputField/InputField.js @@ -24,20 +24,16 @@ class InputField extends Component { meta, } = this.props; const inputProps = { ...input, type, placeholder, autoFocus }; - const { pristine, valid, invalid, touched, error } = meta; + const { valid, invalid, touched, error } = meta; // Error message and input error styles are only shown if the // field has been touched and the validation has failed. const hasError = touched && invalid && error; - // Input is market as succesful if it has been changed and - // validation has not failed. - const isFilledInAndValid = !pristine && touched && valid; - const classes = classNames(rootClassName || css.root, className); const labelClasses = labelRootClassName || css.label; const inputClasses = classNames(inputRootClassName || css.input, { - [css.inputSuccess]: isFilledInAndValid, + [css.inputSuccess]: valid, [css.inputError]: hasError, }); const errorClasses = errorRootClassName || css.validationError; From 950e6b18c887d02f8275fc607784eeca839567e0 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Jun 2017 16:19:25 +0300 Subject: [PATCH 3/8] Add default textarea styles --- src/marketplace.css | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/marketplace.css b/src/marketplace.css index 50a31f2b..91283aa3 100644 --- a/src/marketplace.css +++ b/src/marketplace.css @@ -243,9 +243,19 @@ select { textarea { width: 100%; - border-width: 1px; - border-style: solid; - border-color: var(--marketplaceColor); + min-height: 48px; + padding: 0 0 5px 0; + + /* Borders */ + border: none; + border-bottom-width: 3px; + border-bottom-style: solid; + border-bottom-color: var(--marketplaceColor); + border-radius: 0; + + &:focus { + outline: none; + } } input { From 390bdf8132575fdd0ea9691251a44bb441156e24 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Jun 2017 16:20:51 +0300 Subject: [PATCH 4/8] Fix InputField top margin --- src/components/InputField/InputField.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/InputField/InputField.css b/src/components/InputField/InputField.css index e1056930..5546ae12 100644 --- a/src/components/InputField/InputField.css +++ b/src/components/InputField/InputField.css @@ -1,10 +1,10 @@ @import '../../marketplace.css'; .root { - margin-top: calc(6 * var(--spacingUnit)); + margin-top: calc(4 * var(--spacingUnit)); @media (--desktopViewport) { - margin-top: calc(6 * var(--spacingUnitDesktop)); + margin-top: calc(4 * var(--spacingUnitDesktop)); } } From 39618f456157bbf746c421ada0e012c6f7b1c986 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Jun 2017 16:24:03 +0300 Subject: [PATCH 5/8] Add support for textarea and custom inputs --- .../InputField/InputField.example.js | 8 ++++ src/components/InputField/InputField.js | 42 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/components/InputField/InputField.example.js b/src/components/InputField/InputField.example.js index 021f984a..9c5343b9 100644 --- a/src/components/InputField/InputField.example.js +++ b/src/components/InputField/InputField.example.js @@ -39,6 +39,14 @@ const FormComponent = props => { label="Label for input with initial value" component={InputField} /> + ); diff --git a/src/components/InputField/InputField.js b/src/components/InputField/InputField.js index fae0f2b2..452d7297 100644 --- a/src/components/InputField/InputField.js +++ b/src/components/InputField/InputField.js @@ -1,4 +1,5 @@ import React, { Component, PropTypes } from 'react'; +import { omit } from 'lodash'; import classNames from 'classnames'; import css from './InputField.css'; @@ -16,6 +17,7 @@ class InputField extends Component { labelRootClassName, inputRootClassName, errorRootClassName, + inputComponent: InputComponent, type, label, placeholder, @@ -23,7 +25,22 @@ class InputField extends Component { input, meta, } = this.props; + + const isCustom = type === 'custom'; + const isTextarea = type === 'textarea'; + + if (!isCustom && InputComponent) { + throw new Error('inputComponent should only be given with type="custom" prop'); + } + if (isCustom && !InputComponent) { + throw new Error('inputComponent prop required for custom inputs'); + } + + // Normal component takes all the props, but the type prop + // is omitted from