git ssb

0+

Josiah / patchbay-tags



Tree: 085a3a243377487682b151255dac37aefd134985

Files: 085a3a243377487682b151255dac37aefd134985 / app / page / tags.js

961 bytesRaw
1const nest = require('depnest')
2const { computed, map, h } = require('mutant')
3
4exports.gives = nest({
5 'app.html.menuItem': true,
6 'app.page.tags': true,
7})
8
9exports.needs = nest({
10 'keys.sync.id': 'first',
11 'tag.html.render': 'first',
12 'tag.obs.get': 'first',
13 'tag.obs.allTagsFrom': 'first'
14})
15
16exports.create = function(api) {
17 return nest({
18 'app.html.menuItem': menuItem,
19 'app.page.tags': tagsPage,
20 })
21
22 function menuItem(handleClick) {
23 return h('a', {
24 style: { order: 0 },
25 'ev-click': () => handleClick({ page: 'tags' })
26 }, '/tags')
27 }
28
29 function tagsPage(path) {
30 if (path.page !== ('tags')) return
31
32 const myId = api.keys.sync.id()
33 const tags = map(
34 api.tag.obs.allTagsFrom(myId),
35 tagId => api.tag.obs.get(tagId)
36 )
37
38 return h('Page', [
39 h('section', [
40 map(
41 tags,
42 tag => computed(tag, tag => api.tag.html.render(tag))
43 )
44 ])
45 ])
46 }
47}
48

Built with git-ssb-web