Skip to content

Commit

Permalink
Change :valid hack to class not-empty for inputs (also add email type)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButuzGOL committed Dec 20, 2014
1 parent 3eb741f commit 85e9faf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
11 changes: 7 additions & 4 deletions src/js/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ var Input = React.createClass({
'mui-error': this.props.error !== undefined && this.props.error !== null
}),
placeholder = this.props.inlinePlaceholder ? this.props.placeholder : "",
notEmptyClass = this.state.value ? 'mui-input-not-empty' : '',

This comment has been minimized.

Copy link
@hai-cea

hai-cea Dec 21, 2014

@ButuzGOL can you rename this to 'mui-is-not-empty' please?

inputClassName = notEmptyClass,
textareaClassName = 'mui-input-textarea ' + notEmptyClass,
inputElement = this.props.multiline ?
this.props.valueLink ?
<textarea {...this.props} className="mui-input-textarea" placeholder={placeholder}
<textarea {...this.props} className={textareaClassName} placeholder={placeholder}
rows={this.state.rows} /> :
<textarea {...this.props} value={this.state.value} className="mui-input-textarea"
<textarea {...this.props} value={this.state.value} className={textareaClassName}
placeholder={placeholder} rows={this.state.rows} onChange={this._onTextAreaChange} /> :
this.props.valueLink ?
<input {...this.props} ref="input" placeholder={placeholder} /> :
<input {...this.props} ref="input" value={this.state.value} placeholder={placeholder}
<input {...this.props} ref="input" className={inputClassName} placeholder={placeholder} /> :
<input {...this.props} className={inputClassName} ref="input" value={this.state.value} placeholder={placeholder}
onChange={this._onInputChange} />
placeholderSpan = this.props.inlinePlaceholder ? null : <span className="mui-input-placeholder"
onClick={this._onPlaceholderClick}>{this.props.placeholder}</span>;
Expand Down
18 changes: 9 additions & 9 deletions src/less/components/input.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
padding-bottom: 14px;
width: @input-width;

&:focus, &:valid {
&:focus, &.mui-input-not-empty {
outline: none;
box-shadow: none;
padding: 0;
Expand Down Expand Up @@ -53,7 +53,7 @@
}
}

&:not(:focus):valid {
&:not(:focus).mui-input-not-empty {
&+.mui-input-placeholder {
font-size: 13px;
color: gray;
Expand Down Expand Up @@ -98,12 +98,12 @@
box-sizing: border-box;
padding-bottom: 14px;

&[type='text'], &[type='password'] {
&[type='text'], &[type='password'], &[type='email'] {
display: block;
width: @input-width;
}

&:focus, &:valid {
&:focus, &.mui-input-not-empty {
outline: none;
box-shadow: none;
&~.mui-input-placeholder {
Expand All @@ -129,7 +129,7 @@
}
}

&:not(:focus):valid {
&:not(:focus).mui-input-not-empty {
&+.mui-input-placeholder {
color: gray;

Expand Down Expand Up @@ -207,7 +207,7 @@

&.mui-error {
textarea {
&:focus, &:valid {
&:focus, &.mui-input-not-empty {
&+.mui-input-placeholder {
color: @input-error-color;

Expand Down Expand Up @@ -244,7 +244,7 @@
}

input {
&:focus, &:valid {
&:focus, &.mui-input-not-empty {
&+.mui-input-placeholder {
color: @input-error-color;

Expand Down Expand Up @@ -285,14 +285,14 @@
top: -4px;
}

&:valid {
&.mui-input-not-empty {
&+.mui-input-placeholder {
display: none;
}
}
}

&:valid {
&.mui-input-not-empty {
&+.mui-input-placeholder {
display: none;
}
Expand Down

0 comments on commit 85e9faf

Please sign in to comment.