Files: 7a422bfc032eaea6d5b1148c7b46aa5646ac80d2 / app / html / header.js
1095 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed } = require('mutant') |
3 | const get = require('lodash/get') |
4 | |
5 | exports.gives = nest('app.html.header') |
6 | |
7 | exports.needs = nest('keys.sync.id', 'first') |
8 | |
9 | const FEED_PAGES = [ |
10 | 'home', |
11 | 'blogIndex', |
12 | 'threadShow', // TODO - this doesn't work (`threadSHow` isn't part of the location atm) |
13 | // 'blogSearch', |
14 | // 'threadShow', |
15 | // 'threadNew', |
16 | ] |
17 | const SETTINGS_PAGES = [ |
18 | 'settings', |
19 | 'userEdit', |
20 | ] |
21 | |
22 | exports.create = (api) => { |
23 | return nest('app.html.header', (nav) => { |
24 | const { location, push } = nav |
25 | const currentPage = computed(location, loc => get(loc, 'location.page')) |
26 | |
27 | return h('Header', [ |
28 | h('nav', [ |
29 | h('i.fa', { |
30 | 'ev-click': () => push({page: 'blogIndex'}), |
31 | className: computed(currentPage, page => FEED_PAGES.includes(page) ? 'fa-commenting' : 'fa-commenting-o') |
32 | }), |
33 | h('i.fa', { |
34 | className: computed(currentPage, page => SETTINGS_PAGES.includes(page) ? 'fa-user' : 'fa-user-o'), |
35 | 'ev-click': () => push({page: 'settings'}) |
36 | }) |
37 | ]), |
38 | ]) |
39 | }) |
40 | } |
41 |
Built with git-ssb-web