-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RadioGroup can be an uncontrolled component when not passing the "val…
…ue" prop
- Loading branch information
Showing
10 changed files
with
180 additions
and
21 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,102 @@ | ||
import '@trendmicro/react-tooltip/dist/react-tooltip.css'; | ||
import { Tooltip } from '@trendmicro/react-tooltip'; | ||
import React, { PureComponent } from 'react'; | ||
import Section from './Section'; | ||
import { RadioGroup, RadioButton } from '../src'; | ||
|
||
export default class extends PureComponent { | ||
state = { | ||
ports: '', | ||
comic: '' | ||
}; | ||
|
||
handleChangeByKey = (key) => (value, event) => { | ||
this.setState({ [key]: value }); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Section className="row-sm-11 row-md-6"> | ||
<h3>Uncontrolled Radio Group</h3> | ||
<h5>Stacked</h5> | ||
<p>{`Selected: "${this.state.ports}"`}</p> | ||
<RadioGroup | ||
name="ports" | ||
onChange={this.handleChangeByKey('ports')} | ||
> | ||
<div> | ||
<RadioButton label="All ports" value="all" /> | ||
<Tooltip content="All ports"> | ||
<i className="fa fa-info-circle" style={{ marginLeft: 8 }} /> | ||
</Tooltip> | ||
</div> | ||
<div> | ||
<RadioButton | ||
label="Specified ports" | ||
value="custom" | ||
/> | ||
<Tooltip content="Specified ports"> | ||
<i className="fa fa-info-circle" style={{ marginLeft: 8 }} /> | ||
</Tooltip> | ||
<div style={{ marginLeft: 22 }}> | ||
<input | ||
type="text" | ||
className="form-control" | ||
placeholder={this.state.ports === 'custom' ? '1-1023, 8000, 8080' : ''} | ||
disabled={this.state.ports !== 'custom'} | ||
onChange={event => { | ||
event.stopPropagation(); | ||
}} | ||
/> | ||
<div className="text-muted"> | ||
Use a comma to separate multiple ports. | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
<RadioButton label="Range" value="range" /> | ||
<div style={{ marginLeft: 22 }}> | ||
<div className="row"> | ||
<div className="col-xs-6"> | ||
<input | ||
type="text" | ||
name="from" | ||
className="form-control" | ||
placeholder={this.state.ports === 'range' ? 'From' : ''} | ||
disabled={this.state.ports !== 'range'} | ||
onChange={event => { | ||
//event.stopPropagation(); | ||
}} | ||
/> | ||
</div> | ||
<div className="col-xs-6"> | ||
<input | ||
type="text" | ||
name="to" | ||
className="form-control" | ||
placeholder={this.state.ports === 'range' ? 'To' : ''} | ||
disabled={this.state.ports !== 'range'} | ||
onChange={event => { | ||
//event.stopPropagation(); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</RadioGroup> | ||
<h5>Inline</h5> | ||
<p>{`Selected: "${this.state.comic}"`}</p> | ||
<RadioGroup | ||
name="comic" | ||
onChange={this.handleChangeByKey('comic')} | ||
> | ||
<RadioButton label="Batman (DC)" value="dc:batman" /> | ||
<RadioButton label="Hulk (Marvel)" value="marvel:hulk" /> | ||
<RadioButton label="Superman (DC)" value="dc:superman" /> | ||
<RadioButton label="Spider-Man (Marvel)" value="marvel:spiderman" disabled /> | ||
</RadioGroup> | ||
</Section> | ||
); | ||
} | ||
} |
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
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