git ssb

3+

arj / patchbook



Tree: 840a2fd3498a948c8d45947232f93f06f74d091e

Files: 840a2fd3498a948c8d45947232f93f06f74d091e / book / html / layout / card.js

1541 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3
4exports.needs = nest({
5 'message.html': {
6 backlinks: 'first',
7 meta: 'map',
8 action: 'map',
9 timestamp: 'first'
10 },
11 'about.html.image': 'first',
12 'book.obs.book': 'first',
13 'book.html': {
14 description: 'first',
15 title: 'first',
16 authors: 'first',
17 images: 'first'
18 }
19})
20
21exports.gives = nest('book.html.layout')
22
23exports.create = (api) => {
24 return nest('book.html.layout', bookLayout)
25
26 function bookLayout (msg, opts) {
27 const { layout, obs, isCard } = opts
28
29 if (!(layout === undefined || layout === 'card')) return
30
31 const { timestamp, meta, backlinks, action } = api.message.html
32
33 const { description, title, authors, images } = api.book.html
34
35 const content = [
36 h('a', { href: msg.key }, [
37 h('.toggle-layout', {
38 'ev-click': e => {
39 e.preventDefault()
40 isCard.set(false)
41 }
42 }, '+'),
43 h('.details', [
44 images({images: obs.images}),
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