Files: 48dc57fc8ae627b623bd0e844841403c70e9e383 / app / html / header.js
1394 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 | 'blogNew', |
13 | 'threadShow', // TODO - this doesn't work (`threadSHow` isn't part of the location atm) |
14 | 'threadNew', |
15 | // 'blogSearch', |
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 | |
26 | const loc = computed(location, location => { |
27 | if (typeof location != 'object') return {} |
28 | |
29 | return location.location || {} |
30 | }) |
31 | // Dominics nav location api is slightly different than mine - it nest location in nav.location.location |
32 | |
33 | const isFeed = computed(loc, loc => { |
34 | return FEED_PAGES.includes(loc.page) || (loc.key && loc.feed) |
35 | }) |
36 | |
37 | const isSettings = computed(loc, loc => { |
38 | return SETTINGS_PAGES.includes(loc.page) |
39 | }) |
40 | |
41 | return h('Header', [ |
42 | h('nav', [ |
43 | h('i.fa', { |
44 | 'ev-click': () => push({page: 'blogIndex'}), |
45 | className: when(isFeed, 'fa-commenting', 'fa-commenting-o') |
46 | }), |
47 | h('i.fa', { |
48 | className: when(isSettings, 'fa-user', 'fa-user-o'), |
49 | 'ev-click': () => push({page: 'settings'}) |
50 | }) |
51 | ]), |
52 | ]) |
53 | }) |
54 | } |
55 |
Built with git-ssb-web