Grid and list index
Projects as big centred capital rows with a floating print on hover, or as a loose grid, toggled by a GRID / LIST switch.
Part of the style
Drifting Print Field
6 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/drifting-print-field/index/figma.html?palette=f4ceffd47876adfc
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/drifting-print-field/index/figma.html?palette=f4ceffd47876adfc and pass that whole HTML document to the html_to_figma tool, so the part "Grid and list index" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--ink: #121212;
--paper: #7d837b;
--ink-soft: #191815;
--shade: #6b7069;
}
</style>
<section class="index is-list" aria-label="All work">
<ul class="index__items">
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--wide" src="assets/wave-fjord.jpg" alt="Waves breaking on dark stones" width="800" height="450">
<span class="index__title">Salt Hours</span>
<span class="index__year">2027</span>
</a>
</li>
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--tall" src="assets/dunes-tall.jpg" alt="A dirt road toward pale hills" width="534" height="800">
<span class="index__title">The Long Road</span>
<span class="index__year">2026</span>
</a>
</li>
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--wide" src="assets/crater.jpg" alt="Purple desert flowers on dark rock" width="800" height="534">
<span class="index__title">Bloom Year</span>
<span class="index__year">2026</span>
</a>
</li>
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--tall" src="assets/window.jpg" alt="A figure at a bright window" width="541" height="800">
<span class="index__title">Window Weather</span>
<span class="index__year">2025</span>
</a>
</li>
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--wide" src="assets/bathers.jpg" alt="Bathers on a grey beach" width="800" height="479">
<span class="index__title">Low Tide Letters</span>
<span class="index__year">2024</span>
</a>
</li>
<li class="index__item">
<a class="index__link" href="#">
<img class="index__thumb index__thumb--tall" src="assets/sitter.jpg" alt="An old portrait of a woman with long hair" width="634" height="800">
<span class="index__title">Sitters</span>
<span class="index__year">2023</span>
</a>
</li>
</ul>
<div class="index__switch" role="group" aria-label="View">
<button class="index__view" type="button" data-view="grid" aria-pressed="false">Grid</button>
<button class="index__view" type="button" data-view="list" aria-pressed="true">List</button>
</div>
</section>
<style>
.index {
position: relative;
padding: var(--space-xl) var(--edge) var(--space-m);
background: var(--paper);
color: var(--ink);
font-family: var(--font-display);
font-stretch: var(--stretch-display);
font-weight: var(--weight-display);
letter-spacing: var(--track);
text-transform: uppercase;
}
.index__items {
margin: 0;
padding: 0;
list-style: none;
transition: opacity var(--fade) var(--ease-soft);
}
.index.is-changing .index__items { opacity: 0; }
.index__link {
color: inherit;
text-decoration: none;
}
.index__link:focus-visible {
outline: var(--rule) solid var(--ink);
outline-offset: 4px;
}
.index__thumb {
height: auto;
background: var(--shade);
object-fit: cover;
}
.index__thumb--wide { aspect-ratio: 4 / 3; }
.index__thumb--tall { aspect-ratio: 3 / 4; }
.index__year {
color: var(--ink-soft);
font-family: var(--font-body);
font-size: var(--text-s);
font-weight: 400;
letter-spacing: 0;
}
/* List: one centred capital line per project; its print floats in on hover. */
.index.is-list .index__items {
display: grid;
justify-items: center;
}
.index.is-list .index__link {
position: relative;
display: inline-flex;
align-items: flex-start;
gap: var(--space-s);
min-height: var(--tap);
padding: var(--space-xs) 0;
}
.index.is-list .index__title {
position: relative;
z-index: 1;
font-size: var(--display-l);
line-height: 1;
transition: opacity var(--fade) var(--ease-soft);
}
.index.is-list .index__year {
position: relative;
z-index: 1;
padding-top: 0.3em;
}
.index.is-list .index__thumb {
position: absolute;
left: 50%;
top: 50%;
z-index: 2;
width: var(--print-tall);
opacity: 0;
pointer-events: none;
transform: translate(-50%, -40%) scale(0.92);
transition: opacity var(--fade) var(--ease-soft), transform var(--glide) var(--ease-glide);
}
.index.is-list .index__thumb--wide { width: var(--print-wide); }
.index.is-list .index__items:hover .index__title { opacity: 0.2; }
.index.is-list .index__link:hover .index__title,
.index.is-list .index__link:focus-visible .index__title { opacity: 1; }
.index.is-list .index__link:hover .index__thumb,
.index.is-list .index__link:focus-visible .index__thumb {
opacity: 1;
transform: translate(calc(-50% + var(--nudge, 0px)), -50%) scale(1);
}
/* Grid: the same items as loose prints in staggered columns. */
.index.is-grid .index__items {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: var(--space-l) var(--gap);
align-items: start;
max-width: 1200px;
margin: 0 auto;
}
.index.is-grid .index__item:nth-child(3n + 2) { margin-top: var(--space-xl); }
.index.is-grid .index__item:nth-child(3n + 3) { margin-top: var(--space-l); }
.index.is-grid .index__link {
display: grid;
gap: var(--space-s);
justify-items: center;
}
.index.is-grid .index__thumb { width: 80%; transition: opacity var(--fade) var(--ease-soft); }
.index.is-grid .index__thumb--tall { width: 62%; }
.index.is-grid .index__title { font-size: var(--text-s); }
.index.is-grid .index__year { display: none; }
.index.is-grid .index__items:hover .index__thumb { opacity: 0.3; }
.index.is-grid .index__link:hover .index__thumb,
.index.is-grid .index__link:focus-visible .index__thumb { opacity: 1; }
.index__switch {
display: flex;
justify-content: center;
gap: var(--space-l);
margin-top: var(--space-xl);
}
.index__view {
min-width: var(--tap);
min-height: var(--tap);
padding: 0 var(--space-xs);
border: 0;
background: transparent;
color: var(--ink-soft);
font: inherit;
font-size: var(--display-m);
letter-spacing: inherit;
text-transform: inherit;
cursor: pointer;
transition: color var(--fade) var(--ease-soft);
}
.index__view[aria-pressed="true"],
.index__view:hover,
.index__view:focus-visible { color: var(--ink); }
.index__view:focus-visible { outline: var(--rule) solid var(--ink); }
@media (max-width: 640px) {
.index.is-grid .index__items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.index.is-grid .index__item:nth-child(n) { margin-top: 0; }
.index.is-grid .index__item:nth-child(even) { margin-top: var(--space-l); }
}
</style>
<script>
(() => {
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
for (const root of document.querySelectorAll(".index")) {
const buttons = [...root.querySelectorAll(".index__view")];
let timer = 0;
const set = (view) => {
root.classList.toggle("is-grid", view === "grid");
root.classList.toggle("is-list", view === "list");
buttons.forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.view === view)));
};
buttons.forEach((button) =>
button.addEventListener("click", () => {
const view = button.dataset.view;
if (root.classList.contains(`is-${view}`)) return;
clearTimeout(timer);
if (reduce.matches) return set(view);
root.classList.add("is-changing");
timer = setTimeout(() => {
set(view);
root.classList.remove("is-changing");
}, 490);
})
);
// The floating print leans toward the pointer along the row.
for (const link of root.querySelectorAll(".index__link")) {
link.addEventListener("pointermove", (event) => {
const box = link.getBoundingClientRect();
const nudge = ((event.clientX - box.left) / box.width - 0.5) * box.width * 0.6;
link.style.setProperty("--nudge", `${Math.round(nudge)}px`);
});
}
}
})();
</script>