This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CardSet.vue
112 lines (101 loc) · 2.41 KB
/
CardSet.vue
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
<div class="simpleset">
<FlashCard v-for="card in cards.slice(0,1)"
:key="card.qid"
:qid="card.qid"
:question="card.question"
:answer="card.answer"
@answered=onAnswered
@flipped=onFlipped
:flipped="card.flipped"
:answered="null"
:timeunit="timeunit"
/>
<p v-show="cards.length == 0" class="message">
All done! 👍<br/>
<span>Come back later to this page to practice again. Your progress is only kept on your own device.</span>
</p>
</div>
</template>
<script>
import FlashCard from './FlashCard.vue';
export default {
components: {FlashCard},
data(){
return {
cards: this.$parent.flashCards
}
},
props: {
timeunit: {
type: String,
required: true,
default: "days"
}
},
methods: {
onFlipped: function(qid, is_flipped){
//console.log("flipped: ", qid, is_flipped);
let card = this.cards.find((c) => c.qid === qid);
if(card) card.flipped = is_flipped;
},
onAnswered: function(qid, answer) {
//console.log("onAnswered: ", qid, answer);
let card = this.cards.find((c) => c.qid === qid);
if (answer === "recalled") {
// remove from the set
this.cards.splice( this.cards.indexOf(card), 1 );
} else {
// forgot, so need to practice right away
// remove and append at the end
this.skip(card);
}
},
skip: function(card) {
// pop the first card and append it at the last
this.cards.splice( this.cards.indexOf(card), 1 );
card.answered = null;
card.flipped = false;
this.cards.push(card);
}
}
}
</script>
<style scoped>
*,
*::before,
*::after {
box-sizing: border-box;
}
.simpleset {
display: block;
margin: 0 auto;
text-align: center;
max-width: 960px;
}
.simpleset .flash-card {
display: none;
}
.simpleset .flash-card:first-child {
display: block;
}
p.message {
margin: 0 16px;;
border-radius: 3px;
color: #222;
background-color: #fcfaff;
border: 2px solid purple;
box-shadow: 3px 3px 20px rgb(70, 70, 196);
font-family: "Avenir", Helvetica, Arial, sans-serif;
line-height: 1.4;
max-width: 960px;
padding: 2.0em;
font-weight: bold;
font-size: 3.0em;
-webkit-font-smoothing: antialiased;
}
p.message span {
font-weight: normal;
font-size: 0.5em;
}
</style>