« get me outta code hell

many homepage carousel shenanigans - 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>2022-12-22 22:33:24 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-12-22 22:33:24 -0400
commit215aa2577d9d2e0812a8c42c90bd1d7ba83d2028 (patch)
treebf7d2b36ec9f1fbb2dcea0fcfaf165d367b7fa92 /src/misc-templates.js
parente6f233025c0e511bb472bb75540d50381b58db48 (diff)
many homepage carousel shenanigans
Diffstat (limited to 'src/misc-templates.js')
-rw-r--r--src/misc-templates.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 5dd9649..53a9605 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -6,6 +6,7 @@ import T from './data/things/index.js';
 
 import {
   empty,
+  repeat,
   unique,
 } from './util/sugar.js';
 
@@ -639,6 +640,46 @@ function unbound_getFlashGridHTML({
   });
 }
 
+// Montage reels
+
+function unbound_getMontageHTML({
+  html,
+  img,
+
+  items,
+  lazy = true,
+
+  altFn = () => '',
+  linkFn = (x, {text}) => text,
+  srcFn,
+}) {
+  return (x => x)(html.tag('div', {class: 'montage-container'},
+    repeat(3,
+      html.tag('div',
+        {
+          class: 'montage-grid',
+          'aria-hidden': 'true',
+        },
+        items
+          .filter(item => srcFn(item))
+          .filter(item => item.artTags.every(tag => !tag.isContentWarning))
+          .map((item, i) =>
+            html.tag('div', {class: 'montage-item'},
+              linkFn(item, {
+                attributes: {
+                  tabindex: '-1',
+                },
+                text:
+                  img({
+                    src: srcFn(item),
+                    alt: altFn(item),
+                    thumb: 'small',
+                    lazy: typeof lazy === 'number' ? i >= lazy : lazy,
+                    square: true,
+                  }),
+              })))))));
+}
+
 // Nav-bar links
 
 function unbound_generateInfoGalleryLinks(currentThing, isGallery, {
@@ -837,6 +878,8 @@ export {
   unbound_getAlbumGridHTML as getAlbumGridHTML,
   unbound_getFlashGridHTML as getFlashGridHTML,
 
+  unbound_getMontageHTML as getMontageHTML,
+
   unbound_generateInfoGalleryLinks as generateInfoGalleryLinks,
   unbound_generateNavigationLinks as generateNavigationLinks,