1
0
mirror of https://github.com/EECS-448-Battleship/project-1 synced 2024-09-28 22:20:48 +00:00
eecs448-project-1/src/components/GridCell.component.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

import {Component} from '../../lib/vues6.js'
import {GridCellState} from '../module/util.js'
const template = `
<div
class="game-board-cell-component"
2020-09-10 00:44:09 +00:00
@click="on_click"
@mouseover="on_hover($event)"
@mouseleave="on_mouse_leave"
2020-09-08 00:41:50 +00:00
v-bind:class="{ disabled: render === GridCellState.Disabled, available: render === GridCellState.Available,
ship: render == GridCellState.Ship, damaged: render == GridCellState.Damaged, sunk: render == GridCellState.Sunk,
missed: render == GridCellState.Missed, ghost: has_ghost_ship }"
>
</div>
`
export default class GridCellComponent extends Component {
static get selector() { return 'app-game-cell' }
static get template() { return template }
/** Properties that can be passed into this component. */
static get props() {
return [
'render',
'has_ghost_ship',
]
}
/** Make the "GridCellState" enum available in the template. */
GridCellState = GridCellState
2020-09-10 00:44:09 +00:00
on_click() {
this.$emit('click')
}
on_hover($event) {
this.$emit('hover', $event)
}
on_mouse_leave() {
this.$emit('hoverchange')
}
}