git ssb

2+

mixmix / ticktack



Tree: b4bb2278fc6720ae4aa5470a30a66da315b74f00

Files: b4bb2278fc6720ae4aa5470a30a66da315b74f00 / app / html / header.js

2186 bytesRaw
1const nest = require('depnest')
2const { h, computed, when } = require('mutant')
3const get = require('lodash/get')
4const path = require('path')
5const { remote } = require('electron')
6
7exports.gives = nest('app.html.header')
8
9exports.needs = nest({
10 'keys.sync.id': 'first'
11})
12
13const SETTINGS_PAGES = [
14 'settings',
15 'userEdit',
16]
17
18exports.create = (api) => {
19 return nest('app.html.header', (nav) => {
20 const { location, push } = nav
21 const myKey = api.keys.sync.id()
22
23 const loc = computed(location, location => {
24 if (typeof location != 'object') return {}
25 return location
26 })
27
28 if (loc().page === 'splash') return
29
30 const window = remote.getCurrentWindow()
31 const minimize = () => window.minimize()
32 const maximize = () => {
33 if (!window.isMaximized()) window.maximize()
34 else window.unmaximize()
35 }
36 const close = () => window.close()
37
38 const isSettings = computed(loc, loc => SETTINGS_PAGES.includes(loc.page))
39 const isAddressBook = computed(loc, loc => loc.page === 'addressBook')
40 const isFeed = computed([isAddressBook, isSettings], (p, s) => !p && !s)
41
42 return h('Header', [
43 h('div.window-controls', [
44 h('img.min', {
45 src: assetPath('minimize.png'),
46 'ev-click': minimize
47 }),
48 h('img.max', {
49 src: assetPath('maximize.png'),
50 'ev-click': maximize
51 }),
52 h('img.close', {
53 src: assetPath('close.png'),
54 'ev-click': close
55 })
56 ]),
57 h('nav', [
58 h('img.feed', {
59 src: when(isFeed, assetPath('feed_on.png'), assetPath('feed.png')),
60 'ev-click': () => push({page: 'blogIndex'}),
61 }),
62 h('img.addressBook', {
63 src: when(isAddressBook, assetPath('address_bk_on.png'), assetPath('address_bk.png')),
64 'ev-click': () => push({page: 'addressBook'})
65 }),
66 h('img.settings', {
67 src: when(isSettings, assetPath('settings_on.png'), assetPath('settings.png')),
68 'ev-click': () => push({page: 'settings'})
69 }),
70 ]),
71 ])
72 })
73}
74
75function assetPath (name) {
76 return path.join(__dirname, '../../assets', name)
77}
78
79

Built with git-ssb-web