git ssb

3+

arj / patchbook



Tree: 24301103fc79102ebc4d71e1454571b15c58592e

Files: 24301103fc79102ebc4d71e1454571b15c58592e / book / html / layout / card.js

1561 bytesRaw
1const nest = require('depnest')
2const { h, computed } = require('mutant')
3const spacetime = require('spacetime')
4
5exports.needs = nest({
6 'message.html': {
7 backlinks: 'first',
8 meta: 'map',
9 action: 'map',
10 timestamp: 'first'
11 },
12 'about.html.image': 'first',
13 'about.obs.color': 'first',
14 'blob.sync.url': 'first',
15 'book.obs.book': 'first',
16 'book.html': {
17 description: 'first',
18 title: 'first'
19 }
20})
21
22exports.gives = nest('book.html.layout')
23
24exports.create = (api) => {
25 return nest('book.html.layout', bookLayout)
26
27 function bookLayout (msg, opts) {
28 const { layout, obs, isCard } = opts
29
30 if (!(layout === undefined || layout === 'card')) return
31
32 const { timestamp, meta, backlinks, action } = api.message.html
33
34 const { description, title, authors } = api.book.html
35
36 const content = [
37 h('a', { href: msg.key }, [
38 h('.toggle-layout', {
39 'ev-click': e => {
40 e.preventDefault()
41 isCard.set(false)
42 }
43 }, '+'),
44 h('.details', [
45 title({title: obs.title, msg}),
46 authors({authors: obs.authors}),
47 description({description: obs.description})
48 ])
49 ])
50 ]
51
52 return h('Message -book-card', [
53 h('section.avatar', {}, api.about.html.image(msg.value.author)),
54 h('section.timestamp', {}, timestamp(msg)),
55 h('section.meta', {}, meta(msg)),
56 h('section.content', {}, content),
57 h('section.actions', {}, action(msg)),
58 h('footer.backlinks', {}, backlinks(msg))
59 ])
60 }
61}
62

Built with git-ssb-web