Permalink
Browse files

refactor: update to use new decorator

  • Loading branch information...
kt3k committed Nov 29, 2018
1 parent 20f92ee commit 274c5586da8c1bed5f78114899c9c390810fe7f5
Showing with 7,161 additions and 2,326 deletions.
  1. +7,008 −2,237 dist/app.js
  2. +1 −0 karma.conf.js
  3. +8 −6 package.json
  4. +1 −1 src/component/edit.js
  5. +6 −6 src/component/footer.js
  6. +2 −2 src/component/main.js
  7. +1 −1 src/component/new-todo.js
  8. +5 −5 src/component/todo-item.js
  9. +2 −1 src/component/todo-list.js
  10. +3 −2 src/service/router.js
  11. +4 −1 src/service/todoapp.js
  12. +120 −64 yarn.lock
9,245 dist/app.js

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -14,6 +14,7 @@ module.exports = config =>
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-class-properties',
'istanbul'
]
}
@@ -23,17 +23,18 @@
"author": "Yoshiya Hinosawa <stibium121@gmail.com> (https://twitter.com/kt3k)",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.6",
"@babel/preset-env": "^7.0.0",
"babel-eslint": "^10.0.0",
"babel-plugin-istanbul": "^5.0.1",
"babelify": "^10.0.0",
"browserify": "^16.0.0",
"capsid": "^0.27.0",
"capsid": "^0.28.1",
"chai": "^4.1.0",
"codecov": "^3.0.0",
"hash-route": "^1.1.1",
"hash-route": "^2.0.3",
"husky": "^1.0.0",
"karma": "^3.0.0",
"karma-browserify": "^5.3.0",
@@ -60,9 +61,10 @@
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
"decoratorsBeforeExport": false
}
]
],
"@babel/plugin-proposal-class-properties"
]
},
"lint-staged": {
@@ -7,7 +7,7 @@ const { emits, on, component } = require('capsid')
/**
* TodoEdit controls the edit area of each todo item.
*/
@component
@component('edit')
class Edit {
onStart () {
this.el.focus()
@@ -4,22 +4,22 @@ const {
} = require('../const')
const { on, emits, wired, component } = require('capsid')

@component
@component('footer')
class Footer {
@wired('.clear-completed')
get clearCompletedButton () {}
clearCompletedButton

@wired('a[href="#/active"]')
get activeFilterButton () {}
activeFilterButton

@wired('a[href="#/completed"]')
get completedFilterButton () {}
completedFilterButton

@wired('a[href="#/"]')
get allFilterButton () {}
allFilterButton

@wired('.todo-count')
get todoCountLabel () {}
todoCountLabel

@on('click', { at: '.clear-completed' })
@emits(CLEAR_COMPLETED)
@@ -3,10 +3,10 @@ const {
} = require('../const')
const { component, wired, emits, on } = require('capsid')

@component
@component('main')
class Main {
@wired('.toggle-all')
get toggleAllButton () {}
toggleAllButton

@on('click', { at: '.toggle-all' })
@emits(TOGGLE_ALL)
@@ -10,7 +10,7 @@ const { emits, on, component } = require('capsid')
/**
* TodoInput class controls the input for adding todos.
*/
@component
@component('new-todo')
class NewTodo {
/**
* Handler for key presses.
@@ -7,16 +7,16 @@ const { on, emits, prep, wired, component } = require('capsid')
/**
* TodoItem class controls todo item in a list.
*/
@component
@component('todo-item')
class TodoItem {
@wired('label')
get label () {}
label

@wired('.toggle')
get toggle () {}
toggle

@wired.component
get edit () {}
@wired.component('edit')
edit

__mount__ () {
this.el.innerHTML = `
@@ -6,14 +6,15 @@ const { component, get, make, on } = require('capsid')
/**
* The todo list component.
*/
@component
@component('todo-list')
class TodoList {
/**
* Updates the todo items by the given todo model list.
* @param {TodoCollection} todos The todo list
*/
@on(MODEL_UPDATE)
onRefresh ({ detail: { todoCollection, filter } }) {
console.log('onRefresh')
const visibleTodos = todoCollection.filterBy(filter)

if (this.shouldResetContents(filter, visibleTodos)) {
@@ -10,9 +10,10 @@ const { component, emits } = require('capsid')
/**
* The observer of the filter and invokes filterchange event when it's changed.
*/
@component
@component('router')
class Router {
onHashchange () {
console.log('onHashChange')
dispatch(this)
}

@@ -36,7 +37,7 @@ class Router {

@route
@emits(CHANGE_FILTER)
'*' () {
'(.*)' () {
return Filter.ALL
}
}
@@ -18,7 +18,7 @@ const { notifies, make, on, component } = require('capsid')
/**
* The todo application class.
*/
@component
@component('todoapp')
class Todoapp {
__mount__ () {
this.todoFactory = new Todo.Factory()
@@ -39,11 +39,14 @@ class Todoapp {
save () {
this.todoRepository.saveAll(this.todoCollection)

console.log(this)

return this
}

@on(CHANGE_FILTER)
onFilterchange ({ detail: filter }) {
console.log('onFilterChange')
this.filter = filter
this.save()
}
Oops, something went wrong.

0 comments on commit 274c558

Please sign in to comment.