frontend/smart-hut/src/components/SelectIcons.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-03-24 15:03:08 +00:00
import React, { Component } from "react";
import { Button, Grid } from "semantic-ui-react";
2020-03-13 14:21:33 +00:00
export default class SelectIcons extends Component {
2020-03-14 14:25:55 +00:00
constructor(props) {
super(props);
this.state = {
2020-03-23 20:24:17 +00:00
currentIcon: this.props.currentIcon,
};
2020-03-14 14:25:55 +00:00
}
selectIcon = (e) => {
let el = e.target.name;
2020-03-23 20:24:17 +00:00
if (e.target.tagName === "I") {
2020-03-14 14:25:55 +00:00
el = e.target.parentNode.name;
}
this.props.updateIcon(el);
2020-03-23 20:24:17 +00:00
this.setState({ currentIcon: el });
};
2020-03-14 14:25:55 +00:00
2020-03-23 20:24:17 +00:00
render() {
const myicons = [
["home", "coffee", "beer", "glass martini", "film", "video"],
["music", "headphones", "fax", "phone", "laptop", "bath"],
["shower", "bed", "child", "warehouse", "car", "bicycle"],
["motorcycle", "archive", "boxes", "cubes", "chess", "gamepad"],
["futbol", "table tennis", "server", "tv", "heart", "camera"],
["trophy", "wrench", "image", "book", "university", "medkit"],
["paw", "tree", "utensils", "male", "female", "life ring outline"],
];
2020-03-13 14:21:33 +00:00
return (
<Grid centered relaxed>
2020-03-24 15:03:08 +00:00
{myicons.map((e, i) => {
2020-03-13 14:21:33 +00:00
return (
2020-03-14 14:25:55 +00:00
<Grid.Row key={i}>
2020-03-23 20:24:17 +00:00
{e.map((e, i) => {
return (
<Grid.Column key={i}>
<Button
name={e}
color={e === this.state.currentIcon ? "black" : null}
icon={e}
size="small"
onClick={this.selectIcon}
/>
</Grid.Column>
);
})}
2020-03-13 14:21:33 +00:00
</Grid.Row>
2020-03-23 20:24:17 +00:00
);
})}
</Grid>
);
2020-03-13 14:21:33 +00:00
}
}