import Note from './Note.js'; import {new_note_handler, search_term_change_handler, sorting_change_handler, load_notes, new_bin_handler} from './handlers/App.js'; function App(vnode_init){ const {state, dispatch} = vnode_init.attrs; //load_notes(state, dispatch); return { view: function(vnode){ const s = vnode.attrs.state; return m('.app', {key: 'app'}, [ m('.top', {key: 'top'}, [ m('.top-left', {key: 'top-left'}, [ m('button', {key: 'button', onclick: new_note_handler.bind(null, s, dispatch)}, 'New Note...'), m('input.search', {key: 'search', value: s.search_term, onkeyup: search_term_change_handler.bind(null, s, dispatch)}), m('select.sorting', {key: 'sorting', value: s.sorting, onchange: sorting_change_handler.bind(null, s, dispatch)}, [ m('option', {key: 'new->old', value: 'new->old'}, 'Newest -> Oldest'), m('option', {key: 'old->new', value: 'old->new'}, 'Oldest -> Newest') ]) ]), m('.top-right', {key: 'top-right'}, [ m('.bin-id', {key: 'bin-id'}, s.bin.id), m('button', {key: 'new-bin-button', onclick: new_bin_handler.bind(null, s, dispatch)}, 'New Bin...') ]) ]), m('.main', {key: 'main'}, [ m('.notes', s.notes.map(note_state => m(Note, {state, note_state, dispatch, key: note_state.note.id}) )) ]) ]); } }; } export default App;