Last active
April 22, 2016 14:36
-
-
Save abalmus/8b399dfdb80e31737923ab2ec979f87f to your computer and use it in GitHub Desktop.
Aurelia Todo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="./todo"></require> | |
<div class="page-host"> | |
<todo /> | |
</div> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging(); | |
aurelia.start().then(a => a.setRoot()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.completed { | |
text-decoration: line-through; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<ul> | |
<li repeat.for="todo of todos" click.delegate="toggleTodo(todo)"> | |
<span class="${todo.completed ? 'completed' : ''}"> | |
<span>${todo.id}</span> ${todo.title} | |
</span> | |
</li> | |
</ul> | |
</div> | |
<form action="" submit.delegate="addTodo($event)"> | |
<input type="text" value.bind="newTodoTitle"> | |
<button type="submit">Add Todo</button> | |
</form> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {TodoItem} from './TodoItem'; | |
export class Todo { | |
todos = []; | |
newTodoTitle; | |
addTodo(e) { | |
e.preventDefault(); | |
if (this.newTodoTitle) { | |
this.todos.push(new TodoItem(this.newTodoTitle)); | |
} | |
} | |
toggleTodo(todo) { | |
todo.toggle(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nextTodoId = 0; | |
export class TodoItem { | |
constructor(title) { | |
this.id = nextTodoId++; | |
this.title = title; | |
this.completed = false; | |
} | |
toggle() { | |
this.completed = !this.completed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment