You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pastebin/App.js

36 lines
1.4 KiB
JavaScript

import Note from './Note.js';
import {new_note_handler, search_term_change_handler, sorting_change_handler, load_notes} 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'}, 'New Bin...')
])
]),
m('.main', {key: 'main'}, [
m('.notes', s.notes.map(note_state =>
m(Note, {note_state, dispatch, key: note_state.note.id})
))
])
]);
}
};
}
export default App;