| 1 |
--- |
| 2 |
const memes = [ |
| 3 |
{src: "/img/memes/original.png", alt: "2004 architecture vs 2019 architecture vs 2021 architecture with htmx"}, |
| 4 |
{src: "/img/memes/20yearold.png", alt: "\"lol you are going to use twenty year old technology\" — django, php, flask, rails: \"Yes.\" lisp: \"no, sixty years old.\""}, |
| 5 |
{src: "/img/memes/whowillwin.png", alt: "Who Will Win? Angular and React vs a lunatic in Montana and his internet friends"}, |
| 6 |
{src: "/img/memes/uarealldoingitwrong.png", alt: "Roy Fielding: REST — You're doing it completely wrong"}, |
| 7 |
{src: "/img/memes/restapi.png", alt: "I'm going to create a RESTful API... Using JSON... here are my API docs — increasingly angry Roy Fielding"}, |
| 8 |
{src: "/img/memes/justusehtml.png", alt: "Hydration vs resumability vs just use HTML"}, |
| 9 |
{src: "/img/memes/istudiedhtml.png", alt: "When you wrote class components I studied HTML"}, |
| 10 |
{src: "/img/memes/htmlvsjson.png", alt: "HTML: I feel bad for you. JSON: I don't think about you at all."}, |
| 11 |
{src: "/img/memes/dontknowwhatclientsideroutingis.png", alt: "Can't route client side if you don't know what client-side routing is"}, |
| 12 |
{src: "/img/memes/nocap.png", alt: "Grug with broccoli hair: hypermedia straight bussin"}, |
| 13 |
{src: "/img/memes/ie11enjoyer.png", alt: "Average open standards fan vs average IE11 enjoyer"}, |
| 14 |
{src: "/img/memes/hydration.png", alt: "How much water is in your body? React: 100%"}, |
| 15 |
{src: "/img/memes/viewsource.png", alt: "Gigachad: I wonder how this works — clicks view source — Oh, neat."}, |
| 16 |
{src: "/img/memes/javascripthistory.png", alt: "Friends? Free time? Happiness? Nope — JavaScript History API"}, |
| 17 |
{src: "/img/memes/bellcurve.png", alt: "Bell curve: HTML + a backend — ONE BILLION COMPONENTS — HTML + a backend"}, |
| 18 |
{src: "/img/memes/drakearchitecture.png", alt: "Drake: complex web dev learning graph vs Learn the basics — HTML and CSS"}, |
| 19 |
{src: "/img/memes/bellcurve2.png", alt: "Bell curve: HTML is fine — we have to use react and graphql and redux — htmx is fine"}, |
| 20 |
{src: "/img/memes/dbtohtml.png", alt: "DB to JSON to HTML — or just DB to HTML"}, |
| 21 |
{src: "/img/memes/normal.png", alt: "Me: Why can't you just be normal? JavaScript: screams"}, |
| 22 |
{src: "/img/memes/feelbad.png", alt: "You are using the term REST bad and you should feel bad"}, |
| 23 |
{src: "/img/memes/drakememes.png", alt: "Drake: well reasoned content explaining strengths and weaknesses of htmx vs memes"}, |
| 24 |
{src: "/img/memes/fullstack.jpg", alt: "htmx to backend dev: Look at me. You're fullstack now."}, |
| 25 |
{src: "/img/memes/frontenddevs.png", alt: "Front end devs thinking everyone will use JavaScript on the backend — htmx"}, |
| 26 |
{src: "/img/memes/htmxanddjango.png", alt: "Django riding htmx refusing all that complicated JS noise"}, |
| 27 |
{src: "/img/memes/aye.png", alt: "Old Java dev: I never thought I'd die fighting side by side with dotnet developers — what about someone who also hates JS frameworks? — aye, I could do that"}, |
| 28 |
{src: "/img/memes/extinction.png", alt: "JavaScript/Node as Thanos vs Java, Ruby, Lisp, Python, PHP fighting back"}, |
| 29 |
]; |
| 30 |
|
| 31 |
const total = memes.length; |
| 32 |
--- |
| 33 |
|
| 34 |
<div id="meme-gallery" class="columns-1 sm:columns-2 gap-4 mb-16"> |
| 35 |
{memes.map((meme, i) => ( |
| 36 |
<button type="button" |
| 37 |
class="block w-full mb-4 break-inside-avoid cursor-zoom-in group" |
| 38 |
data-src={meme.src} |
| 39 |
data-alt={meme.alt} |
| 40 |
_={`on click |
| 41 |
set #lightbox-img.src to my @data-src |
| 42 |
set #lightbox-img.alt to my @data-alt |
| 43 |
set #lightbox-counter.textContent to '${i + 1} / ${total}' |
| 44 |
set #meme-lightbox@data-index to '${i}' |
| 45 |
call #meme-lightbox.showModal()`}> |
| 46 |
<img src={meme.src} |
| 47 |
alt={meme.alt} |
| 48 |
loading="lazy" |
| 49 |
class="rounded border border-neutral-200 dark:border-neutral-800 w-full h-auto transition" /> |
| 50 |
</button> |
| 51 |
))} |
| 52 |
</div> |
| 53 |
|
| 54 |
<!-- Lightbox dialog --> |
| 55 |
<dialog id="meme-lightbox" |
| 56 |
class="fixed inset-0 m-0 w-full h-full max-w-none max-h-none bg-transparent p-0 |
| 57 |
backdrop:bg-black/85 backdrop:backdrop-blur-sm |
| 58 |
open:flex open:items-center open:justify-center" |
| 59 |
data-index="0" |
| 60 |
_="on click |
| 61 |
if event.target is me |
| 62 |
call me.close() |
| 63 |
end |
| 64 |
end |
| 65 |
on keydown[key=='ArrowRight'] |
| 66 |
halt the event |
| 67 |
trigger next on me |
| 68 |
end |
| 69 |
on keydown[key=='ArrowLeft'] |
| 70 |
halt the event |
| 71 |
trigger prev on me |
| 72 |
end |
| 73 |
on touchstart |
| 74 |
set touch to event.changedTouches[0] |
| 75 |
set my @data-touch-x to touch.clientX |
| 76 |
end |
| 77 |
on touchend |
| 78 |
set touch to event.changedTouches[0] |
| 79 |
set startX to (my @data-touch-x as Number) |
| 80 |
set diff to (startX - touch.clientX) |
| 81 |
if diff > 50 |
| 82 |
trigger next on me |
| 83 |
else if diff < -50 |
| 84 |
trigger prev on me |
| 85 |
end |
| 86 |
end |
| 87 |
on next |
| 88 |
set buttons to #meme-gallery.children |
| 89 |
set idx to ((my @data-index as Int) + 1) |
| 90 |
if idx >= buttons.length |
| 91 |
set idx to 0 |
| 92 |
end |
| 93 |
set btn to buttons[idx] |
| 94 |
set #lightbox-img.src to btn.dataset.src |
| 95 |
set #lightbox-img.alt to btn.dataset.alt |
| 96 |
set #lightbox-counter.textContent to ((idx + 1) + ' / ' + buttons.length) |
| 97 |
set my @data-index to idx |
| 98 |
end |
| 99 |
on prev |
| 100 |
set buttons to #meme-gallery.children |
| 101 |
set idx to ((my @data-index as Int) - 1) |
| 102 |
if idx < 0 |
| 103 |
set idx to (buttons.length - 1) |
| 104 |
end |
| 105 |
set btn to buttons[idx] |
| 106 |
set #lightbox-img.src to btn.dataset.src |
| 107 |
set #lightbox-img.alt to btn.dataset.alt |
| 108 |
set #lightbox-counter.textContent to ((idx + 1) + ' / ' + buttons.length) |
| 109 |
set my @data-index to idx |
| 110 |
end"> |
| 111 |
|
| 112 |
<!-- Close --> |
| 113 |
<button type="button" |
| 114 |
class="fixed top-4 right-4 z-10 size-10 flex items-center justify-center rounded-full |
| 115 |
text-white/70 interact:text-white interact:bg-white/10 transition cursor-pointer outline-none" |
| 116 |
_="on click call #meme-lightbox.close()" |
| 117 |
aria-label="Close lightbox"> |
| 118 |
<i class="icon-[mdi--close] size-6"></i> |
| 119 |
</button> |
| 120 |
|
| 121 |
<!-- Prev --> |
| 122 |
<button type="button" |
| 123 |
class="fixed left-4 top-1/2 -translate-y-1/2 z-10 size-12 flex items-center justify-center rounded-full |
| 124 |
text-white/50 interact:text-white interact:bg-white/10 transition cursor-pointer outline-none" |
| 125 |
_="on click trigger prev on #meme-lightbox" |
| 126 |
aria-label="Previous meme"> |
| 127 |
<i class="icon-[mdi--chevron-left] size-8"></i> |
| 128 |
</button> |
| 129 |
|
| 130 |
<!-- Next --> |
| 131 |
<button type="button" |
| 132 |
class="fixed right-4 top-1/2 -translate-y-1/2 z-10 size-12 flex items-center justify-center rounded-full |
| 133 |
text-white/50 interact:text-white interact:bg-white/10 transition cursor-pointer outline-none" |
| 134 |
_="on click trigger next on #meme-lightbox" |
| 135 |
aria-label="Next meme"> |
| 136 |
<i class="icon-[mdi--chevron-right] size-8"></i> |
| 137 |
</button> |
| 138 |
|
| 139 |
<!-- Image --> |
| 140 |
<img id="lightbox-img" |
| 141 |
src="" |
| 142 |
alt="" |
| 143 |
class="max-w-[90vw] max-h-[85vh] object-contain rounded-lg select-none" /> |
| 144 |
|
| 145 |
<!-- Counter --> |
| 146 |
<span id="lightbox-counter" |
| 147 |
class="fixed bottom-4 left-1/2 -translate-x-1/2 text-sm text-white/50 font-mono tabular-nums select-none"> |
| 148 |
</span> |
| 149 |
</dialog> |