Vue
by Abner Rodrigues
HTML
<div id="app">
<h1 class="title">Piattino</h1>
<h2 class="subtitle">Teste Frontend</h2>
<hr />
<div class="saudacao">
<span>
Olá <img class="emoji-animated" src="https://cdn.joypixels.com/products/previews/O6D7BMG8R2DMMNC4LLZH/2411_HZWARHWk0TImR0UBwvuHRUXPorcBwWs1.gif"/>
<br />
</span>
<p>
Eu me chamo <b>{{ nome }}</b>
</p>
</div>
<hr />
<small>
Funcionalidade Secreta:
</small>
<div class="alert-box">
<button class="toggle-btn" @click="changeVisible()">
Clique aqui e veja algo incrível.
</button>
<div class="hidden-content" v-if="exibir">
<img class="emoji-animated" style="margin-left: 0;" src="https://cdn.joypixels.com/products/previews/O6D7BMG8R2DMMNC4LLZH/3148_0Zf7XssvjygbfIK0wUIrodM7C43tdOqc.gif"/> Aumente as suas vendas com a Piattino!
</div>
</div>
<hr />
<div class="container-newtask">
<input type="text" placeholder="Digite a tarefa" v-model="contentTask" @keyup.enter="newTodo(contentTask)" />
<button class="action-button" @click="newTodo(contentTask)">Nova Tarefa</button>
</div>
<ol>
<li v-for="todo in todos">
<label>
<input type="checkbox" v-on:change="toggle(todo)" v-bind:checked="todo.done">
<del v-if="todo.done">
{{ todo.text }}
</del>
<span v-else>
{{ todo.text }}
</span>
</label>
</li>
</ol>
<p class="content-counter">📉 Tarefas Concluídas: <span class="counter">{{ todoCount }}</span></p>
<div class="table-container">
<table>
<thead>
<tr>
<th></th>
<th>Tarefa</th>
<th>Status</th>
</tr>
</thead>
<tbody>
...
CSS
* {
box-sizing: border-box;
border: 0;
}
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
overflow-y: auto;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
display: flex;
justify-content: center;
flex-direction: column;
margin: auto;
max-width: 800px;
}
.title {
font-size: 48px;
color: #2D3748;
margin-bottom: 0;
}
.subtitle {
font-weight: 400;
color: #666;
border-bottom: 1px solid rgba(0, 0, 0, .1);
display: inline-block;
}
.saudacao {
font-size: 20px;
margin-bottom: 2em;
color: #2D3748;
}
.saudacao span {
display: flex;
align-items: center;
font-size: 30px;
font-weight: 600;
}
.emoji-animated {
width: 45px;
height: 45px;
margin-left: 10px;
}
.saudacao b {
border-bottom: 2px solid rgba(0, 0, 0, .7);
}
.alert-box {
background: #D6F6E5;
padding: 10px;
font-weight: 400;
color: #444;
border-radius: 3px;
font-size: 14px;
}
.hidden-content {
padding: 10px;
color: #000;
font-weight: 600;
font-size: 20px;
display: flex;
align-items: center;
}
.toggle-btn {
background: transparent;
width: 100%;
text-align: start;
cursor: pointer;
}
li {
display: flex;
align-items: center;
margin: 8px 0;
background: #f4f4f4;
margin: 5px;
padding: 10px 20px;
cursor: pointer;
}
li label {
display: flex;
align-items: center;
width: 100%;
}
h1,
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
.content-counter {
font-size: 18px;
color: #333;
text-align: center;
margin: 1em 0;
border-bottom: 1px solid #F2F4F6;
padding-bottom: 1em;
}
span.counter {
color: green;
}
.container-newtask {
display: flex;
align-items: center;
margin-bottom: 1em;
}
input[type="text"] {
background: #ffffff;
border: 1px solid...
Vue
new Vue({
el: "#app",
name: 'App',
data() {
return {
nome: 'Abner Rodrigues',
exibir: false,
contentTask: "",
todos: [
{text: "Aprender JavaScript", done: true},
{text: "Aprender Vue", done: false},
{text: "Fazer Testes no JSFiddle", done: false},
{text: "Construir algo incrível", done: true}
]
}
},
methods: {
toggle: function (todo) {
todo.done = !todo.done;
},
changeVisible() {
this.exibir = !this.exibir;
},
newTodo(text) {
if (text) {
this.todos.push({text: text, done: false});
this.contentTask = "";
} else alert("Informe a tarefa antes de continuar")
},
},
computed: {
todoCount: function () {
return this.todos.filter((filtro) => filtro.done === true).length;
},
exibir() {
return this.exibir;
},
}
})