git ssb

2+

mixmix / ticktack



Tree: 856796486d48c7b494769019a74b9b843471ee41

Files: 856796486d48c7b494769019a74b9b843471ee41 / app / html / header.js

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

Built with git-ssb-web