-
Notifications
You must be signed in to change notification settings - Fork 47.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update number fixtures to use latest components
- Loading branch information
Showing
2 changed files
with
132 additions
and
95 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
fixtures/dom/src/components/fixtures/number-inputs/NumberTestCase.js
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,37 @@ | ||
const React = window.React; | ||
|
||
import Fixture from '../../Fixture'; | ||
|
||
const NumberTestCase = React.createClass({ | ||
getInitialState() { | ||
return { value: '' }; | ||
}, | ||
onChange(event) { | ||
const parsed = parseFloat(event.target.value, 10) | ||
const value = isNaN(parsed) ? '' : parsed | ||
|
||
this.setState({ value }) | ||
}, | ||
render() { | ||
return ( | ||
<Fixture> | ||
<div>{this.props.children}</div> | ||
|
||
<div className="control-box"> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<input type="number" value={this.state.value} onChange={this.onChange} /> | ||
<span className="hint"> Value: {JSON.stringify(this.state.value)}</span> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<input type="number" defaultValue={0.5} /> | ||
</fieldset> | ||
</div> | ||
</Fixture> | ||
); | ||
}, | ||
}); | ||
|
||
export default NumberTestCase; |
190 changes: 95 additions & 95 deletions
190
fixtures/dom/src/components/fixtures/number-inputs/index.js
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