git ssb

2+

mixmix / ticktack



Tree: 5831f345af34aebcc413b1b452dadcbf6244b419

Files: 5831f345af34aebcc413b1b452dadcbf6244b419 / app / html / topNav / topNavBlog.js

1849 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3
4exports.gives = nest('app.html.topNav')
5
6exports.needs = nest({
7 'history.sync.push': 'first',
8 'translations.sync.strings': 'first'
9})
10
11exports.create = (api) => {
12 return nest('app.html.topNav', (location) => {
13 const strings = api.translations.sync.strings()
14 const goTo = (loc) => () => api.history.sync.push(loc)
15
16 if (!['blogIndex', 'blogSearch'].includes(location.page)) return
17
18 const activeFilter = location.hasOwnProperty('filter') ? location.filter : "All"
19
20 var filters = () => {
21 return h('Filters', [
22 h('span -filter', {
23 className: 'All' === activeFilter ? '-active' : '',
24 'ev-click': goTo({ page: location.page, filter: 'All' })
25 }, 'All'),
26 h('span', '|'),
27 h('span -filter', {
28 className: 'Subscriptions' === activeFilter ? '-active' : '',
29 'ev-click': goTo({ page: location.page, filter: 'Subscriptions' })
30 }, 'Subscriptions'),
31 h('span', '|'),
32 h('span -filter', {
33 className: 'Friends' === activeFilter ? '-active' : '',
34 'ev-click': goTo({ page: location.page, filter: 'Friends' })
35 }, 'Friends')
36 ])
37 }
38
39 return [h('TopNav -blog', [
40 h('div.left', [
41 h('div', {
42 className: location.page === 'blogIndex' ? '-active' : '',
43 'ev-click': goTo({ page: 'blogIndex' })
44 }, strings.topNav.blogsAll),
45 h('div', {
46 className: location.page === 'blogSearch' ? '-active' : '',
47 'ev-click': goTo({ page: 'blogSearch' })
48 }, strings.topNav.blogSearch)
49 ]),
50 h('div.right', [
51 h('Button -strong', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog)
52 ])
53 ]),
54 filters
55 ]
56 })
57}
58

Built with git-ssb-web