Skip to content

Commit

Permalink
Remove Borders
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwaterman committed Jan 31, 2020
1 parent 7056af4 commit 90acd51
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Cell.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { cellStores, surroundingStores } from "./cellsStore";
import { cellStores, surroundingStores, width } from "./cellsStore";
export let index;
$: me = cellStores[index];
Expand Down Expand Up @@ -41,20 +41,23 @@
][adjacentMinesCount];
}
let backgroundColor;
$: if (stateKnown) {
backgroundColor = isMine ? "#f55" : "white";
} else {
backgroundColor = null;
$: x = Math.floor(index / $width);
$: y = index % $width;
$: light = (x + y) % 2 === 0;
function getBackgroundColor(stateKnown, isMine, light) {
if (stateKnown && isMine) return "#f55";
if (stateKnown && !isMine && light) return "#fff";
if (stateKnown && !isMine && !light) return "#ddd";
if (!stateKnown && light) return "#aaa";
if (!stateKnown && !light) return "#999";
}
$: backgroundColor = getBackgroundColor(stateKnown, isMine, light);
$: cellText = isMine ? "X" : adjacentMinesCount;
</script>

<style>
.cell {
border: 1px solid #aaa;
background-color: #ddd;
display: flex;
align-items: center;
justify-content: center;
Expand Down

0 comments on commit 90acd51

Please sign in to comment.