index.js (1516B)
1 import React from 'react'; 2 import PropTypes from 'prop-types'; 3 import styles from './styles.module.css'; 4 5 class SmallButton extends React.Component { 6 render() { 7 return ( 8 <button 9 type='button' 10 onClick={this.props.onClick} 11 className={styles.button} 12 value={this.props.value} 13 > 14 {this.props.value} 15 </button> 16 ); 17 } 18 } 19 SmallButton.propTypes = { 20 value: PropTypes.string.isRequired, 21 onClick: PropTypes.func.isRequired 22 }; 23 24 export class SmallButtonRow extends React.Component { 25 render() { 26 const onClick = this.props.onClick, 27 onModeClick = this.props.onModeClick; 28 return ( 29 <div className={styles.buttonRow}> 30 {this.props.buttonValues.map(function (value, index, _) { 31 if (value === '…') { 32 return ( 33 <button type='button' onClick={onModeClick} className={styles.button} value={'select'}> 34 {value} 35 </button> 36 ); 37 } else { 38 return <SmallButton idx={index} value={value} onClick={onClick}/>; 39 } 40 })} 41 </div> 42 ); 43 } 44 } 45 SmallButtonRow.propTypes = { 46 buttonValues: PropTypes.arrayOf(PropTypes.string).isRequired, 47 onClick: PropTypes.func, 48 onModeClick: PropTypes.func 49 };