Files: f1afbfb0382d0d2375a5ca7ec9bc9b673a9bff84 / app / html / header.js
1311 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, when } = 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 | 'threadNew', |
14 | // 'blogSearch', |
15 | ] |
16 | const SETTINGS_PAGES = [ |
17 | 'settings', |
18 | 'userEdit', |
19 | ] |
20 | |
21 | exports.create = (api) => { |
22 | return nest('app.html.header', (nav) => { |
23 | const { location, push } = nav |
24 | |
25 | const loc = computed(location, location => location.location || {}) |
26 | // Dominics nav location api is slightly different than mine - it nest location in nav.location.location |
27 | |
28 | const isFeed = computed(loc, loc => { |
29 | return FEED_PAGES.includes(loc.page) || (loc.key && loc.feed) |
30 | }) |
31 | |
32 | const isSettings = computed(loc, loc => { |
33 | return SETTINGS_PAGES.includes(loc.page) |
34 | }) |
35 | |
36 | return h('Header', [ |
37 | h('nav', [ |
38 | h('i.fa', { |
39 | 'ev-click': () => push({page: 'blogIndex'}), |
40 | className: when(isFeed, 'fa-commenting', 'fa-commenting-o') |
41 | }), |
42 | h('i.fa', { |
43 | className: when(isSettings, 'fa-user', 'fa-user-o'), |
44 | 'ev-click': () => push({page: 'settings'}) |
45 | }) |
46 | ]), |
47 | ]) |
48 | }) |
49 | } |
50 |
Built with git-ssb-web