aboutsummaryrefslogtreecommitdiff
path: root/build/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'build/gallery')
-rw-r--r--build/gallery/index.html22
1 files changed, 2 insertions, 20 deletions
diff --git a/build/gallery/index.html b/build/gallery/index.html
index bd2c312..796b249 100644
--- a/build/gallery/index.html
+++ b/build/gallery/index.html
@@ -3,11 +3,12 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="dark light">
<link rel="icon" href="data:,">
<title>Simplifying the Craigslist Gallery</title>
<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
<link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" />
-<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
+<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}blockquote{background:rgba(0,0,0,0.1);border-left:4px solid;padding-left:5px;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
</head>
<nav>
@@ -16,21 +17,13 @@
<main>
<h1 id="simplifying-the-craigslist-gallery">Simplifying the Craigslist Gallery</h1>
-
<p>2022-10-03</p>
-
<p><strong>This article was updated on October 11, 2022</strong></p>
-
<p>I&#8217;m a big fan of <a href="https://craigslist.org">craigslist.org</a> and the overall UX used throughout their application. My own website is an ever-changing example of &#8220;brutalist&#8221; or minimalist design, so I&#8217;m always inspired by existing web apps out in the wild using the same principles.</p>
-
<p>One nitpick I have with the current craigslist design is their approach to image galleries inside their listings. They use a chunk of bloated JavaScript (more than <code>380kB</code> total) to render something as simple as a collection of images. This seems like overkill to me.</p>
-
<h2 id="simplifying-things">Simplifying Things</h2>
-
<p>My first suggestion would be to remove JavaScript altogether. We can replicate most of the required features with just HTML &#38; CSS. Let&#8217;s start with our core HTML structure:</p>
-
<h3 id="html">HTML</h3>
-
<pre><code>&#60;div class="gallery-wrapper"&#62;
&#60;div class="full-size"&#62;
&#60;a name="p1"&#62;&#60;img src="https:&#47;&#47;picsum.photos&#47;id&#47;100&#47;400" alt="Picture 1" class="gallery-item"&#62;&#60;&#47;a&#62;
@@ -44,15 +37,10 @@
&#60;&#47;div&#62;
&#60;&#47;div&#62;
</code></pre>
-
<p>Here we are placing the full-size gallery images directly inside a single <code>div.full-size</code> as - you guessed it - <code>img</code> elements. This already helps us avoid the pitfall of building out spaghetti <code>div</code> containers.</p>
-
<p>Below this parent container we have another element, <code>div.thumbnails</code>, which will be used for our separate, smaller thumbnail versions of our main images. The most important items to note are the associated <code>ahref</code> elements surrounding each <code>img</code> element. By setting the <code>id</code> parameter on our thumbnails to match that of the <code>name</code> on our full-sized images, we can &#8220;scroll&#8221; the proper image into view without the need for JavaScript.</p>
-
<p>Now for the <em>fancy</em> stuff - the CSS!</p>
-
<h3 id="css">CSS</h3>
-
<pre><code>.gallery-wrapper {
position: relative;
}
@@ -80,17 +68,11 @@
margin-right: 10px;
}
</code></pre>
-
<p>Okay, so it isn&#8217;t <em>that</em> fancy. It&#8217;s actually very basic, which is exactly what we were going for. The images are &#8220;stacked&#8221; inline thanks to the parent container being set to <code>display: flex</code>, even though it has a set width of <code>600px</code>. The included <code>scroll-snap-type: x mandatory</code> tells the browser to allow users to scroll&#47;swipe horizontally through the parent container.</p>
-
<p>The last important piece of this CSS is the <code>scroll-snap-align: start</code> added to the individual image elements. This parameter <em>snaps</em> the next image into the starting position of the parent container on scroll, giving a behavior users have come to expect from media galleries.</p>
-
<p>You will also see the included <code>:before</code> pseudo element attached to the main <code>.gallery-wrapper</code> element. This isn&#8217;t <em>required</em> but it certainly helps from a UX standpoint.</p>
-
<h2 id="live-demo">Live Demo</h2>
-
<p>Check out the embedded CodePen below to see it in action. More functionality could always be built on top of this, such as rendering all images dynamically on &#8220;build&#8221;, but for a starting point I think it&#8217;s great.</p>
-
<p><a href="https://codepen.io/bradleytaunt/pen/ExLRyXz">Live CodePen Example</a></p>
<footer role="contentinfo">
<h2>Menu Navigation</h2>