CSS task
Invervue
by leomac
HTML
<div id="app" :class={loaded:data_is_loaded}>
<h2>Todo:</h2>
<ol class='tasks' >
<task-element v-for='task in todos' :task='task'></task-element>
</ol>
<h3>
Add new task:
</h3>
<input type='text'/>
<button>
Add task
</button>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
width: 250px;
border-bottom: 1px solid #ccc;
margin-bottom: 20px;
}
label.islong span::before {
content: "⌛";
}
div.loaded ol.tasks li span {
opacity: 1;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
Vue
Vue.component('task-element',{
props : ['task'],
data : function () {
var d = {seconds_elapsed: null};
return d;
},
template : `<li>
<label :class='{islong:task.islong}'>
<input type="checkbox"
v-on:change="toggle(task)"
v-bind:checked="task.done">
<span>
{{ task.text }}
</span>
<small>
{{ seconds_elapsed }}
</small>
</label>
</li>`,
});
new Vue({
el: "#app",
data: {
todos: [
{ text: "Learn JavaScript", done: false, islong: true},
{ text: "Learn Vue", done: false, islong: false},
{ text: "Play around in JSFiddle", done: true, islong: false},
{ text: "Build something awesome", done: true, islong: true}
],
data_is_loaded: true,
},
methods: {
toggle: function(todo){
todo.done = !todo.done
},
}
})