Last active
November 24, 2020 09:43
-
-
Save asoglovo/1cdb6cdd8bd98dce3a3e7d1bed91d36f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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