-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new TextField component. Fixes #183
- Loading branch information
Hai Nguyen
committed
Jan 21, 2015
1 parent
a64a399
commit b607a57
Showing
12 changed files
with
736 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
258 changes: 258 additions & 0 deletions
258
docs/src/app/components/pages/components/text-fields.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
var React = require('react'); | ||
var mui = require('mui'); | ||
var TextField = mui.TextField; | ||
var ComponentDoc = require('../../component-doc.jsx'); | ||
|
||
var TextFieldsPage = React.createClass({ | ||
|
||
getInitialState: function() { | ||
return { | ||
errorText: 'This field is required.', | ||
error2Text: 'This field must be numeric.', | ||
floatingErrorText: 'This field is required.', | ||
floatingError2Text: 'This field must be numeric.' | ||
}; | ||
}, | ||
|
||
render: function() { | ||
|
||
var code = | ||
'//Single Line Text Fields\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text" />\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text"\n' + | ||
' defaultValue="Default Value" />\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text"\n' + | ||
' value="Prop Value" />\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text (MultiLine)"\n' + | ||
' multiLine={true} />\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text"\n' + | ||
' errorText={this.state.errorText}\n' + | ||
' onChange={this._handleErrorInputChange} />\n' + | ||
'<TextField\n' + | ||
' hintText="Hint Text"\n' + | ||
' errorText={this.state.error2Text}\n' + | ||
' onChange={this._handleError2InputChange}\n' + | ||
' defaultValue="abc" />\n' + | ||
'<TextField\n' + | ||
' hintText="Disabled Hint Text"\n' + | ||
' disabled={true} />\n' + | ||
'<TextField\n' + | ||
' hintText="Disabled Hint Text"\n' + | ||
' disabled={true}\n' + | ||
' defaultValue="Disabled With Value" />\n\n' + | ||
|
||
'//Multi Line Text Fields\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text"\n' + | ||
' floatingLabels={true} />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text"\n' + | ||
' floatingLabels={true}\n' + | ||
' defaultValue="Default Value" />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text"\n' + | ||
' floatingLabels={true}\n' + | ||
' value="Prop Value" />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text (MultiLine)"\n' + | ||
' floatingLabels={true} multiLine={true} />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text"\n' + | ||
' errorText={this.state.floatingErrorText}\n' + | ||
' floatingLabels={true}\n' + | ||
' onChange={this._handleFloatingErrorInputChange} />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Hint Text"\n' + | ||
' errorText={this.state.floatingError2Text}\n' + | ||
' floatingLabels={true} defaultValue="abc"\n' + | ||
' onChange={this._handleFloating2ErrorInputChange} />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Disabled Hint Text"\n' + | ||
' disabled={true}\n' + | ||
' floatingLabels={true} />\n' + | ||
'<TextField\n' + | ||
' hintText="Floating Label Disabled Hint Text"\n' + | ||
' disabled={true}\n' + | ||
' floatingLabels={true}\n' + | ||
' defaultValue="Disabled With Value" />'; | ||
|
||
var componentInfo = [ | ||
{ | ||
name: 'Props', | ||
infoArray: [ | ||
{ | ||
name: 'errorText', | ||
type: 'string', | ||
header: 'optional', | ||
desc: 'The error text string to display.' | ||
}, | ||
{ | ||
name: 'floatingLabels', | ||
type: 'bool', | ||
header: 'default: false', | ||
desc: 'If true, hint text labels will float above the input box.' | ||
}, | ||
{ | ||
name: 'hintText', | ||
type: 'string', | ||
header: 'optional', | ||
desc: 'The hint text string to display.' | ||
}, | ||
{ | ||
name: 'multiLine', | ||
type: 'bool', | ||
header: 'default: false', | ||
desc: 'If true, a textarea element will be rendered. The textarea also grows and shrinks according to the number of lines.' | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'Methods', | ||
infoArray: [ | ||
{ | ||
name: 'blur', | ||
header: 'TextField.blur()', | ||
desc: 'Removes focus on the input element.' | ||
}, | ||
{ | ||
name: 'clearValue', | ||
header: 'TextField.clearValue()', | ||
desc: 'Clears the value on the input element.' | ||
}, | ||
{ | ||
name: 'focus', | ||
header: 'TextField.focus()', | ||
desc: 'Sets the focus on the input element.' | ||
}, | ||
{ | ||
name: 'getValue', | ||
header: 'TextField.getValue()', | ||
desc: 'Returns the value of the input.' | ||
}, | ||
{ | ||
name: 'setErrorText', | ||
header: 'TextField.setErrorText(newErrorText)', | ||
desc: 'Sets the error text on the input element.' | ||
}, | ||
{ | ||
name: 'setValue', | ||
header: 'TextField.setValue(newValue)', | ||
desc: 'Sets the value of the input element.' | ||
} | ||
] | ||
} | ||
]; | ||
|
||
return ( | ||
<ComponentDoc | ||
name="Text Field" | ||
code={code} | ||
componentInfo={componentInfo}> | ||
|
||
<div className="text-field-example"> | ||
<div className="text-field-example-group text-field-example-single-line"> | ||
<TextField | ||
hintText="Hint Text" /><br/> | ||
<TextField | ||
hintText="Hint Text" | ||
defaultValue="Default Value" /><br/> | ||
<TextField | ||
hintText="Hint Text" | ||
value="Prop Value" /><br/> | ||
<TextField | ||
hintText="Hint Text (MultiLine)" | ||
multiLine={true} /><br/> | ||
<TextField | ||
hintText="Hint Text" | ||
errorText={this.state.errorText} | ||
onChange={this._handleErrorInputChange} /><br/> | ||
<TextField | ||
hintText="Hint Text" | ||
errorText={this.state.error2Text} | ||
onChange={this._handleError2InputChange} | ||
defaultValue="abc" /><br/> | ||
<TextField | ||
hintText="Disabled Hint Text" | ||
disabled={true} /><br/> | ||
<TextField | ||
hintText="Disabled Hint Text" | ||
disabled={true} | ||
defaultValue="Disabled With Value" /><br/> | ||
</div> | ||
|
||
<div className="text-field-example-group"> | ||
<TextField | ||
hintText="Floating Label Hint Text" | ||
floatingLabels={true} /><br/> | ||
<TextField | ||
hintText="Floating Label Hint Text" | ||
floatingLabels={true} | ||
defaultValue="Default Value" /><br/> | ||
<TextField | ||
hintText="Floating Label Hint Text" | ||
floatingLabels={true} | ||
value="Prop Value" /><br/> | ||
<TextField | ||
hintText="Floating Label Hint Text (MultiLine)" | ||
floatingLabels={true} multiLine={true} /><br/> | ||
<TextField | ||
hintText="Floating Label Hint Text" | ||
errorText={this.state.floatingErrorText} | ||
floatingLabels={true} | ||
onChange={this._handleFloatingErrorInputChange} /><br/> | ||
<TextField | ||
hintText="Floating Label Hint Text" | ||
errorText={this.state.floatingError2Text} | ||
floatingLabels={true} defaultValue="abc" | ||
onChange={this._handleFloating2ErrorInputChange} /><br/> | ||
<TextField | ||
hintText="Floating Label Disabled Hint Text" | ||
disabled={true} | ||
floatingLabels={true} /><br/> | ||
<TextField | ||
hintText="Floating Label Disabled Hint Text" | ||
disabled={true} | ||
floatingLabels={true} | ||
defaultValue="Disabled With Value" /><br/> | ||
</div> | ||
</div> | ||
</ComponentDoc> | ||
); | ||
}, | ||
|
||
_handleErrorInputChange: function(e) { | ||
this.setState({ | ||
errorText: e.target.value ? '' : 'This field is required.' | ||
}); | ||
}, | ||
|
||
_handleError2InputChange: function(e) { | ||
var value = e.target.value; | ||
var isNumeric = !isNaN(parseFloat(value)) && isFinite(value); | ||
this.setState({ | ||
error2Text: isNumeric ? '' : 'This field must be numeric.' | ||
}); | ||
}, | ||
|
||
_handleFloatingErrorInputChange: function(e) { | ||
this.setState({ | ||
floatingErrorText: e.target.value ? '' : 'This field is required.' | ||
}); | ||
}, | ||
|
||
_handleFloating2ErrorInputChange: function(e) { | ||
var value = e.target.value; | ||
var isNumeric = !isNaN(parseFloat(value)) && isFinite(value); | ||
this.setState({ | ||
floatingError2Text: isNumeric ? '' : 'This field must be numeric.' | ||
}); | ||
} | ||
|
||
}); | ||
|
||
module.exports = TextFieldsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.text-field-example { | ||
|
||
.clearfix(); | ||
|
||
.text-field-example-group { | ||
width: 100%; | ||
float: left; | ||
margin-bottom: 32px; | ||
|
||
@media @device-large { | ||
width: 50%; | ||
} | ||
} | ||
|
||
.text-field-example-single-line { | ||
.mui-text-field { | ||
margin-top: 24px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.