From 5b1418b417c2bac641a8671e7da5cf02aefa6245 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 31 Dec 2021 21:16:59 -0400 Subject: refactor/tweak getGridHTML to use link() fns --- src/misc-templates.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'src/misc-templates.js') diff --git a/src/misc-templates.js b/src/misc-templates.js index a6b39b9..e787184 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -270,45 +270,42 @@ export function iconifyURL(url, {strings, to}) { // Grids export function getGridHTML({ - getLinkThemeString, img, strings, entries, srcFn, - hrefFn, + linkFn, altFn = () => '', detailsFn = null, lazy = true }) { - return entries.map(({ large, item }, i) => html.tag('a', + return entries.map(({ large, item }, i) => linkFn(item, { class: ['grid-item', 'box', large && 'large-grid-item'], - href: hrefFn(item), - style: getLinkThemeString(item.color) - }, - fixWS` - ${img({ - src: srcFn(item), - alt: altFn(item), - thumb: 'small', - lazy: (typeof lazy === 'number' ? i >= lazy : lazy), - square: true, - reveal: getRevealStringFromTags(item.artTags, {strings}) - })} - ${item.name} - ${detailsFn && `${detailsFn(item)}`} - `)).join('\n'); + text: fixWS` + ${img({ + src: srcFn(item), + alt: altFn(item), + thumb: 'small', + lazy: (typeof lazy === 'number' ? i >= lazy : lazy), + square: true, + reveal: getRevealStringFromTags(item.artTags, {strings}) + })} + ${item.name} + ${detailsFn && `${detailsFn(item)}`} + ` + })).join('\n'); } export function getAlbumGridHTML({ - getAlbumCover, getGridHTML, strings, to, + getAlbumCover, getGridHTML, link, strings, details = false, ...props }) { return getGridHTML({ srcFn: getAlbumCover, - hrefFn: album => to('localized.album', album.directory), + linkFn: link.album, detailsFn: details && (album => strings('misc.albumGridDetails', { tracks: strings.count.tracks(album.tracks.length, {unit: true}), time: strings.count.duration(getTotalDuration(album.tracks)) @@ -318,15 +315,16 @@ export function getAlbumGridHTML({ } export function getFlashGridHTML({ - getFlashCover, getGridHTML, to, + getFlashCover, getGridHTML, link, ...props }) { return getGridHTML({ srcFn: getFlashCover, - hrefFn: flash => to('localized.flash', flash.directory), + linkFn: link.flash, ...props }); } + // Nav-bar links export function generateInfoGalleryLinks(currentThing, isGallery, { -- cgit 1.3.0-6-gf8a5