Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Ginalick
authored and
Michael Ginalick
committed
Jan 1, 2018
1 parent
9d44d08
commit 79591eb
Showing
3 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
((() => { | ||
const html = ` | ||
<div class="wrapper"> | ||
<div v-for="(tile, index) in tiles" | ||
v-bind:key="tile.id" | ||
v-bind:class="{black_active: !tile.showFace }" | ||
class="box" | ||
@click="handleClick(tile)"> | ||
{{tile.id}} | ||
</div> | ||
</div> | ||
` | ||
|
||
Vue.component("tile", { | ||
template: html, | ||
|
||
data() { | ||
return { | ||
|
||
} | ||
}, | ||
|
||
mounted() { | ||
this.populateBoard() | ||
}, | ||
|
||
props: { | ||
tiles: { | ||
type: Array, | ||
required: true | ||
}, | ||
|
||
matchingOptions: { | ||
type: Array, | ||
required: true | ||
}, | ||
}, | ||
|
||
methods: { | ||
populateBoard() { | ||
|
||
for(let i = 0; i <= ((this.matchingOptions.length*2)-1); i++) { | ||
this.tiles.push({id: i, showFace: false, matched: false }) | ||
} | ||
|
||
return this.tiles | ||
}, | ||
|
||
handleClick(tile) { | ||
tile.showFace = true | ||
|
||
setTimeout(function() { | ||
tile.showFace = false | ||
}, 2000) | ||
} | ||
} | ||
|
||
}) | ||
}))() |