-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
89 lines (86 loc) · 3.11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="me">
<img src="me.jpeg" alt="">
<p>
<strong>Hassane Dao</strong>
<span>Développeur full-stack</span>
<span style="font-weight:bold; margin-top: 3px; font-family: 'Fira Code'">#Vuejs</span>
</p>
</div>
<img class="img" src="logo.jpeg" alt="">
<div id="shopping-list">
<div class="header">
<h1>{{ header.toUpperCase() }}</h1>
<button v-if="state === 'default'" class="btn btn-primary" @click="changeState('edit')">Ajouter</button>
<button v-else class="btn btn-cancel" @click="changeState('default')">Annuler</button>
</div>
<div v-if="state === 'edit'" class="add-item-form">
<input type="text" v-model="newItem" placeholder="Ajouter un contenu" @keyup.enter="saveItem">
<p>{{ characterCount }}/200</p>
<button class="btn btn-primary" @click="saveItem()" :disabled="newItem.length === 0">Enregistrer</button>
</div>
<ul>
<li v-for="item in reversedItems" :class="{strikeout : item.purchased}">{{ item.label }}</li>
</ul>
<p v-if="items.length === 0">Super!!, vous avez acheté tous vos articles</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script>
var shoppingList = new Vue({
el: '#shopping-list',
data: {
state: 'default',
header: "shopping list app",
newItem: '',
items: [
// {
// label: '1kg de tomates',
// purchased: false,
// hightPriority: true
// },
// {
// label: '2kg d\'oignons',
// purchased: true,
// hightPriority: true
// },
// {
// label: '1kg de riz',
// purchased: false,
// hightPriority: false
// }
]
},
methods: {
saveItem: function() {
this.items.push({
label: this.newItem,
purchased: false
})
this.newItem = ''
},
changeState: function(newState) {
this.state = newState
this.newItem = ''
}
},
computed: {
characterCount() {
return this.newItem.length
},
reversedItems() {
return this.items.slice(0).reverse();
}
}
})
</script>
</body>
</html>