Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 149 additions & 31 deletions docs/src/app/components/pages/components/inputs.jsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,163 @@
var React = require('react'),
mui = require('mui');
var React = require('react');
var mui = require('mui');
var Input = mui.Input;
var CodeExample = require('../../code-example/code-example.jsx');
var ComponentInfo = require('../../component-info.jsx');

var InputsPage = React.createClass({


componentDidMount: function() {
//console.log(this.refs.firstname.getValue());
},

render: function() {
var code =
'// Default\n' +
'<Input ref="firstname" type="text" name="firstname" placeholder="First Name" />\n' +
'// With description\n' +
'<Input ref="lastname" type="text" name="lastname" placeholder="Last Name" description="Your last name as it appears on your credit card." />\n' +
'// Disabled\n' +
'<Input ref="addressline1" type="text" name="addressline1" disabled={true} placeholder="Address Line 1" />\n' +
'// Disabled with value\n' +
'<Input ref="addressline2" type="text" name="addressline2" disabled={true} defaultValue="with value" placeholder="Address Line 2" />\n' +
'// With error\n' +
'<Input ref="city" type="text" name="city" defaultValue="Detroit" placeholder="City" description="Your city as it appears on your credit card." error="Can\'t process city name" />\n' +
'// Inline placeholder\n' +
'<Input ref="state" type="text" name="state" inlinePlaceholder={true} placeholder="State" description="Your state as it appears on your credit card." />\n' +
'// Input style "float"\n' +
'<Input ref="allegiance" inputStyle="floating" type="text" name="allegiance" placeholder="Allegiance" description="The house of which you served under." />\n' +
'// Textarea\n' +
'<Input ref="phones" multiline={true} rows={5} type="text" name="phones" placeholder="Phone numbers" description="Your phone numbers." />';

return (
<div>
<h2 className="mui-font-style-headline">Inputs</h2>
<br />
<mui.Input ref="firstname" onChange={this._onChange} type="text" name="firstname" placeholder="First Name" description="Your first name as it appears on your credit card." />
<mui.Input ref="lastname" type="text" name="lastname" placeholder="Last Name" description="Your last name as it appears on your credit card." />
<mui.Input ref="disabled" type="text" name="disabled" disabled={true} placeholder="Disabled input" />
<mui.Input ref="disabled_v" type="text" name="disabled_v" disabled={true} defaultValue="with value" placeholder="Disabled input" />
<mui.Input ref="addressline1" type="text" name="addressline1" placeholder="Address Line 1" description="Your address as it appears on your credit card." />
<mui.Input ref="addressline2" type="text" name="zipcode" placeholder="Zip Code" description="Your zip code as it appears on your credit card." />
<mui.Input ref="city" type="text" name="city" placeholder="City" description="Your city as it appears on your credit card." />
<mui.Input ref="state" type="text" name="state" placeholder="State" description="Your state as it appears on your credit card." />
<h2 className="mui-font-style-headline">Error Validation</h2>
<br />
<mui.Input ref="allegiance" type="text" name="allegiance" placeholder="Allegiance" description="The house of which you served under." />
<br />
<h2 className="mui-font-style-headline">Floating</h2>
<br />
<mui.Input ref="username" type="text" inputStyle="floating" name="Username" description="The username associated with your account." />

{/* TODO: Needs to be completed}
<h2 className="mui-font-style-headline">Multi-Line</h2>
<br />
<mui.Input multiline={true} ref="textmessage" type="text" name="textmessage" placeholder="Text Message" description="Your text message." />
{*/}
<CodeExample code={code}>
<Input ref="firstname" type="text" name="firstname" placeholder="First Name" />
<Input ref="lastname" type="text" name="lastname" placeholder="Last Name" description="Your last name as it appears on your credit card." />
<Input ref="addressline1" type="text" name="addressline1" disabled={true} placeholder="Address Line 1" />
<Input ref="addressline2" type="text" name="addressline2" disabled={true} defaultValue="with value" placeholder="Address Line 2" />
<Input ref="city" type="text" name="city" defaultValue="Detroit" placeholder="City" description="Your city as it appears on your credit card." error="Can't process city name" />
<Input ref="state" type="text" name="state" inlinePlaceholder={true} placeholder="State" description="Your state as it appears on your credit card." />
<Input ref="allegiance" inputStyle="floating" type="text" name="allegiance" placeholder="Allegiance" description="The house of which you served under." />
<Input ref="phones" multiline={true} rows={5} type="text" name="phones" placeholder="Phone numbers" description="Your phone numbers." />
</CodeExample>

<h3 className="mui-font-style-title">Props</h3>
{this._getPropInfo()}

<br/><hr/><br/>

<h3 className="mui-font-style-title">Methods</h3>
{this._getMethodInfo()}

<br/><hr/><br/>

<h3 className="mui-font-style-title">Events</h3>
{this._getEventInfo()}
</div>
);
},

_onChange: function(e, value) {
//console.log(value);
_getPropInfo: function() {
var info = [
{
name: 'description',
type: 'string',
header: 'optional',
desc: 'Input description.'
},
{
name: 'error',
type: 'string',
header: 'optional',
desc: 'Error message.'
},
{
name: 'inlinePlaceholder',
type: 'bool',
header: 'default: false',
desc: 'Placeholder will be inline.'
},
{
name: 'multiline',
type: 'bool',
header: 'default: false',
desc: 'Input becames multiline (textarea).'
},
{
name: 'name',
type: 'string',
header: 'required',
desc: 'Input name.'
},
{
name: 'placeholder',
type: 'string',
header: 'optional',
desc: 'Input placeholder.'
},
{
name: 'required',
type: 'bool',
header: 'default: true',
desc: 'Is required.'
},
{
name: 'rows',
type: 'bool',
header: 'default: false',
desc: 'Count of rows in textarea related to multiline: true.'
},
{
name: 'type',
type: 'string',
header: 'default: "text"',
desc: 'Input type, current supports only text and email.'
}
];

return <ComponentInfo infoArray={info} />;
},

_getMethodInfo: function() {
var info = [
{
name: 'blur',
header: 'Input.blur()',
desc: 'Blur input.'
},
{
name: 'clearValue',
header: 'Input.clearValue()',
desc: 'Clearing value.'
},
{
name: 'focus',
header: 'Input.focus()',
desc: 'Focus input.'
},
{
name: 'getValue',
header: 'Input.getValue()',
desc: 'Getting value.'
},
{
name: 'setValue',
header: 'Input.setValue("txt")',
desc: 'Setting value.'
}
];

return <ComponentInfo infoArray={info} />;
},

_getEventInfo: function() {
var info = [
{
name: 'onChange',
header: 'function(e, value)',
desc: 'Fired when the input is changed.'
}
];

return <ComponentInfo infoArray={info} />;
}

});
Expand Down
13 changes: 6 additions & 7 deletions src/js/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ var Input = React.createClass({
required: React.PropTypes.bool,
inlinePlaceholder: React.PropTypes.bool,
rows: React.PropTypes.number,
min: React.PropTypes.number,
max: React.PropTypes.number,
step: React.PropTypes.number,
inputStyle: React.PropTypes.string,
error: React.PropTypes.string,
description: React.PropTypes.string,
Expand Down Expand Up @@ -56,7 +53,7 @@ var Input = React.createClass({
'mui-disabled': !!this.props.disabled,
}),
placeholder = this.props.inlinePlaceholder ? this.props.placeholder : "",
inputIsNotEmpty = Boolean(this.state.value),
inputIsNotEmpty = !!this.state.value,
inputClassName = classSet({
'mui-is-not-empty': inputIsNotEmpty
}),
Expand Down Expand Up @@ -125,10 +122,12 @@ var Input = React.createClass({
},

_onLineBreak: function(e) {
var input = (e.target.value.slice(-1));
var value = e.target.value,
input = (value.slice(-1)),
lines = value.split('\n').length;

if(input.match(/\n/gm)) {
if(this.state.rows != 20) {
if (lines > this.state.rows) {
if (this.state.rows != 20) {
this.setState({ rows: ((this.state.rows) + 1)});
}
}
Expand Down
Loading