Added drag and drop

This commit is contained in:
2019-05-28 16:22:59 +03:00
commit 7b210b25f2
13 changed files with 11760 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

5
babel.config.js Normal file
View File

@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}

11475
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

50
package.json Normal file
View File

@@ -0,0 +1,50 @@
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^2.6.5",
"emoji-mart-vue": "^2.6.6",
"uuid": "^3.3.2",
"vue": "^2.6.10",
"vue-emoji-picker": "^1.0.1",
"vuedraggable": "^2.21.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.8.0",
"@vue/cli-plugin-eslint": "^3.8.0",
"@vue/cli-service": "^3.8.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

17
public/index.html Normal file
View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>ToDo List</title>
</head>
<body>
<noscript>
<strong>We're sorry but ToDo List doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

64
src/App.vue Normal file
View File

@@ -0,0 +1,64 @@
<template>
<div id="app">
<Header />
<AddTodo v-on:add-todo="addTodo"/>
<Todos v-bind:todos="todos" v-on:del-todo="deleteTodo" />
</div>
</template>
<script>
import uuid from 'uuid'
import Header from "./components/layout/Header";
import Todos from "./components/Todos";
import AddTodo from "./components/AddTodo";
export default {
name: 'app',
components: {
Header,
Todos,
AddTodo
},
data() {
return {
todos: [
{
id: uuid.v4(),
name: "Что-то, что я собираюсь сделать",
completed: false
},
{
id: uuid.v4(),
name: "Что-то, что я уже сделал",
completed: true
}
]
}
},
methods: {
deleteTodo(id) {
this.todos = this.todos.filter(todo => todo.id !== id);
},
addTodo(n) {
(n !== '' & n !== ' ') && this.todos.push({
id: uuid.v4(),
name: n,
completed: false
})
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Oswald&display=swap');
#app {
font-family: 'Oswald', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: ;
margin-top: 50px;
}
</style>

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,53 @@
<template>
<div>
<form autocomplete="off" @submit.prevent="$emit('add-todo', inputName); inputName = '';" class="addTodo">
<input type="text" v-model="inputName" name="title" placeholder="Название дела..." class="txtField">
<input type="submit" value="Добавить" class="btn">
</form>
</div>
</template>
<script>
export default {
name: "AddTodo",
data() {
return {
inputName: ''
}
}
}
</script>
<style scoped>
.addTodo {
width: 400px;
height: 30px;
margin: auto;
text-align: left;
}
.txtField {
font-family: 'Oswald', sans-serif;
width: 300px;
float: left;
border-width: 0px;
border-bottom-width: 1px;
height: 30px;
font-size: 16px;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.btn {
font-family: 'Oswald', sans-serif;
float: right;
font-size: 16px;
border: 0ch;
height: 30px;
width: 90px;
background: black;
color: white;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
</style>

View File

@@ -0,0 +1,41 @@
<template>
<div class="todo-item" v-bind:class='{"is-complete":todo.completed}' v-on:click="markComplete">
<p>
{{todo.name}}
<button @click="$emit('del-todo', todo.id)" class="delete">&#10060;</button>
</p>
</div>
</template>
<script>
export default {
name: "TodoItem",
props: ["todo"],
methods: {
markComplete() {
this.todo.completed = !this.todo.completed
}
}
}
</script>
<style scoped>
.todo-item {
margin: auto;
text-align: left;
width: 400px;
cursor: pointer;
font-weight: Regular;
}
.is-complete {
text-decoration: line-through;
}
.delete {
float: right;
border: none;
background-color: Transparent;
cursor: pointer;
}
</style>

31
src/components/Todos.vue Normal file
View File

@@ -0,0 +1,31 @@
<template>
<draggable v-model="todos" group="people" @start="drag=true" @end="drag=false">
<div v-bind:key="todo.id" v-for="todo in todos">
<TodoItem v-bind:todo="todo" v-on:del-todo="$emit('del-todo', todo.id)" />
</div>
</draggable>
</template>
<script>
import draggable from 'vuedraggable'
import TodoItem from "./TodoItem.vue";
export default {
name: "Todos",
components: {
draggable,
TodoItem
},
props: ["todos"],
methods: {
moveItem(from, to) {
this.todos.splice(to, 0, this.todos[from]);
this.todos[from] = null;
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,15 @@
<template>
<header class="header">
<h1>Мои Дела &#128221;</h1>
</header>
</template>
<script>
export default {
name: "Header"
}
</script>
<style scoped>
</style>

8
src/main.js Normal file
View File

@@ -0,0 +1,8 @@
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')