From 215aa2577d9d2e0812a8c42c90bd1d7ba83d2028 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 22 Dec 2022 22:33:24 -0400 Subject: many homepage carousel shenanigans --- src/misc-templates.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/misc-templates.js') 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, -- cgit 1.3.0-6-gf8a5