git ssb

2+

mixmix / ticktack



Tree: b820672852d31940a46c7ac613f5f5c0195f65b8

Files: b820672852d31940a46c7ac613f5f5c0195f65b8 / app / html / header.js

2238 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 h('i.fa.fa-bell', {
44 'ev-click': () => push({page: 'statsShow'})
45 })
46 ])
47 ])
48 })
49
50 function windowControls () {
51 if (process.platform === 'darwin') return
52
53 const window = remote.getCurrentWindow()
54 const minimize = () => window.minimize()
55 const maximize = () => {
56 if (!window.isMaximized()) window.maximize()
57 else window.unmaximize()
58 }
59 const close = () => window.close()
60
61 return h('div.window-controls', [
62 h('img.min', {
63 src: assetPath('minimize.png'),
64 'ev-click': minimize
65 }),
66 h('img.max', {
67 src: assetPath('maximize.png'),
68 'ev-click': maximize
69 }),
70 h('img.close', {
71 src: assetPath('close.png'),
72 'ev-click': close
73 })
74 ])
75 }
76}
77
78function assetPath (name) {
79 return path.join(__dirname, '../../assets', name)
80}
81
82

Built with git-ssb-web