git ssb

2+

mixmix / ticktack



Tree: dfa8dcc1b8dc80fea753df44f2c9faa9c5eb88ef

Files: dfa8dcc1b8dc80fea753df44f2c9faa9c5eb88ef / app / html / header.js

1276 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 || {}
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