figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

index.js (2162B)


      1 import React from 'react';
      2 import PropTypes from 'prop-types';
      3 import {SmallButtonRow} from "../smallButton";
      4 import {LargeButton} from "../largeButton";
      5 import styles from './styles.module.css';
      6 
      7 export class Pad extends React.Component {
      8     render() {
      9         const disabledTruths = this.props.disabledTruths,
     10             displayValues = this.props.displayValues,
     11             onChange = this.props.onChange,
     12             onClick = this.props.onClick,
     13             onModeClick = this.props.onModeClick,
     14             textValues = this.props.textValues,
     15             mode = this.props.mode;
     16         let rows;
     17         if (this.props.type === 'small') {
     18             rows = this.props.buttonValues.map(function (array, index, _) {
     19                 return <SmallButtonRow
     20                     idx={index}
     21                     buttonValues={array}
     22                     onClick={onClick}
     23                     onModeClick={onModeClick}
     24                 />;
     25             });
     26         } else {
     27             rows = this.props.buttonValues.map(function (value, index, _) {
     28                 return (
     29                     <LargeButton
     30                         disabledTruth={disabledTruths == null ? false : disabledTruths[index]}
     31                         displayValue={displayValues == null ? '' : displayValues[index]}
     32                         mode={mode}
     33                         onChange={onChange}
     34                         onClick={onClick}
     35                         onModeClick={onModeClick}
     36                         textValue={textValues == null ? '' : textValues[index]}
     37                         value={value}
     38                     />
     39                 );
     40             });
     41         }
     42         return (
     43             <div className={styles.pad} style={this.props.style}>
     44                 {rows}
     45             </div>
     46         );
     47     }
     48 }
     49 Pad.propTypes = {
     50     type: PropTypes.string.isRequired,
     51     buttonValues: PropTypes.array.isRequired,
     52     onClick: PropTypes.func,
     53     mode: PropTypes.string,
     54     onChange: PropTypes.func,
     55     onModeClick: PropTypes.func,
     56     disabledTruths: PropTypes.arrayOf(PropTypes.bool),
     57     displayValues: PropTypes.array,
     58     textValues: PropTypes.arrayOf(PropTypes.string)
     59 };