git ssb

2+

mixmix / ticktack



Tree: 8c68dbb9a3b69a0cf0e0dd503ef059a873189cd5

Files: 8c68dbb9a3b69a0cf0e0dd503ef059a873189cd5 / app / html / header.js

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

Built with git-ssb-web