add list item as separate element

This commit is contained in:
Alexey Pavlenko 2020-05-19 18:58:38 +03:00 committed by Alexander Alemayhu
parent 09d9676c1e
commit a31c432f5e
2 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import {vbox, completed} from './styles/index.css' import {vbox, completed} from './styles/index.css'
import { List } from './item-list'
var store = { var store = {
title: "" title: ""
@ -15,16 +16,11 @@ tag App
data:items.push(title: data:title) data:items.push(title: data:title)
data:title = "" data:title = ""
def completeItem item
console.log "clicked,{item:completed}"
item:completed = !item:completed
def render def render
<self.{vbox}> <self.{vbox}>
<header> <header>
<input[data:title] placeholder="New..." :keyup.enter.addItem> <input[data:title] placeholder="New..." :keyup.enter.addItem>
<button :tap.addItem> 'Add item' <button :tap.addItem> 'Add item'
<ul> for item in data:items <List list=data:items>
<li .{item:completed and completed} :tap.completeItem(item)> item:title
Imba.mount <App[store]> Imba.mount <App[store]>

11
src/item-list.imba Normal file
View File

@ -0,0 +1,11 @@
export tag List
prop list
def completeItem item
console.log "clicked,{item:completed}"
item:completed = !item:completed
def render
<self>
<ul> for item in list
<li .{item:completed} :tap.completeItem(item)> item:title