-
Notifications
You must be signed in to change notification settings - Fork 9
/
column-component.js
50 lines (43 loc) · 926 Bytes
/
column-component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Vue.component('column', {
props: ['column'],
methods: {
cardClicked: function(card) {
if (card == this.lastCard() || !card.reversed) {
this.$emit('card-clicked', card, this.column);
}
},
cards: function() {
return this.column.cards;
},
empty: function() {
return this.cards().length == 0;
},
emptySpotClicked: function() {
this.$emit('empty-spot-clicked', this.column);
},
id: function() {
return this.column.id;
},
lastCard: function() {
if (!this.empty()) {
return this.cards()[this.cards().length - 1];
}
else {
return null;
}
},
},
template: `
<span
class="column"
v-bind:class="{ empty: column.empty() }">
<card
v-for="card in column.cards"
v-bind:key="card.id"
v-bind:card="card"
v-on:card-clicked="cardClicked"
></card>
<span class="empty-spot" v-on:click="emptySpotClicked"></span>
</span>
`,
});