git ssb

0+

Zach! / dat-zine-library



Tree: d732abfd07c7c2670daa5ed4ad2071aa0d1cb6e3

Files: d732abfd07c7c2670daa5ed4ad2071aa0d1cb6e3 / building / components / shelving.js

1154 bytesRaw
1const html = require('choo/html')
2const _ = require('lodash')
3
4module.exports = view
5
6function view (state, emit) {
7 return html`
8 <ul id='zine-shelves'>
9 ${state.library.map(listZines)}
10 </ul>
11 `
12
13 function listZines (zine) {
14 var trimmedUrl = _.trimEnd(zine.url, '/')
15 var zineID = zine.title.replace(/ /g, '-')
16 var imagePath = state.covers[trimmedUrl]
17 return html`
18 <li id=${zineID}>
19 <a href=${zine.url} title=${zine.title} target="_blank">
20 <div class='zine-card'>
21 <div class='title'>
22 <h1>${zine.title}</h1>
23 </div>
24 <div class='details'>
25 <img src=${imagePath}/>
26 <p>${zine.adoration}</p>
27 ${renderInfo(zine, state)}
28 </div>
29 </div>
30 </a>
31 </li>
32 `
33 }
34
35 function renderInfo (zine, state) {
36 var trimmedUrl = _.trimEnd(zine.url, '/')
37 var info = state.info[trimmedUrl]
38 if (info) {
39 return html`
40 <div>
41 <h2>Info From this Zine!</p>
42 <p><strong>Creation Date:</strong>${info['creation date']}</p>
43 <p><strong>Sharing Notes:</strong> ${info.sharing}</p>
44 <p><strong>Other Notes:</strong> ${info.notes}</p>
45 </div>
46 `
47 }
48 }
49}
50

Built with git-ssb-web