|
| 1 | +import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import { MathComponent } from 'mathjax-react'; |
| 4 | + |
| 5 | +import EditableControl from '../form-components/EditableControl.js'; |
| 6 | +import { handleFormUpdate } from '../utils.js'; |
| 7 | + |
| 8 | +export default class TemplateGraphEditor extends React.Component { |
| 9 | + render() { |
| 10 | + const func1 = String.raw`MP_N = (1 - \alpha)AK^\alpha N^{-\alpha}`; |
| 11 | + const func2 = String.raw`MP_K = \alpha AK^{\alpha - 1} N^{1 - \alpha}`; |
| 12 | + |
| 13 | + return ( |
| 14 | + <> |
| 15 | + <div className="d-flex flex-wrap"> |
| 16 | + <div className="row"> |
| 17 | + <div className="col"> |
| 18 | + <label className="form-check-label me-2" |
| 19 | + htmlFor="gExpression"> |
| 20 | + <MathComponent tex={`y = `} /> |
| 21 | + </label> |
| 22 | + <EditableControl |
| 23 | + id="gExpression" |
| 24 | + name="Expression" |
| 25 | + value={this.props.gExpression} |
| 26 | + valueEditable={true} |
| 27 | + isInstructor={this.props.isInstructor} |
| 28 | + disabled={this.props.disabled} |
| 29 | + updateGraph={this.props.updateGraph} /> |
| 30 | + </div> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + |
| 34 | + <h3 className="mt-3"> |
| 35 | + NLDS Function |
| 36 | + </h3> |
| 37 | + |
| 38 | + <div className="row"> |
| 39 | + <div className="form-check"> |
| 40 | + <input className="form-check-input" |
| 41 | + aria-label={func1} |
| 42 | + type="radio" |
| 43 | + name="gFunctionChoice" |
| 44 | + id="gFunctionChoice1" |
| 45 | + onChange={handleFormUpdate.bind(this)} |
| 46 | + value={0} |
| 47 | + checked={this.props.gFunctionChoice === 0} /> |
| 48 | + <label className="form-check-label" |
| 49 | + htmlFor="gFunctionChoice1"> |
| 50 | + <MathComponent tex={func1} /> |
| 51 | + </label> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + <div className="row"> |
| 55 | + <div className="form-check"> |
| 56 | + <input className="form-check-input" |
| 57 | + aria-label={func2} |
| 58 | + type="radio" |
| 59 | + name="gFunctionChoice" |
| 60 | + id="gFunctionChoice2" |
| 61 | + onChange={handleFormUpdate.bind(this)} |
| 62 | + value={1} |
| 63 | + checked={this.props.gFunctionChoice === 1} /> |
| 64 | + <label className="form-check-label" |
| 65 | + htmlFor="gFunctionChoice2"> |
| 66 | + <MathComponent tex={func2} /> |
| 67 | + </label> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + </> |
| 71 | + ); |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +TemplateGraphEditor.propTypes = { |
| 76 | + gType: PropTypes.number, |
| 77 | + updateGraph: PropTypes.func.isRequired, |
| 78 | + |
| 79 | + isInstructor: PropTypes.bool.isRequired, |
| 80 | + |
| 81 | + disabled: PropTypes.bool |
| 82 | +}; |
0 commit comments