This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Button from './Button'; | |
| export { Button }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Component from 'metal-jsx'; | |
| import Mathematics from './components/Mathematics'; | |
| class App extends Component { | |
| render() { | |
| const {lvlDefault, lvls, showResult, countdown} = this.state; | |
| return ( | |
| <Mathematics | |
| countdown={30} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Render UI finish game | |
| */ | |
| renderFinishGame() { | |
| const {hits, errors} = this.state; | |
| return ( | |
| <Layout> | |
| <Layout.Header>{LANGUAGE.finishGame}</Layout.Header> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Handle click to validate expression | |
| * @param {object} event | |
| */ | |
| _handleClickValidateExpression(event) { | |
| event.preventDefault(); | |
| if (event.target.result.value === '') return; | |
| let value = event.target.result.value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setNextOperation() { | |
| let n1 = getRandomNumber(0, this.state.lvl.maxNumber); | |
| let n2 = getRandomNumber(0, this.state.lvl.maxNumber); | |
| let operator = this.getRandomOperator(); | |
| let result = CALCULATE(n1, n2, operator); | |
| // If isn't real number, set the next operation | |
| if (isNaN(result) || !isFinite(result)) { | |
| this.setNextOperation(); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Render UI start game | |
| */ | |
| renderStartGame() { | |
| const { | |
| state: {lvl, n1, n2, operator, message, errors, hits, countdown}, | |
| props: {showResult} | |
| } = this; | |
| const result = CALCULATE(n1, n2, operator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Render UI init game | |
| */ | |
| renderInitGame() { | |
| return ( | |
| <Layout> | |
| <Layout.Header>{LANGUAGE.initGame}</Layout.Header> | |
| <Layout.Body> | |
| {this.renderUIButtons()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| render() { | |
| const {start, finish, init, lvl} = this.state; | |
| return ( | |
| <div class={`mathematics mathematics--lvl-${lvl.internalLabel}`}> | |
| <div class={'mathematics__body'}> | |
| {init && ( | |
| <div class={'mathematics__init'}> | |
| {this.renderInitGame()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mathematics.PROPS = { | |
| /** | |
| * @type {number} | |
| * @default 30 | |
| */ | |
| countdown: Config.number().value(30), | |
| /** | |
| * @type {string} | |
| * @default undefined |