Files: 5f59445f9e468790a0106acff65bdd3ce873c37a / app / html / header.js
1043 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 SETTINGS_PAGES = [ |
10 | 'settings', |
11 | 'userEdit', |
12 | ] |
13 | |
14 | exports.create = (api) => { |
15 | return nest('app.html.header', (nav) => { |
16 | const { location, push } = nav |
17 | |
18 | const loc = computed(location, location => { |
19 | if (typeof location != 'object') return {} |
20 | |
21 | return location || {} |
22 | }) |
23 | |
24 | const isSettings = computed(loc, loc => { |
25 | return SETTINGS_PAGES.includes(loc.page) |
26 | }) |
27 | |
28 | const isFeed = computed([isSettings], isSettings => !isSettings) |
29 | |
30 | return h('Header', [ |
31 | h('nav', [ |
32 | h('i.fa', { |
33 | 'ev-click': () => push({page: 'blogIndex'}), |
34 | className: when(isFeed, 'fa-commenting', 'fa-commenting-o') |
35 | }), |
36 | h('i.fa', { |
37 | className: when(isSettings, 'fa-user', 'fa-user-o'), |
38 | 'ev-click': () => push({page: 'settings'}) |
39 | }) |
40 | ]), |
41 | ]) |
42 | }) |
43 | } |
44 |
Built with git-ssb-web