git ssb

2+

mixmix / ticktack



Tree: f6a16e3fc5c25cadd2445d141a36a91d964a1813

Files: f6a16e3fc5c25cadd2445d141a36a91d964a1813 / app / html / header.js

1381 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 => {
26 if (typeof location != 'object') return {}
27
28 return location.location || {}
29 })
30 // Dominics nav location api is slightly different than mine - it nest location in nav.location.location
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