git ssb

2+

mixmix / ticktack



Tree: f53d4720c0fe90f6e4f8f94d0f986812e6ca896b

Files: f53d4720c0fe90f6e4f8f94d0f986812e6ca896b / app / html / header.js

1521 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 const myKey = api.keys.sync.id()
19
20 const loc = computed(location, location => {
21 if (typeof location != 'object') return {}
22 return location
23 })
24
25 if (loc().page === 'splash') return
26
27 const isProfile = computed(loc, loc => loc.feed == myKey)
28 const isSettings = computed(loc, loc => SETTINGS_PAGES.includes(loc.page))
29
30 const isFeed = computed([isProfile, isSettings], (p, s) => !p && !s)
31
32 return h('Header', [
33 h('nav', [
34 h('img.feed', {
35 src: when(isFeed, assetPath('feed_on.png'), assetPath('feed.png')),
36 'ev-click': () => push({page: 'blogIndex'}),
37 }),
38 h('img.profile', {
39 src: when(isProfile, assetPath('address_bk_on.png'), assetPath('address_bk.png')),
40 'ev-click': () => push({page: 'userShow', feed: myKey})
41 }),
42 h('img.settings', {
43 src: when(isSettings, assetPath('settings_on.png'), assetPath('settings.png')),
44 'ev-click': () => push({page: 'settings'})
45 }),
46 ]),
47 ])
48 })
49}
50
51function assetPath (name) {
52 return path.join(__dirname, '../../assets', name)
53}
54
55

Built with git-ssb-web