-
Notifications
You must be signed in to change notification settings - Fork 29
/
Main.js
66 lines (63 loc) · 2.01 KB
/
Main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const h = require('react-hyperscript')
const {observer} = require('mobx-react')
const {loadUser} = require('./state')
const state = require('./state')
const log = require('./log')
module.exports = observer(() => {
return (
h('div', [
h('nav.nav', [
h('.nav-left', [
h('a.nav-item', {href: '#!/'}, [
h('img', {src: 'https://raw.githubusercontent.com/fiatjaf/coisas/master/icon.png'})
]),
h('a.nav-item', {href: '#!/'}, 'coisas')
]),
h('.nav-center', [
window.coisas.liveSiteURL
? h('a.nav-item', {
href: window.coisas.liveSiteURL,
title: window.coisas.liveSiteURL,
target: '_blank'
}, [
h('span.icon', [ h('i.fa.fa-external-link-square') ]),
'Live site'
])
: null,
state.slug.get()
? h('a.nav-item', {
href: `https://github.com/${state.slug.get()}`,
title: state.slug.get(),
target: '_blank'
}, [
h('span.icon', [ h('i.fa.fa-github-square') ]),
'Browse repository'
])
: null,
state.loggedUser.get()
? h('.nav-item', [
state.loggedUser.get(),
h('span', {style: {marginRight: '5px'}}, ', '),
h('a', {
onClick: () =>
window.coisas.authorizationRemove()
.then(loadUser)
}, 'logout')
])
: h('a.nav-item', {
onClick: () => {
window.coisas.authorizationInit()
.then(() => {
log.success('Got GitHub token and stored it locally.')
loadUser()
})
.catch(log.error)
}
}, 'authorize on GitHub')
])
]),
h(components[state.route.get().componentName])
])
)
})
const components = require('./components')