git ssb

3+

arj / patchbook



Tree: c6808ebda95764b1cdd2b287584c051d8901fb42

Files: c6808ebda95764b1cdd2b287584c051d8901fb42 / book / html / layout / card.js

1648 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 authors: 'first',
20 images: 'first'
21 }
22})
23
24exports.gives = nest('book.html.layout')
25
26exports.create = (api) => {
27 return nest('book.html.layout', bookLayout)
28
29 function bookLayout (msg, opts) {
30 const { layout, obs, isCard } = opts
31
32 if (!(layout === undefined || layout === 'card')) return
33
34 const { timestamp, meta, backlinks, action } = api.message.html
35
36 const { description, title, authors, images } = api.book.html
37
38 const content = [
39 h('a', { href: msg.key }, [
40 h('.toggle-layout', {
41 'ev-click': e => {
42 e.preventDefault()
43 isCard.set(false)
44 }
45 }, '+'),
46 h('.details', [
47 title({title: obs.title, msg}),
48 authors({authors: obs.authors}),
49 description({description: obs.description}),
50 images({images: obs.images})
51 ])
52 ])
53 ]
54
55 return h('Message -book-card', [
56 h('section.avatar', {}, api.about.html.image(msg.value.author)),
57 h('section.timestamp', {}, timestamp(msg)),
58 h('section.meta', {}, meta(msg)),
59 h('section.content', {}, content),
60 h('section.actions', {}, action(msg)),
61 h('footer.backlinks', {}, backlinks(msg))
62 ])
63 }
64}
65

Built with git-ssb-web