Skip to content

Instantly share code, notes, and snippets.

@synga
Created August 13, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synga/6ce05786d90df871bb52eabc8c1382df to your computer and use it in GitHub Desktop.
Save synga/6ce05786d90df871bb52eabc8c1382df to your computer and use it in GitHub Desktop.
import { Component, Prop, Event, EventEmitter, State } from '@stencil/core';
@Component({
tag: 'todo-item',
styleUrl: "todo-item.css"
})
export class TodoItem {
@Prop() posicao: number;
@Prop() descricao: string;
@State() feito: boolean = false;
@Event() excluiItem: EventEmitter;
@Event() marcaFeito: EventEmitter
excluirTarefas = () => this.excluiItem.emit(this.posicao);
tarefaConcluida = () => {
this.feito = !this.feito;
this.marcaFeito.emit({ pos: this.posicao, feito: this.feito });
}
render() {
return (
<div class="tarefa">
<div>
<input type="checkbox" class="tarefa--alterar" checked={this.feito} onChange={() => this.tarefaConcluida()} />
<label class={`${this.feito ? 'concluido' : ''} tarefa--descricao`} onClick={() => this.tarefaConcluida()}>{this.descricao}</label>
</div>
<button class="tarefa--botao" onClick={() => this.excluirTarefas()}>&#215;</button>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment