-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: for v2 reap all the low hanging fruit
Implement improvements from GH https://github.com/MithrilJS/mithril.js/issues/2499#issuecomment-521182524.
- Loading branch information
1 parent
8f48822
commit a31eca6
Showing
4 changed files
with
89 additions
and
105 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
// js/views/footer-view.js | ||
import Data from '../models/Data'; | ||
|
||
function Footer(data, filter) { | ||
var amountCompleted = data.amountCompleted(); | ||
var amountActive = data.amountActive(); | ||
function Footer(initialVnode) { | ||
|
||
return m('footer.footer', | ||
[ | ||
return { | ||
view: vnode => { | ||
var filter = vnode.attrs.filter; | ||
var amountActive = Data.amountActive(); | ||
|
||
return m('footer.footer', | ||
[ | ||
m('span.todo-count', [ | ||
m('strong', amountActive), ' item' + (amountActive !== 1 ? 's' : '') + ' left' | ||
m('strong', amountActive), ' item' + (amountActive !== 1 ? 's' : '') + ' left' | ||
]), | ||
m('ul.filters', [ | ||
m('li', [ | ||
m(m.route.Link, { | ||
href: "/", | ||
class: filter === '' ? 'selected' : '' | ||
}, 'All') | ||
]), | ||
m('li', [ | ||
m(m.route.Link, { | ||
// config: m.route, | ||
href: "/active", | ||
class: filter === 'active' ? 'selected' : '' | ||
}, 'Active') | ||
]), | ||
m('li', [ | ||
m(m.route.Link, { | ||
href: "/completed", | ||
class: filter === 'completed' ? 'selected' : '' | ||
}, 'Completed') | ||
]) | ||
m('li', [ | ||
m(m.route.Link, { | ||
href: "/", | ||
class: filter === '' ? 'selected' : '' | ||
}, 'All') | ||
]), | ||
m('li', [ | ||
m(m.route.Link, { | ||
// config: m.route, | ||
href: "/active", | ||
class: filter === 'active' ? 'selected' : '' | ||
}, 'Active') | ||
]), | ||
m('li', [ | ||
m(m.route.Link, { | ||
href: "/completed", | ||
class: filter === 'completed' ? 'selected' : '' | ||
}, 'Completed') | ||
]) | ||
]), | ||
m('button.clear-completed', { | ||
onclick: () => data.clearCompleted(), | ||
onclick: () => Data.clearCompleted(), | ||
}, 'Clear completed') | ||
] | ||
); | ||
]) | ||
}, | ||
} | ||
}; | ||
|
||
export default Footer; |
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