Implement button module in React

This commit is contained in:
Daniel Sinn
2019-11-25 10:16:04 -05:00
parent 28a4d8c4f8
commit 5621ab7212
8 changed files with 184 additions and 68 deletions
+31
View File
@@ -0,0 +1,31 @@
import PropTypes from 'prop-types';
import React, {Component} from "react";
export default class ButtonModuleColourInput extends Component {
render() {
return (
<label>
<input
checked={this.props.stateColour === this.props.colour}
name="buttonColour"
onChange={this.props.onChange}
type="radio"
value={this.props.colour}
/>
<span className={`button ${this.props.colour}`}>
{this.props.colour.charAt(0).toUpperCase() + this.props.colour.slice(1)}
</span>
</label>
)
}
shouldComponentUpdate(nextProps) {
return this.props.stateColour !== nextProps.stateColour;
}
}
ButtonModuleColourInput.propTypes = {
colour: PropTypes.string,
onChange: PropTypes.func,
stateColour: PropTypes.string
};