Skip to content

Commit 8bd5681

Browse files
committed
Break display of game details out into its own subcomponent.
1 parent c094572 commit 8bd5681

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/BoardGame.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<li>
3+
<span :class="icon"></span>
4+
{{ name }}
5+
</li>
6+
</template>
7+
8+
<script>
9+
module.exports = {
10+
props: [
11+
'name',
12+
'type'
13+
],
14+
computed: {
15+
icon: function () {
16+
return 'icon-' + this.type
17+
}
18+
}
19+
}
20+
</script>

src/BoardLibrary.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
<button @click="addGame">Add</button>
99
<p v-if="empty">Zarro Boords!</p>
1010
<ul v-else>
11-
<li v-for="g in games">
12-
<span :class="icon(g.type)"></span>
13-
{{ g.game }}
14-
</li>
11+
<board-game v-for="g in games" :type="g.type" :name="g.game"></board-game>
1512
</ul>
1613
</div>
1714
</template>
1815

1916
<script>
17+
var BoardGame = require('./BoardGame.vue')
18+
2019
module.exports = {
2120
data: function() {
2221
return {
@@ -36,10 +35,10 @@ module.exports = {
3635
game: this.game,
3736
type: this.type
3837
})
39-
},
40-
icon: function (type) {
41-
return 'icon-' + type
4238
}
39+
},
40+
components: {
41+
BoardGame: BoardGame
4342
}
4443
}
45-
</script>
44+
</script>

0 commit comments

Comments
 (0)