From 221465bd5e8e91bcda1d7b337ae5f2bdb87bc53e Mon Sep 17 00:00:00 2001 From: rnentjes Date: Sat, 29 Apr 2017 13:23:15 +0200 Subject: [PATCH] Todos --- src/main/kotlin/nl/astraeus/komp/todo/Todo.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/kotlin/nl/astraeus/komp/todo/Todo.kt b/src/main/kotlin/nl/astraeus/komp/todo/Todo.kt index a613dae..5316f18 100644 --- a/src/main/kotlin/nl/astraeus/komp/todo/Todo.kt +++ b/src/main/kotlin/nl/astraeus/komp/todo/Todo.kt @@ -1,10 +1,12 @@ package nl.astraeus.komp.todo import kotlinx.html.* +import kotlinx.html.js.onKeyPressFunction import kotlinx.html.js.section import nl.astraeus.komp.HtmlComponent import nl.astraeus.komp.Komp import org.w3c.dom.HTMLElement +import org.w3c.dom.events.KeyboardEvent import kotlin.browser.document /** @@ -18,12 +20,21 @@ class Todo(val dataId: String, val title: String, var completed: Boolean) class TodoApp: HtmlComponent() { val todos: List = ArrayList() + fun addTodo(todo: String) { + + } + override fun render(consumer: TagConsumer) = consumer.section(classes = "todoapp") { header(classes = "header") { h1 { + "todos" } input(classes = "new-todo") { placeholder = "What needs to be done?" autoFocus = true + onKeyPressFunction = { e -> + if (e is KeyboardEvent && e.keyCode == 13) { + //addTodo(e.target.value) + } + } } } section(classes = "main") {