Skip to content

Commit f644c8d

Browse files
committed
feat: add todomvc
1 parent af29a9d commit f644c8d

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

src/App.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<template>
22
<div id="app">
3-
<h1>Hello!</h1>
4-
<Congratulations />
3+
<TodoMVC />
54
</div>
65
</template>
76

87
<script>
9-
import Congratulations from './components/Congratulations'
8+
import TodoMVC from './components/TodoMVC'
109
1110
export default {
1211
name: 'App',
1312
components: {
14-
Congratulations
13+
TodoMVC
1514
},
1615
data() {
1716
return {

src/components/TodoMVC.vue

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<script>
2+
export default {
3+
data() {
4+
return {
5+
taskList: [],
6+
userInput: ''
7+
}
8+
},
9+
methods: {
10+
addTask(event) {
11+
if (event.key === 'Enter') {
12+
this.taskList.push({
13+
description: this.userInput,
14+
complete: false
15+
})
16+
this.userInput = ''
17+
}
18+
}
19+
}
20+
}
21+
</script>
22+
23+
<template>
24+
<h1>TodoMVC</h1>
25+
<input
26+
type="text"
27+
placeholder="Enter task"
28+
v-model="userInput"
29+
@keyup="addTask"
30+
/>
31+
<p>X items left</p>
32+
{{ taskList }}
33+
<h2>All Tasks</h2>
34+
<ul class="task-list">
35+
<li v-for="(task, index) in taskList" :key="`task-${index}`">
36+
<input type="checkbox" v-model="task.complete" />{{ task.description }}
37+
</li>
38+
</ul>
39+
<h2>Active Tasks</h2>
40+
<h2>Completed Tasks</h2>
41+
<button>Clear all tasks</button>
42+
</template>
43+
44+
<style>
45+
input[type='text'] {
46+
padding: 1.5rem;
47+
font-size: 1.5rem;
48+
width: 50%;
49+
}
50+
51+
.task-list {
52+
display: flex;
53+
flex-direction: column;
54+
justify-content: center;
55+
align-items: center;
56+
}
57+
58+
.task-list li {
59+
list-style: none;
60+
width: 200px;
61+
text-align: left;
62+
}
63+
</style>

0 commit comments

Comments
 (0)