Files: efdfbffdb3fdf4473cb8506801af56d5a656f4d3 / app / html / header.js
1276 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 || {} |
30 | }) |
31 | |
32 | const isFeed = computed(loc, loc => { |
33 | return FEED_PAGES.includes(loc.page) || (loc.key && loc.feed) |
34 | }) |
35 | |
36 | const isSettings = computed(loc, loc => { |
37 | return SETTINGS_PAGES.includes(loc.page) |
38 | }) |
39 | |
40 | return h('Header', [ |
41 | h('nav', [ |
42 | h('i.fa', { |
43 | 'ev-click': () => push({page: 'blogIndex'}), |
44 | className: when(isFeed, 'fa-commenting', 'fa-commenting-o') |
45 | }), |
46 | h('i.fa', { |
47 | className: when(isSettings, 'fa-user', 'fa-user-o'), |
48 | 'ev-click': () => push({page: 'settings'}) |
49 | }) |
50 | ]), |
51 | ]) |
52 | }) |
53 | } |
54 |
Built with git-ssb-web