Skip to content

Instantly share code, notes, and snippets.

@NovoManu
Last active August 18, 2019 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NovoManu/6f63454030ed53297641d3f5287eb900 to your computer and use it in GitHub Desktop.
Save NovoManu/6f63454030ed53297641d3f5287eb900 to your computer and use it in GitHub Desktop.
<template>
<div>
<Header listName="My new todo list" />
<main>
<TodoList>
<!--<TodoCard-->
<!--v-for="{ id, title, completed } in todos"-->
<!--:key="id"-->
<!--:title="title"-->
<!--:completed="completed"-->
<!--/>-->
<TodoRow
v-for="{ id, title, completed } in todos"
:key="id"
:id="id"
:title="title"
:completed="completed"
/>
</TodoList>
</main>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { ITodo } from '@/types'
import { Api } from '@/api/api'
import Header from '@/components/Header.vue'
import TodoList from '@/components/TodoList.vue'
import TodoCard from '@/components/TodoCard.vue'
import TodoRow from '@/components/TodoRow.vue'
@Component({
components: { Header, TodoList, TodoCard, TodoRow }
})
export default class Home extends Vue {
todos: ITodo[] = []
async mounted() {
this.todos = await this.fetch()
}
async fetch(): Promise<ITodo[]> {
const api = new Api()
return await api.fetch('todos')
}
}
</script>
<style lang="scss">
.container {
padding: 1.5rem;
}
</style>
<template functional>
<div class="todo-list__task">
<span :class="{ 'todo-list__task--completed': props.completed }">
{{ props.title }}
</span>
</div>
</template>
<style lang="scss" scoped>
.todo-list {
&__task {
width: 24%;
padding: 1.5rem;
margin: 0.5%;
text-align: left;
color: #4169e1;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
&:hover {
box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25),
0 10px 10px rgba(0, 0, 0, 0.22);
}
&--completed {
color: #2e8b57;
text-decoration: line-through;
}
}
}
</style>
<template functional>
<div class="todo-list__row">
<span>{{ props.id }}: </span>
<span :class="{ 'todo-list__row--completed': props.completed }">{{
props.title
}}</span>
</div>
</template>
<style lang="scss">
.todo-list {
&__row {
width: 100%;
text-align: left;
color: #4169e1;
&--completed {
text-decoration: line-through;
color: #2e8b57;
}
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment