diff --git a/src/components/input.js b/src/components/input.js
new file mode 100644
index 0000000..25ee108
--- /dev/null
+++ b/src/components/input.js
@@ -0,0 +1,20 @@
+import React from 'react';
+
+
+class Input extends React.Component {
+
+ read(e){
+ this.props.update(this.props.id, e.target.value)
+ }
+
+ render(){
+ switch (this.props.type) {
+ case 'submit':
+ return
+ default:
+ return
+ }
+ }
+}
+
+export default Input;
diff --git a/src/components/task.js b/src/components/task.js
deleted file mode 100644
index 4cf9e10..0000000
--- a/src/components/task.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from 'react';
-
-function Task(props) {
- let s = "width:" + props.progress + "%"
- return (
-
- )
-}
-
-export default Task;
diff --git a/src/db/index.js b/src/db/index.js
new file mode 100644
index 0000000..4bb58d2
--- /dev/null
+++ b/src/db/index.js
@@ -0,0 +1,35 @@
+var TaskDb = [
+ {
+ 'lable': "some stuff",
+ 'progress': 0.5
+ },{
+ 'lable': "some other stuff",
+ 'progress': 0.2
+ },{
+ 'lable': "fun stuff",
+ 'progress': 0.75
+ },
+]
+
+class Database{
+ getTasks(){
+ return TaskDb;
+ }
+
+ addTask(task){
+ TaskDb.push(task);
+ }
+
+ updateTask(id, task){
+ TaskDb[id] = task
+ }
+
+ removeTask(id){
+ for(let i=id+1; i
+
+
+
diff --git a/src/res/trash.svg b/src/res/trash.svg
new file mode 100644
index 0000000..0368dcb
--- /dev/null
+++ b/src/res/trash.svg
@@ -0,0 +1,35 @@
+
+
+
+
diff --git a/src/styles/App.css b/src/styles/App.css
index 61c6824..63a1a2e 100644
--- a/src/styles/App.css
+++ b/src/styles/App.css
@@ -6,6 +6,32 @@
--dark-3-color: #444;
}
+
+input{
+ background: none transparent;
+ border: none;
+ border-bottom: var(--dark-3-color) 1px solid;
+ color: white;
+ text-align: center;
+ height: 30px;
+ width: calc(100% - 50px);
+ margin: 5px 25px;
+}
+input[type=text] {
+ cursor: text;
+}
+input[type=submit] {
+ cursor: pointer;
+}
+input[type=submit]:hover{
+ background-color: var(--primary-color);
+ border-radius: 7px;
+}
+
+
+html{
+ background-color: var(--dark-2-color);
+}
body{
padding-top: 75px;
color: white;
@@ -33,10 +59,6 @@ header h1 {
vertical-align: middle;
}
-main{
- background-color: var(--dark-2-color);
-}
-
.task-container {
background-color: var(--dark-1-color);
width: 100%;
@@ -46,6 +68,16 @@ main{
margin: 0 0 3px 0;
}
+.task-container.add {
+ justify-content: center;
+ flex-direction: column;
+ min-height: 50px;
+ height: auto;
+}
+.task-container.adding {
+ padding: 0 0 10px 0;
+}
+
.task-progress{
position: relative;
background-color: var(--primary-color);
@@ -59,3 +91,13 @@ main{
position: absolute;
width: 100%
}
+
+.task-trash{
+ position: absolute;
+ right: 10px;
+ height: 30px;
+}
+
+.task-add{
+ height: 30px;
+}
diff --git a/src/tasks.js b/src/tasks.js
index 15eb39f..968035e 100644
--- a/src/tasks.js
+++ b/src/tasks.js
@@ -1,40 +1,109 @@
import React from 'react'
-import Task from './components/task'
+import Database from './db'
-var tasks = [
- {
- 'lable': "some stuff",
- 'progress': 0.5
- },{
- 'lable': "some other stuff",
- 'progress': 0.2
- },{
- 'lable': "fun stuff",
- 'progress': 0.75
- },
-]
+import Input from './components/input'
+
+import trashSvg from './res/trash.svg';
+import addSvg from './res/add.svg'
+
+var db = new Database();
+
+function Details(props){
+ if(!props.display) return ""
+
+ let ret = []
+ let keys = Object.keys(props.task)
+ for(let i in Object.keys(props.task)){
+ let key = keys[i]
+ console.log(key, props.task[key])
+ ret.push({key})
+ ret.push({props.task[key]})
+ }
+ return {ret}
+}
class Tasks extends React.Component {
constructor(props){
super(props);
- this.state = tasks;
+ this.state = {
+ tasks: db.getTasks(),
+ add: false,
+ details: -1, // -1 meens don't show details of eny task
+ };
+ this.form = {};
}
-
updateFromDB() {
- this.setState(tasks);
+ this.state.tasks = db.getTasks();
+ this.setState(this.state);
}
- renderOne(task){
- return
+ trash(id, e){
+ db.removeTask(id);
+ this.updateFromDB();
+ }
+ add(e){
+ this.state.add = true;
+ this.state.details = -1;
+ this.setState(this.state);
+ }
+ focus(id, e){
+ this.state.add = false;
+ this.state.details = id;
+ this.setState(this.state);
+ }
+
+ renderTask(task, id){
+ let classes = "task-container"
+ if(this.state.details == id) classes += " focus"
+
+ let progress = (task.progress*100) + "%"
+
+ return (
+
+
+
{task.lable}
+

+
+
+ )
+ }
+
+ valueUpdate(key, value){
+ this.form[key] = value
+ }
+
+ addSubmit(){
+ db.addTask({
+ lable: this.form['lable'],
+ progress: 0
+ })
+ this.updateFromDB()
+ }
+
+ renderAdd(){
+ if(this.state.add === false)
+ return (
+
+

+
+ )
+
+ return (
+
+
+
+
+ )
}
render() {
let tasks = []
- for(let i=0; i