Skip to content

Instantly share code, notes, and snippets.

View interaminense's full-sized avatar
🖐️
Hi there!

Adriano Interaminense interaminense

🖐️
Hi there!
View GitHub Profile
@interaminense
interaminense / mathematics-render-start-game.js
Created February 27, 2018 01:39
Mathematics RenderStartGame
/**
* Render UI start game
*/
renderStartGame() {
const {
state: {lvl, n1, n2, operator, message, errors, hits, countdown},
props: {showResult}
} = this;
const result = CALCULATE(n1, n2, operator);
@interaminense
interaminense / mathematics-setnextoperation.js
Created February 27, 2018 02:28
Mathematics setNextOperation
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 {
@interaminense
interaminense / mathematics-handleclickbutton.js
Created February 27, 2018 03:15
Mathematics handleClickButton
/**
* Handle click on buttons inside forms
* @param {*} event
*/
_handleClickButton(event) {
// If button is a submit type, return
if (event.target.type !== 'button') {
return;
}
@interaminense
interaminense / mathematics-handleclickvalidateexpression.js
Created February 27, 2018 03:19
Mathematics handleClickValidateExpression
/**
* Handle click to validate expression
* @param {object} event
*/
_handleClickValidateExpression(event) {
event.preventDefault();
if (event.target.result.value === '') return;
let value = event.target.result.value;
@interaminense
interaminense / mathematics-render-finish-game.js
Created February 28, 2018 01:36
Mathematics RenderFinishGame
/**
* Render UI finish game
*/
renderFinishGame() {
const {hits, errors} = this.state;
return (
<Layout>
<Layout.Header>{LANGUAGE.finishGame}</Layout.Header>
@interaminense
interaminense / mathematics-app.js
Last active February 28, 2018 03:13
Mathematics App
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}
@interaminense
interaminense / mathematics-export-components.js
Created February 28, 2018 04:14
Mathematics Export Components
import Button from './Button';
export { Button };
@interaminense
interaminense / mathematics-import-metaljsx.js
Created February 28, 2018 04:15
Mathematics Import MetalJSX
import Component from 'metal-jsx';
class Button extends Component {}
export default Button;
@interaminense
interaminense / mathematics-component-button.js
Created February 28, 2018 04:16
Mathematics Component Button
<Button isActive style={'primary'} />
@interaminense
interaminense / mathematics-config.js
Created February 28, 2018 04:17
Mathematics Config
import Component, {Config} from 'metal-jsx';
class Button extends Component {}
export default Button;