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

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-05-12 13:18:33 +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-05-12 13:18:33 +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 = [
2020-05-12 13:18:33 +00:00
['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-23 20:24:17 +00:00
];
2020-03-13 14:21:33 +00:00
return (
<Grid centered relaxed>
2020-05-12 13:18:33 +00:00
{myicons.map((e, i) => (
<Grid.Row key={i}>
{e.map((e, i) => (
<Grid.Column key={i}>
<Button
name={e}
color={e === this.state.currentIcon ? 'black' : null}
icon={e}
size="small"
onClick={this.selectIcon}
/>
</Grid.Column>
))}
</Grid.Row>
))}
2020-03-23 20:24:17 +00:00
</Grid>
);
2020-03-13 14:21:33 +00:00
}
}