From 9ecf92d79a15b7ff01a454914fe20f3ba6bb5482 Mon Sep 17 00:00:00 2001 From: Hermes Date: Sat, 8 Aug 2026 14:21:28 +0200 Subject: [PATCH] use own card template (mm-card) + Template.add, like Shikimori plugin; fixes empty card (native card__img hidden) --- plugin.js | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/plugin.js b/plugin.js index 1b2ec31..c9d2ed0 100644 --- a/plugin.js +++ b/plugin.js @@ -42,21 +42,42 @@ } } - // Inject plugin styles (only the grid layout; cards use native Lampa classes) + // Plugin templates/styles (pattern from Shikimori plugin): + // own namespaced classes so they do NOT collide with Lampa native .card__img + // (native card__img is hidden until its own lazy-load runs, so our must use a custom class). function injectStyles() { if (window.__mymovies_css_injected) return; window.__mymovies_css_injected = true; - var css = '' + + + // Card template with poster image + Lampa.Template.add('mymovies-card', + '
' + + '
' + + '' + + '
' + + '
{title}
' + + '
{year}
' + + '
'); + + // Styles + Lampa.Template.add('mymovies-style', + ''); } // ---------- Component: movie list ---------- @@ -111,13 +132,14 @@ return; } movies.forEach(function (m) { - // LAMPA NATIVE card classes so the grid/style matches the app - var card = $('
'); - var view = $('
'); - view.append($('').attr('src', resolve(m.poster || m.cover)).attr('loading', 'lazy')); - card.append(view); - card.append($('
').text(m.title || m.id)); - if (m.year) card.append($('
').text(m.year)); + // Use plugin card template (own classes, does not collide with native card__img) + var card = Lampa.Template.get('mymovies-card', { + img: resolve(m.poster || m.cover), + title: m.title || m.id, + year: m.year || '' + }); + card = $(card); + card.attr('data-id', esc(m.id)); card.on('hover:enter', function () { openMovie(m); }); grid.append(card); });