Skip to content

Instantly share code, notes, and snippets.

@asoglovo
Last active November 24, 2020 09:43
Show Gist options
  • Save asoglovo/1cdb6cdd8bd98dce3a3e7d1bed91d36f to your computer and use it in GitHub Desktop.
Save asoglovo/1cdb6cdd8bd98dce3a3e7d1bed91d36f to your computer and use it in GitHub Desktop.
<script>
import { createEventDispatcher } from "svelte";
export let cell;
export let overrideVisible = false;
const dispatch = new createEventDispatcher();
function unhideCell() {
if (cell.hasMine) {
dispatch("game-over");
} else {
dispatch("uncover", { ...cell, isHidden: false });
}
}
</script>
<style scoped>
.board-cell {
width: 30px;
height: 30px;
border: 1px solid;
}
.hidden {
width: inherit;
height: inherit;
background-color:lightslategray;
cursor: pointer;
}
.has-mine {
width: inherit;
height: inherit;
line-height: 30px;
background-color: red;
}
</style>
<td class="board-cell">
{#if cell.isHidden && !overrideVisible}
<div class="hidden" on:click={unhideCell}></div>
{:else if cell.hasMine}
<div class="has-mine">X</div>
{:else}
{cell.minesAroundCount}
{/if}
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment