Files: 93aed91e8e392b4b011fbacc5cccc010522e986d / book / html / layout / card.js
1541 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | |
4 | exports.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 | |
21 | exports.gives = nest('book.html.layout') |
22 | |
23 | exports.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