git ssb

2+

mixmix / ticktack



Tree: 1399cedf6a9c2dcf4b6662bdeb010225320af71c

Files: 1399cedf6a9c2dcf4b6662bdeb010225320af71c / app / html / header.js

1311 bytesRaw
1const nest = require('depnest')
2const { h, computed, when } = require('mutant')
3const get = require('lodash/get')
4
5exports.gives = nest('app.html.header')
6
7exports.needs = nest('keys.sync.id', 'first')
8
9const 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]
16const SETTINGS_PAGES = [
17 'settings',
18 'userEdit',
19]
20
21exports.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