feat: Implement a 'Exit 2D MPR' button in the toolbar
* feat: Implement a 'Exit 2D MPR' button in the toolbar to act as a toggle when '2D MPR' button is clicked * Move logic to exit MPR and toggling into ConnectedPluginSwitch and PluginSwitch. Also, discard the ConnectedExitPluginSwitch and ExitPluginSwitch components. * Update ToolbarRow.js
This commit is contained in:
1 parent
84144bc3ef
commit
c99e0d8a23
2 files changed
+63
-17
No files matched your search
@@ -6,14 +6,43 @@ import './PluginSwitch.css';
|
||||
class PluginSwitch extends Component {
|
||||
static propTypes = {
|
||||
mpr: PropTypes.func,
|
||||
exitMpr: PropTypes.func
|
||||
};
|
||||
|
||||
static defaultProps = {};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isPlugSwitchOn: false,
|
||||
label: "2D MPR",
|
||||
icon: "cube"
|
||||
};
|
||||
}
|
||||
|
||||
handleClick = () => {
|
||||
if (this.state.isPlugSwitchOn) {
|
||||
this.setState({
|
||||
isPlugSwitchOn: false,
|
||||
label: "2D MPR",
|
||||
icon: "cube"
|
||||
});
|
||||
this.props.exitMpr();
|
||||
} else {
|
||||
this.setState({
|
||||
isPlugSwitchOn: true,
|
||||
label: "Exit 2D MPR",
|
||||
icon: "times"
|
||||
});
|
||||
this.props.mpr();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { label, icon } = this.state;
|
||||
|
||||
return (
|
||||
<div className="PluginSwitch">
|
||||
<ToolbarButton label="2D MPR" icon="cube" onClick={this.props.mpr} />
|
||||
<ToolbarButton label={label} icon={icon} onClick={this.handleClick} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user