Files: 4e3a4be0788f6e80d9510e5f86c967dea4d413cd / views / songbook.js
1156 bytesRaw
1 | const choo = require('choo') |
2 | const html = require('choo/html') |
3 | const cool = require('../dots.json') |
4 | |
5 | module.exports = view |
6 | |
7 | function view (state, emit) { |
8 | if(state.currentSong == ''){ |
9 | return trackListing(state) |
10 | } |
11 | else{ |
12 | return song(state) |
13 | } |
14 | |
15 | function trackListing(state, emit) { |
16 | return html` |
17 | <div class='wrapper'> |
18 | <div class='paper'> |
19 | <div class='text'> |
20 | <ul> |
21 | ${state.songs.map(listTracks)} |
22 | </ul> |
23 | <div class='fadingAnimation'></div> |
24 | </div> |
25 | </div> |
26 | </div> |
27 | ` |
28 | } |
29 | function listTracks (song) { |
30 | return html`<li onclick=${change}>${song.title}</li>` |
31 | } |
32 | |
33 | function song(state,emit) { |
34 | var song = state.songs.find(song => song.title == state.currentSong) |
35 | console.log(song) |
36 | return html` |
37 | <div class='wrapper'> |
38 | <div class='paper'> |
39 | <h1>${song.title}</h1> |
40 | <p>${song.post}></p> |
41 | <p onclick=${close}>x close x</a> |
42 | </div> |
43 | </div> |
44 | ` |
45 | } |
46 | |
47 | |
48 | |
49 | function change (data) { |
50 | console.log(data.target.innerHTML) |
51 | song = data.target.innerHTML |
52 | emit('changeSong',song) |
53 | } |
54 | function close (data) { |
55 | console.log(data) |
56 | } |
57 | |
58 | |
59 | } |
60 | |
61 | |
62 | |
63 |
Built with git-ssb-web