From 86c31c72f81ccd59eba0f7e7867454176c660ccb Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 4 Apr 2023 15:48:39 -0300 Subject: content: generateAlbumTrackListItem: fixes & polish --- src/content/dependencies/generateAlbumTrackListItem.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/content/dependencies/generateAlbumTrackListItem.js b/src/content/dependencies/generateAlbumTrackListItem.js index fb315cb1..dd41ba11 100644 --- a/src/content/dependencies/generateAlbumTrackListItem.js +++ b/src/content/dependencies/generateAlbumTrackListItem.js @@ -7,7 +7,7 @@ export default { ], extraDependencies: [ - 'getLinkThemeString', + 'getColors', 'html', 'language', ], @@ -27,7 +27,7 @@ export default { return relations; }, - data(track) { + data(track, album) { const data = {}; data.color = track.color; @@ -36,12 +36,14 @@ export default { data.showArtists = !compareArrays( track.artistContribs.map(c => c.who), - track.album.artistContribs.map(c => c.who), + album.artistContribs.map(c => c.who), {checkOrder: false}); + + return data; }, generate(data, relations, { - getLinkThemeString, + getColors, html, language, }) { @@ -50,8 +52,14 @@ export default { track: relations.trackLink, }; + let style; + if (data.color) { + const {primary} = getColors(data.color); + style = `--primary-color: ${primary}`; + } + return html.tag('li', - {style: getLinkThemeString(data.color)}, + {style}, (!data.showArtists ? language.$('trackList.item.withDuration', stringOpts) : language.$('trackList.item.withDuration.withArtists', { -- cgit 1.3.0-6-gf8a5