Fixed minor things, cleaned up some code
This commit is contained in:
parent
72f38c1137
commit
3b0dce6fbe
@ -54,6 +54,9 @@ export function State() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO a proper Prop-decorator
|
||||
export {State as Prop};
|
||||
|
||||
|
||||
/**
|
||||
* This CustomElement class is to avoid having to do an ugly workaround in every custom-element:
|
||||
|
||||
@ -26,7 +26,6 @@ export class MyTodo extends CustomElement{
|
||||
{this.todos.map(item =>
|
||||
<todo-item
|
||||
model={ item.id }
|
||||
text={item.text}
|
||||
checked={ item.checked }
|
||||
>
|
||||
{ item.text }
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {defineElement, render, CustomElement, Host} from "../../../packages/csx-custom-elements";
|
||||
import {defineElement, render, CustomElement, Host, State} from "../../../packages/csx-custom-elements";
|
||||
import style from './todo-input.scss';
|
||||
|
||||
@defineElement('todo-input')
|
||||
export class TodoInput extends CustomElement{
|
||||
value = "";
|
||||
@State() value = "";
|
||||
|
||||
render(){
|
||||
return (
|
||||
@ -27,7 +27,7 @@ export class TodoInput extends CustomElement{
|
||||
this.dispatchEvent(new CustomEvent('submit', {
|
||||
detail: this.value
|
||||
}));
|
||||
this.state = "";
|
||||
this.value = "";
|
||||
};
|
||||
handleInput = ({target: {value}})=>{
|
||||
this.value = value;
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import {defineElement, render, CustomElement, Host, ShadowDOM, State} from "../../../packages/csx-custom-elements";
|
||||
import {defineElement, render, CustomElement, Host, ShadowDOM, State, Prop} from "../../../packages/csx-custom-elements";
|
||||
import style from './todo-item.scss';
|
||||
|
||||
@defineElement('todo-item')
|
||||
export class TodoItem extends CustomElement{
|
||||
@State() checked = false;// TODO annotate as prop instead of state (attribute)
|
||||
@State() model; // TODO annotate as prop instead of state
|
||||
@State() text;
|
||||
@Prop() checked = false;
|
||||
@Prop() model;
|
||||
|
||||
render(){
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user