1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import {stitchArrays} from '#sugar';
export default {
query: (tracks, contextTrack, _contextContributions) => ({
presentedTracks:
(contextTrack
? tracks.map(track =>
track.otherReleases.find(({album}) => album === contextTrack.album) ??
track)
: tracks),
}),
relations: (relation, query, _tracks, _contextTrack, contextContributions) => ({
items:
query.presentedTracks
.map(track => relation('generateTrackListItem', track, contextContributions)),
}),
data: (query, _tracks, contextTrack, _contextContributions) => ({
presentedTracksMatchContextRelease:
query.presentedTracks
.map(track => track.album === contextTrack.album),
}),
slots: {
showArtists: {
validate: v => v.is(true, false, 'auto'),
default: 'auto',
},
showDuration: {
type: 'boolean',
default: false,
},
showDetail: {
type: 'boolean',
default: true,
},
colorMode: {
validate: v => v.is('none', 'track', 'line'),
default: 'track',
},
},
generate: (data, relations, slots, {html}) =>
html.tag('ul',
{[html.onlyIfContent]: true},
stitchArrays({
item: relations.items,
releasesMatch: data.presentedTracksMatchContextRelease,
}).map(({item, releasesMatch}) =>
item.slots({
showArtists: slots.showArtists,
showDuration: slots.showDuration,
showDetail:
(slots.showDetail && releasesMatch
? 'from within album'
: slots.showDetail
? 'from across wiki'
: false),
colorMode: slots.colorMode,
}))),
};
|