From 0044597f0737aa3277bbb4dd851da7491c05920c Mon Sep 17 00:00:00 2001 From: M03M Date: Mon, 16 Mar 2015 15:21:12 -0500 Subject: [PATCH 1/3] Refactored css for textfields. --- .../pages/components/text-fields.jsx | 26 ++- .../less/pages/components/text-fields.less | 5 - src/js/before-after-wrapper.jsx | 18 +- src/js/enhanced-textarea.jsx | 6 +- src/js/styles/variables/custom-variables.js | 3 +- src/js/text-field.jsx | 180 +++++++++++++++--- src/less/components/components.less | 1 - src/less/components/text-field.less | 168 ---------------- 8 files changed, 187 insertions(+), 220 deletions(-) delete mode 100644 src/less/components/text-field.less diff --git a/docs/src/app/components/pages/components/text-fields.jsx b/docs/src/app/components/pages/components/text-fields.jsx index ea91ab347386e9..a4df52431ab39a 100644 --- a/docs/src/app/components/pages/components/text-fields.jsx +++ b/docs/src/app/components/pages/components/text-fields.jsx @@ -20,6 +20,12 @@ var TextFieldsPage = React.createClass({ }; }, + _textfieldStyle: function() { + return { + marginTop: 24, + }; + }, + render: function() { var code = @@ -176,35 +182,44 @@ var TextFieldsPage = React.createClass({ componentInfo={componentInfo}>
-
+









@@ -212,41 +227,50 @@ var TextFieldsPage = React.createClass({








{this.state.errorText}
+
{this.state.errorText}
) : null; var hintTextElement = this.props.hintText ? ( -
{this.props.hintText}
+
{this.props.hintText}
) : null; var floatingLabelTextElement = this.props.floatingLabelText ? ( ) : null; - var textAreaStyles = { - paddingTop: this.props.floatingLabelText ? '24px' : 0 - }; - var inputProps; var inputElement; inputProps = { - ref: 'input', - className: 'mui-text-field-input', id: inputId, + ref: 'input', + style: this._input(), onBlur: this._handleInputBlur, onFocus: this._handleInputFocus, onKeyDown: this._handleInputKeyDown @@ -121,8 +237,7 @@ var TextField = React.createClass({ {...other} {...inputProps} onHeightChange={this._handleTextAreaHeightChange} - className="mui-text-field-textarea" - style={textAreaStyles} /> + textareaStyle={this._textarea()} /> ) : ( ); - return ( -
+ var underlineElement = this.props.disabled ? ( +
+ ............................................................. +
+ ) : ( +
+ ); + var focusUnderlineElement =
; + return ( +
{floatingLabelTextElement} {hintTextElement} {inputElement} - -
-
- + {underlineElement} + {focusUnderlineElement} {errorTextElement} -
); }, diff --git a/src/less/components/components.less b/src/less/components/components.less index 86927599b726dc..60457d618c576e 100644 --- a/src/less/components/components.less +++ b/src/less/components/components.less @@ -4,5 +4,4 @@ @import "paper.less"; @import "subheader.less"; @import "table.less"; -@import "text-field.less"; @import "toolbar.less"; \ No newline at end of file diff --git a/src/less/components/text-field.less b/src/less/components/text-field.less deleted file mode 100644 index 831e8dbdc21d4e..00000000000000 --- a/src/less/components/text-field.less +++ /dev/null @@ -1,168 +0,0 @@ -.mui-text-field { - @disabled-text-color: fade(@body-text-color, 30%); - @error-color: @red-500; - - font-size: 16px; - line-height: 24px; - - width: (64px * 4); - height: 48px; - display: inline-block; - position: relative; - .ease-out(@property: height, @duration: 200ms); - - //Normal Text Field Styles - //------------------------ - .mui-text-field-hint, - .mui-text-field-floating-label { - position: absolute; - line-height: 48px; - color: @disabled-text-color; - opacity: 1; - .ease-out(); - } - - .mui-text-field-error { - position: absolute; - bottom: -10px; - font-size: 12px; - line-height: 12px; - color: @error-color; - .ease-out(); - } - - .mui-text-field-input, - .mui-text-field-textarea { - position: relative; - width: 100%; - height: 100%; - border: none; - outline: none; - background-color: @transparent; - color: @body-text-color; - } - - .mui-text-field-textarea { - margin-top: 12px; - } - - .mui-text-field-underline, - .mui-text-field-focus-underline { - position: absolute; - width: 100%; - bottom: 8px; - margin: 0; - } - - .mui-text-field-focus-underline { - border-color: @primary-1-color; - border-bottom-width: 2px; - transform: scaleX(0); - .ease-out(); - } - - &.mui-has-error { - .mui-text-field-focus-underline { - border-color: @error-color; - transform: scaleX(1); - } - } - - &.mui-has-value { - .mui-text-field-hint { - opacity: 0; - } - } - - &.mui-is-disabled { - - .mui-text-field-input { - color: @disabled-text-color; - } - - .mui-text-field-underline { - border: none; - height: 40px; - overflow: hidden; - - //hack because border style dotted just doesn't look right - //border-bottom-style: dotted; - &:after { - content: '..............................................................................................................................................................................................................................................................................................................................................................'; - position: absolute; - top: 23px; - color: @disabled-text-color; - } - } - } - - &.mui-is-focused { - .mui-text-field-focus-underline { - transform: scaleX(1); - } - } - - //Floating Label Text Field Styles - //-------------------------------- - &.mui-has-floating-labels { - height: 72px; - - .mui-text-field-floating-label { - top: 24px; - transform: scale(1) translate3d(0, 0, 0); - transform-origin: left top; - } - - .mui-text-field-hint { - top: 24px; - opacity: 0; - } - - .mui-text-field-input { - padding-top: 24px; - } - - &.mui-has-value, - &.mui-is-focused { - .mui-text-field-floating-label { - transform: scale(0.75) translate3d(0, -18px, 0); - } - } - - &.mui-has-value { - .mui-text-field-floating-label { - color: fade(@body-text-color, 50%); - } - } - - &.mui-is-disabled { - .mui-text-field-hint { - color: @disabled-text-color; - } - } - - &.mui-is-focused { - - .mui-text-field-hint { - opacity: 1; - } - - .mui-text-field-floating-label { - transform: scale(0.75) translate3d(0, -18px, 0); - color: @primary-1-color; - } - - &.mui-has-error { - .mui-text-field-floating-label { - color: @error-color; - } - } - - &.mui-has-value { - .mui-text-field-hint { - opacity: 0; - } - } - } - } -} \ No newline at end of file From bd9faa53ab39c6f12ab4a7317dbf5f0193b341cd Mon Sep 17 00:00:00 2001 From: M03M Date: Mon, 16 Mar 2015 15:47:40 -0500 Subject: [PATCH 2/3] Removed underline style props. --- src/js/text-field.jsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/js/text-field.jsx b/src/js/text-field.jsx index 9493391a262803..8c598cab3af8cd 100644 --- a/src/js/text-field.jsx +++ b/src/js/text-field.jsx @@ -25,9 +25,6 @@ var TextField = React.createClass({ onKeyDown: React.PropTypes.func, onEnterKeyDown: React.PropTypes.func, type: React.PropTypes.string, - - focusUnderlineStyle: React.PropTypes.object, - underlineStyle: React.PropTypes.object, }, getDefaultProps: function() { @@ -149,12 +146,12 @@ var TextField = React.createClass({ }, _underline: function() { - return this.mergeAndPrefix({ + return { position: 'absolute', width: '100%', bottom: 8, margin: 0, - }, this.props.underlineStyle); + }; }, //hack because border style dotted just doesn't look right @@ -180,7 +177,7 @@ var TextField = React.createClass({ if (this.props.errorText) style.borderColor = this.errorColor; if (this.props.errorText || this.state.isFocused) style.transform = 'scaleX(1)'; - return this.mergeAndPrefix(style, this.props.focusUnderlineStyle); + return style; }, render: function() { From 4b39b08fae7032c772f44a3b3aeaf7f329021241 Mon Sep 17 00:00:00 2001 From: M03M Date: Mon, 16 Mar 2015 15:52:15 -0500 Subject: [PATCH 3/3] Removed unused dependency. --- src/js/text-field.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/text-field.jsx b/src/js/text-field.jsx index 8c598cab3af8cd..30cef32a8ecc27 100644 --- a/src/js/text-field.jsx +++ b/src/js/text-field.jsx @@ -1,5 +1,4 @@ var React = require('react'); -var BeforeAfterWrapper = require('./before-after-wrapper'); var ColorManipulator = require('./utils/color-manipulator'); var Colors = require('./styles/colors'); var Theme = require('./styles/theme').get();