Files: 9ae1c46f226c40c608560b66d0b5ca42ecce151b / app / html / topNav / topNavBlog.js
1054 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | |
4 | exports.gives = nest('app.html.topNav') |
5 | |
6 | exports.needs = nest({ |
7 | 'history.sync.push': 'first', |
8 | 'translations.sync.strings': 'first' |
9 | }) |
10 | |
11 | exports.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 | return h('TopNav -blog', [ |
19 | h('div.left', [ |
20 | h('div', { |
21 | className: location.page === 'blogIndex' ? '-active' : '', |
22 | 'ev-click': goTo({ page: 'blogIndex' }) |
23 | }, strings.topNav.blogsAll), |
24 | h('div', { |
25 | className: location.page === 'blogSearch' ? '-active' : '', |
26 | 'ev-click': goTo({ page: 'blogSearch' }) |
27 | }, strings.topNav.blogSearch) |
28 | ]), |
29 | h('div.right', [ |
30 | h('Button -strong', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog) |
31 | ]) |
32 | ]) |
33 | }) |
34 | } |
35 |
Built with git-ssb-web