git ssb

3+

arj / patchbook



Tree: 59b2150aa65f622113a8aae8016eb849a7345690

Files: 59b2150aa65f622113a8aae8016eb849a7345690 / book / html / layout / card.js

1642 bytesRaw
1const nest = require('depnest')
2const { h, Value } = 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 let rawMessage = Value(null)
53
54 return h('Message -book-card', [
55 h('section.avatar', {}, api.about.html.image(msg.value.author)),
56 h('section.timestamp', {}, timestamp(msg)),
57 h('section.meta', {}, meta(msg, { rawMessage })),
58 h('section.content', {}, content),
59 h('section.raw-content', rawMessage),
60 h('section.actions', {}, action(msg)),
61 h('footer.backlinks', {}, backlinks(msg))
62 ])
63 }
64}
65

Built with git-ssb-web