Files: 50a8f45832d95d56a26433d9cd66e7453416a55e / app / html / blogNav.js
1469 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, when } = require('mutant') |
3 | const get = require('lodash/get') |
4 | |
5 | exports.gives = nest('app.html.blogNav') |
6 | |
7 | exports.needs = nest({ |
8 | 'history.sync.push': 'first', |
9 | 'history.sync.back': 'first', |
10 | 'translations.sync.strings': 'first', |
11 | }) |
12 | |
13 | exports.create = (api) => { |
14 | return nest('app.html.blogNav', (location) => { |
15 | const strings = api.translations.sync.strings() |
16 | const goTo = (loc) => () => api.history.sync.push(loc) |
17 | const back = () => api.history.sync.back() |
18 | |
19 | if (location.page === 'blogIndex' || location.page === 'blogSearch') { |
20 | return h('BlogNav', [ |
21 | h('div.left', [ |
22 | h('div', { |
23 | className: location.page === 'blogIndex' ? '-active' : '', |
24 | 'ev-click': goTo({ page: 'blogIndex' }) |
25 | }, strings.blogNav.blogsAll), |
26 | h('div', { |
27 | className: location.page === 'blogSearch' ? '-active' : '', |
28 | 'ev-click': goTo({ page: 'blogSearch' }) |
29 | }, strings.blogNav.blogSearch), |
30 | ]), |
31 | h('div.right', [ |
32 | h('Button -strong', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog), |
33 | ]) |
34 | ]) |
35 | } |
36 | |
37 | return h('BlogNav', [ |
38 | h('div.left', [ |
39 | h('div.-discovery', { 'ev-click': back }, [ |
40 | h('i.fa.fa-chevron-left'), |
41 | strings.blogIndex.title |
42 | ]), |
43 | ]), |
44 | h('div.right', [ |
45 | ]) |
46 | ]) |
47 | }) |
48 | } |
49 | |
50 |
Built with git-ssb-web