git ssb

2+

mixmix / ticktack



Tree: 162122b46e57bbd1cb6ff6774e6b40502586e89b

Files: 162122b46e57bbd1cb6ff6774e6b40502586e89b / app / html / header.js

1202 bytesRaw
1const nest = require('depnest')
2const { h, computed, when } = require('mutant')
3const get = require('lodash/get')
4const path = require('path')
5
6exports.gives = nest('app.html.header')
7
8exports.needs = nest('keys.sync.id', 'first')
9
10const SETTINGS_PAGES = [
11 'settings',
12 'userEdit',
13]
14
15exports.create = (api) => {
16 return nest('app.html.header', (nav) => {
17 const { location, push } = nav
18
19 const loc = computed(location, location => {
20 if (typeof location != 'object') return {}
21
22 return location || {}
23 })
24
25 const isSettings = computed(loc, loc => {
26 return SETTINGS_PAGES.includes(loc.page)
27 })
28
29 const isFeed = computed([isSettings], isSettings => !isSettings)
30
31 return h('Header', [
32 h('nav', [
33 h('img.feed', {
34 src: when(isFeed, assetPath('feed_on.png'), assetPath('feed.png')),
35 'ev-click': () => push({page: 'blogIndex'}),
36 }),
37 h('img.feed', {
38 src: when(isSettings, assetPath('settings_on.png'), assetPath('settings.png')),
39 'ev-click': () => push({page: 'settings'})
40 }),
41 ]),
42 ])
43 })
44}
45
46function assetPath (name) {
47 return path.join(__dirname, '../../assets', name)
48}
49
50

Built with git-ssb-web