Files: a48b8e932c4ae4ce8ffaf7d73f6a8ab26057700c / modules_core / menu.js
904 bytesRaw
1 | const h = require('hyperscript') |
2 | |
3 | module.exports = { |
4 | needs: { |
5 | menu_items: 'map' |
6 | }, |
7 | gives: { |
8 | connection_status: true, |
9 | menu: true, |
10 | menu_items: true |
11 | }, |
12 | create: function (api) { |
13 | const { menu_items } = api |
14 | |
15 | var status = h('div.status.error') //start off disconnected |
16 | var list = h('div.menu.column', {style: 'display: none;'}) |
17 | |
18 | var menu = h('div.column', { |
19 | onmouseover: () => list.style.display = 'flex', |
20 | onmouseout: () => list.style.display = 'none' |
21 | }, [ |
22 | status, |
23 | list |
24 | ]) |
25 | |
26 | setTimeout(function () { |
27 | menu_items().forEach(function (el) { |
28 | if(el) |
29 | list.appendChild(el) |
30 | }) |
31 | }, 0) |
32 | |
33 | return { |
34 | connection_status: (err) => { |
35 | if(err) status.classList.add('error') |
36 | else status.classList.remove('error') |
37 | }, |
38 | menu: () => menu, |
39 | menu_items: () => null |
40 | } |
41 | } |
42 | } |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 |
Built with git-ssb-web