-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
187 lines (172 loc) · 8.65 KB
/
index.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="language" content="sk">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="Kamila Skokňová" >
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bungee&family=Fredericka+the+Great&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=DM+Serif+Text&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="assets/styles/styles.css">
<link rel="icon" href="assets/img/flashcards-logo.png">
<title>Flashcards</title>
</head>
<body class="background">
<div id="app" class="main-app">
<div class="add-new">
<button type="button" class="btn btn-dark mb-2 me-2" @click="toggleStudy">Study</button>
<button type="button" class="btn btn-dark mb-2 me-2" @click="toggleAdd">Add new</button>
<button type="button" class="btn btn-dark mb-2 me-2" @click="toggleShow">Show all</button>
</div>
<div v-show="sectionCards" class="cards">
<h1 v-text="deckName" class="logo text-center"></h1>
<div class="d-flex justify-content-between">
<button @click="move(-1)" type="button" class="navigation"><i class="bi bi-caret-left"></i></button>
<div>
<div class="d-flex justify-content-evenly">
<p class="text-center mt-2 sizable me-2" @click="fontSize--">smaller text</p>
<p class="text-center mt-2 sizable" @click="fontSize++">BIGGER TEXT</p>
</div>
<div class="card mx-lg-2" @click="flipped = !flipped">
<h3 v-text="flipped ? '' : cards[index].front" class="text-center card-text" :style="{'font-size': fontSize + 'px'}"></h3>
<h3 v-html="flipped ? cards[index].back : '' " class="text-center card-text" :style="{'font-size': fontSize + 'px'}"></h3>
</div>
</div>
<button @click="move(1)" type="button" class="navigation py-1"><i class="bi bi-caret-right"></i></button>
</div>
<div class="score d-flex justify-content-center mt-4">
<button @click.stop="gotIt" type="button" class="me-1 got-it-btn">Got it</button>
<button @click.stop="again" type="button" class="ms-1 again-btn">Again</button>
</div>
</div>
<div v-show="sectionForm" class="form">
<h1 class="logo text-center mb-3">Create New Card</h1>
<form class="form__form">
<label for="name">First side:</label>
<textarea v-model="form.first" class="form-control"></textarea> ({{ form.first.length }} characters)
<label for="description" class="mt-3">Second side:</label>
<textarea v-model="form.second" class="form-control"></textarea> ({{ 200 - form.second.length }} left)
<button @click.prevent="submit" type="submit" class="mt-3 got-it-btn">Create</button>
</form>
</div>
<div v-show="sectionAll" class="show-all">
<h1 class="logo text-center mb-3">Card Manager</h1>
<div v-for="(card, index) in cards" class="card-pair d-flex justify-content-between">
<div class="show-all__card">
<h5 v-text="card.front" class="mt-5"></h5>
</div>
<i class="bi bi-trash3" @click.stop="gotIt"></i>
<div class="show-all__card"><h5 v-html="card.back" class="mt-5"></h5></div>
</div>
</div>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const FlashCardApp = {
data() {
return {
deckName: 'Flashcards',
cards: [
{
front: 'Best JS tool',
back: 'Vue.js'
},
{
front: 'Does it make sense to learn without fun?',
back: "Usually no"
},
{
front: 'Best band ever',
back: 'Epica / Arch Enemy'
},
{
front: 'Our "oldest" sci-fi and fantasy writer',
back: 'Gustáv Reuss'
},
{
front: 'Who is Doctor Strange?',
back: 'Best male magician'
},
{
front: 'Who are X-men?',
back: 'They are the mutants of prof. Charles Xavier'
}
],
index: 0,
flipped: false,
fontSize: 20,
sectionCards: true,
sectionForm: false,
sectionAll: false,
form: {
first: '',
second: ''
},
};
},
methods: {
move(change) {
if (this.cards[this.index + change]) {
this.index += change;
} else {
this.index = change == 1 ? 0 : this.cards.length - 1;
}
this.flipped = false;
},
gotIt () {
if (this.cards.length === 1) {
return alert('Well done!');
}
this.cards.splice(this.index, 1);
if (! this.index[this.index]) {
this.index = 0;
}
this.flipped = false;
},
again () {
this.cards[this.index].isRepeat = true;
this.move(1);
},
submit() {
if (this.form.first.length === 0) {
return alert("You need to set the front side, too.");
} else if (this.form.second.length === 0) {
return alert("You need to set the back side, too.");
} else {
this.cards.push({
front: this.form.first,
back: this.form.second
});
this.form.first = "";
this.form.second = "";
return alert("Card was created!");
}
},
toggleStudy() {
this.sectionCards = true;
this.sectionAll = false;
this.sectionForm = false;
},
toggleAdd() {
this.sectionCards = false;
this.sectionAll = false;
this.sectionForm = true;
},
toggleShow() {
this.sectionCards = false;
this.sectionAll = true;
this.sectionForm = false;
},
}
};
const app = Vue.createApp(FlashCardApp);
app.mount('#app');
</script>
</body>
</html>