git ssb

2+

mixmix / ticktack



Tree: e39763f409d19a3fb6f6c9052dccd36946f8be25

Files: e39763f409d19a3fb6f6c9052dccd36946f8be25 / app / html / header.js

1394 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 'blogNew',
13 'threadShow', // TODO - this doesn't work (`threadSHow` isn't part of the location atm)
14 'threadNew',
15 // 'blogSearch',
16]
17const SETTINGS_PAGES = [
18 'settings',
19 'userEdit',
20]
21
22exports.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