From 14652eecb0fb4ebcb14e830504bfb02017bd010e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 16 Sep 2018 16:03:41 +0200 Subject: augmentation grid --- app/client/common/augmentationGrid.component.js | 37 +++++++++++++++++++++++++ app/client/common/buttonGrid.component.js | 32 +++++++++++++++++++++ app/client/common/index.js | 3 ++ 3 files changed, 72 insertions(+) create mode 100644 app/client/common/augmentationGrid.component.js create mode 100644 app/client/common/buttonGrid.component.js (limited to 'app/client/common') diff --git a/app/client/common/augmentationGrid.component.js b/app/client/common/augmentationGrid.component.js new file mode 100644 index 0000000..69bdc8a --- /dev/null +++ b/app/client/common/augmentationGrid.component.js @@ -0,0 +1,37 @@ +import { h, Component } from 'preact' + +import Group from './group.component' +import Param from './param.component' +import Button from './button.component' +import ButtonGrid from './buttonGrid.component' + +export default class AugmentationGrid extends Component { + state = { + x: 0, y: 0, sum: 0, + } + render() { + let rows = [] + return ( + + this.setState({ x, y })} + onClick={(x, y) => { + this.setState({ sum: this.state.sum + x * y }) + this.props.onAugment(y, x) + }} + /> + {this.state.y} + {this.state.x} + {this.state.x * this.state.y} + {this.state.sum} + + + ) + } +} diff --git a/app/client/common/buttonGrid.component.js b/app/client/common/buttonGrid.component.js new file mode 100644 index 0000000..4b86d62 --- /dev/null +++ b/app/client/common/buttonGrid.component.js @@ -0,0 +1,32 @@ +import { h, Component } from 'preact' + +export default function ButtonGrid(props) { + const max = props.max || Infinity + return ( + + + + {props.x.map(x => ( + + ))} + + {props.y.map(y => ( + + + {props.x.map(x => ( + + ))} + + ))} +
{" "}{x}
{y} + {x * y > max ? " " : + + } +
+ ) +} diff --git a/app/client/common/index.js b/app/client/common/index.js index 13b3189..7448104 100644 --- a/app/client/common/index.js +++ b/app/client/common/index.js @@ -1,4 +1,6 @@ +import AugmentationGrid from './augmentationGrid.component' import Button from './button.component' +import ButtonGrid from './buttonGrid.component' import Checkbox from './checkbox.component' import CurrentTask from './currentTask.component' import { FileList, FileRow } from './fileList.component' @@ -29,4 +31,5 @@ export { TextInput, NumberInput, Slider, Select, SelectGroup, Button, Checkbox, CurrentTask, TaskList, + ButtonGrid, AugmentationGrid, } \ No newline at end of file -- cgit v1.2.3-70-g09d2