git ssb

2+

mixmix / ticktack



Tree: e421e6f554c1320df904394b27f186dbdac65de5

Files: e421e6f554c1320df904394b27f186dbdac65de5 / app / html / sideNav / sideNavNotifications.js

1695 bytesRaw
1const nest = require('depnest')
2const { h, computed } = require('mutant')
3
4exports.gives = nest({
5 'app.html.sideNav': true
6})
7
8exports.needs = nest({
9 'history.sync.push': 'first',
10 'translations.sync.strings': 'first'
11})
12
13const SECTIONS = ['comments', 'likes', 'shares']
14
15const ICONS = {
16 stats: 'bar-chart',
17 comments: 'commenting-o',
18 likes: 'heart-o',
19 shares: 'share-alt'
20}
21
22exports.create = (api) => {
23 return nest({
24 'app.html.sideNav': sideNav
25 })
26
27 function sideNav (location) {
28 if (location.page !== 'statsShow' && location.page !== 'notifications') return
29 if (location.page === 'notifications' && !SECTIONS.includes(location.section)) return
30
31 const strings = api.translations.sync.strings()
32 const goTo = (loc) => () => api.history.sync.push(loc)
33
34 return h('SideNav -notifications', [
35 LevelOneSideNav()
36 ])
37
38 function LevelOneSideNav () {
39 return h('div.level.-one', [
40 h('section', [
41 h('Option',
42 {
43 className: location.page === 'statsShow' ? '-selected' : '',
44 'ev-click': goTo({page: 'statsShow'})
45 },
46 [
47 h('i.fa', { className: `fa-${ICONS['stats']}` }),
48 strings['stats']
49 ]
50 ),
51 SECTIONS.map(section => SectionOption(section))
52 ])
53 ])
54 }
55
56 function SectionOption (section) {
57 return h('Option',
58 {
59 className: location.section === section ? '-selected' : '',
60 'ev-click': goTo({page: 'notifications', section})
61 },
62 [
63 h('i.fa', { className: `fa-${ICONS[section]}` }),
64 strings[section]
65 ]
66 )
67 }
68 }
69}
70

Built with git-ssb-web