import Note from './Note.js'; function App(){ const bin = {id: 'egf35'}; const notes = [ {id: 'aaa', text: 'Note one', modified: 1}, {id: 'bbb', text: 'Note two', modified: 1}, {id: 'ccc', text: 'Note three', modified: 1}, {id: 'ddd', text: 'Note four', modified: 1}, {id: 'eee', text: 'Note five', modified: 1}, {id: 'fff', text: 'Note six', modified: 1}, {id: 'ggg', text: 'Note seven', modified: 1}, {id: 'hhh', text: 'Note eight', modified: 1} ]; let search_term = ''; let count = 9; const new_note_handler = function(){ count++; // TODO: make immutable-style: notes.push({id: ''+count, text: '', modified: Date.now()}); }; const search_term_change_handler = function(e){ if(e.code === 'Enter'){ } else{ search_term = e.target.value; } }; const sorting_change_handler = function(){ }; return { view: function(vnode){ return m('.app', {key: 'app'}, [ m('.top', {key: 'top'}, [ m('.top-left', {key: 'top-left'}, [ m('button', {key: 'button', onclick: new_note_handler}, 'New Note...'), m('input.search', {key: 'search', value: search_term, onkeyup: search_term_change_handler}), m('select.sorting', {key: 'sorting', onchange: sorting_change_handler}, [ m('option', {key: 'new-old'}, 'Newest -> Oldest'), m('option', {key: 'old-new'}, 'Oldest -> Newest') ]) ]), m('.top-right', {key: 'top-right'}, [ m('.bin-id', {key: 'bin-id'}, bin.id), m('button', {key: 'new-bin-button'}, 'New Bin...') ]) ]), m('.main', {key: 'main'}, [ m('.notes', notes.map(note => m(Note, {note, key: note.id}) )) ]) ]); } }; } export default App;