« get me outta code hell

refactor/tweak getGridHTML to use link() fns - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/misc-templates.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2021-12-31 21:16:59 -0400
committer(quasar) nebula <qznebula@protonmail.com>2021-12-31 21:16:59 -0400
commit5b1418b417c2bac641a8671e7da5cf02aefa6245 (patch)
treedba642ee9fbcb6d4e8707c007c0962e8621f946c /src/misc-templates.js
parent7710fc578ec94bb9edca551e7d38ab30d8560ecf (diff)
refactor/tweak getGridHTML to use link() fns
Diffstat (limited to 'src/misc-templates.js')
-rw-r--r--src/misc-templates.js42
1 files changed, 20 insertions, 22 deletions
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})
-            })}
-            <span>${item.name}</span>
-            ${detailsFn && `<span>${detailsFn(item)}</span>`}
-        `)).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})
+                })}
+                <span>${item.name}</span>
+                ${detailsFn && `<span>${detailsFn(item)}</span>`}
+            `
+        })).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, {