Files: ed0d0518717fe16a686399588766fb35b3e6e37a / app / html / menu.js
778 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | |
4 | exports.gives = nest('app.html.menu') |
5 | |
6 | exports.needs = nest({ |
7 | 'app.html.menuItem': 'map', |
8 | 'app.sync.goTo': 'first' |
9 | }) |
10 | |
11 | exports.create = function (api) { |
12 | var _menu |
13 | |
14 | return nest('app.html.menu', function menu () { |
15 | if (_menu) return _menu |
16 | |
17 | const menuItems = api.app.html.menuItem(api.app.sync.goTo).map(item => { |
18 | // Remove custom order from dependencies that give app.html.menuItem |
19 | item.style.order = null |
20 | return item |
21 | }) |
22 | const sortedMenuItems = Object.values(menuItems).sort((a, b) => |
23 | a.text.localeCompare(b.text) |
24 | ) |
25 | |
26 | // TODO: move goTo out into each menuItem |
27 | _menu = h('i.Menu.fa.fa-bars', [ |
28 | h('div', sortedMenuItems) |
29 | ]) |
30 | |
31 | return _menu |
32 | }) |
33 | } |
34 |
Built with git-ssb-web