Inset project tiles
Three project tiles with drawn artwork (a pinball marquee, a moth game at night, a green CRT maze) under glass title strips and category keys. Hover clips the artwork into a rounded inset and zooms it slightly.
Part of the style
Pressed Key Grid
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/pressed-key-grid/projects/figma.html?palette=7d6675095163ed59&type=violet-difference
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/pressed-key-grid/projects/figma.html?palette=7d6675095163ed59&type=violet-difference and pass that whole HTML document to the html_to_figma tool, so the part "Inset project tiles" 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 */
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;800&family=Newsreader:opsz,wght@6..72,400;6..72,600&display=swap");
:root {
--ink: #100f0f;
--paper: #fefefe;
--white: #ffffff;
--pressed: #efefef;
--sand: #efefef;
--guide: #dadada;
--rule-dark: #353434;
--muted: #868686;
--muted-dark: #b7b7b7;
--glass: rgba(254, 254, 254, 0.64);
--phosphor-deep: #121111;
--ember: #a7706c;
--ember-deep: #010000;
--plum: #9d7a61;
--lilac: #fff7f1;
--orchid: #a7706c;
--phosphor: #9d7a61;
--font-sans: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
}
</style>
<section class="projects" aria-label="Selected machines">
<article class="projects__item projects__item--wide">
<a class="projects__media" href="#" aria-label="Bumper City, a pinball table">
<span class="projects__frame"><canvas class="projects__art" data-art="bumper" aria-hidden="true"></canvas></span>
</a>
<div class="projects__meta">
<a class="projects__name" href="#">Bumper City</a>
<span class="projects__tags"><a class="projects__tag" href="#"><span>Pinball</span></a><a class="projects__tag" href="#"><span>Light & sound</span></a></span>
</div>
</article>
<article class="projects__item projects__item--right">
<a class="projects__media" href="#" aria-label="Moth Hour, a two-player night game">
<span class="projects__frame"><canvas class="projects__art" data-art="moth" aria-hidden="true"></canvas></span>
</a>
<div class="projects__meta">
<a class="projects__name" href="#">Moth Hour</a>
<span class="projects__tags"><a class="projects__tag" href="#"><span>Game design</span></a></span>
</div>
</article>
<article class="projects__item projects__item--left">
<a class="projects__media" href="#" aria-label="Signal Maze, a CRT cabinet">
<span class="projects__frame"><canvas class="projects__art" data-art="maze" aria-hidden="true"></canvas></span>
</a>
<div class="projects__meta">
<a class="projects__name" href="#">Signal Maze</a>
<span class="projects__tags"><a class="projects__tag" href="#"><span>Cabinets</span></a><a class="projects__tag" href="#"><span>Software</span></a></span>
</div>
</article>
</section>
<style>
.projects {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
align-items: start;
padding: var(--space-l) var(--edge) var(--space-xl);
background: var(--paper);
color: var(--ink);
}
.projects__item { position: relative; min-width: 0; }
.projects__item--wide { grid-column: 1 / 4; grid-row: 1; }
.projects__item--right { grid-column: 3 / 5; grid-row: 2; margin-top: calc(var(--hair) * -1); }
.projects__item--left { grid-column: 1 / 3; grid-row: 2; margin-top: calc(var(--cell) * 1.5); margin-right: calc(var(--hair) * -1); }
.projects__media {
display: block;
border: var(--hair) solid var(--ink);
background: var(--ink);
outline: none;
-webkit-tap-highlight-color: transparent;
}
.projects__frame {
display: block;
aspect-ratio: 16 / 9;
overflow: hidden;
clip-path: inset(0px round 0px);
transition: clip-path var(--t-drift) var(--ease-expo);
}
.projects__item:not(.projects__item--wide) .projects__frame { aspect-ratio: 1; }
.projects__art {
width: 100%;
height: 100%;
transition: transform var(--t-panel) var(--ease-expo);
}
.projects__media:is(:hover, :focus-visible) .projects__frame { clip-path: inset(var(--space-xs) round var(--radius)); transition-duration: var(--t-inset); }
.projects__media:is(:hover, :focus-visible) .projects__art { transform: scale(1.05); }
.projects__media:active .projects__art { transform: scale(0.97); }
.projects__media:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.projects__meta {
display: grid;
grid-template-columns: minmax(0, 1fr);
width: calc(100% / 3);
min-width: min(100%, 15em);
margin-top: calc(var(--hair) * -1);
}
.projects__item:not(.projects__item--wide) .projects__meta { width: 50%; }
.projects__name {
display: flex;
align-items: center;
min-height: var(--cell);
padding: 0 var(--space-m);
border: var(--hair) solid var(--ink);
background: var(--glass);
color: var(--ink);
font: 500 calc(var(--title) * 0.72)/1.25 var(--font-sans);
letter-spacing: -0.02em;
text-decoration: none;
backdrop-filter: blur(6px);
transition: background-color 0.25s var(--ease-expo), color 0.25s var(--ease-expo);
}
.projects__item:has(.projects__media:is(:hover, :focus-visible)) .projects__name,
.projects__name:is(:hover, :focus-visible) { background: var(--ink); color: var(--white); outline: none; }
.projects__tags { display: flex; flex-wrap: wrap; margin-top: calc(var(--hair) * -1); }
.projects__tag {
position: relative;
display: block;
flex: 0 1 auto;
height: calc(var(--cell) * 0.75);
margin-right: calc(var(--hair) * -1);
background: var(--ink);
color: var(--ink);
font: 500 calc(var(--unit) * 0.5)/1.5 var(--font-sans);
text-decoration: none;
outline: none;
}
.projects__tag span {
display: flex;
align-items: center;
height: 100%;
padding: 0 1.4em;
border: var(--hair) solid var(--ink);
background: var(--paper);
white-space: nowrap;
transform: translate(var(--lift-x, 0px), var(--lift-y, 0px));
transition: transform var(--t-panel) var(--ease-expo), background-color var(--t-panel) var(--ease-expo);
}
@media (hover: hover) and (pointer: fine) {
.projects__tag:hover span { --lift-x: 0.5em; --lift-y: -0.5em; }
}
.projects__tag:focus-visible span { --lift-x: 0.5em; --lift-y: -0.5em; outline: 2px solid var(--ink); outline-offset: 3px; }
.projects__tag:active span { --lift-x: 0px; --lift-y: 0px; background: var(--pressed); }
@media (max-width: 767px) {
.projects { grid-template-columns: minmax(0, 1fr); gap: var(--space-l) 0; }
.projects__item--wide, .projects__item--right, .projects__item--left { grid-column: 1; grid-row: auto; margin: 0; }
.projects__meta, .projects__item:not(.projects__item--wide) .projects__meta { width: 100%; }
.projects__tag { flex: 1 1 auto; height: var(--tap); }
.projects__tag span { justify-content: center; }
}
</style>
<script>
(() => {
const still = matchMedia('(prefers-reduced-motion: reduce)');
const colours = (canvas) => {
const style = getComputedStyle(canvas);
const read = (name) => style.getPropertyValue(name).trim();
return { ember: read('--ember'), deep: read('--ember-deep'), plum: read('--plum'), orchid: read('--orchid'),
lilac: read('--lilac'), phosphor: read('--phosphor'), crt: read('--phosphor-deep'), paper: read('--paper'), ink: read('--ink'), font: read('--font-sans') };
};
function paintBumper(c, w, h, t, k) {
c.fillStyle = k.deep;
c.fillRect(0, 0, w, h);
const horizon = h * 0.62;
c.strokeStyle = k.ember;
c.globalAlpha = 0.28;
c.lineWidth = 1;
for (let i = -8; i <= 8; i++) {
c.beginPath();
c.moveTo(w / 2 + i * w * 0.02, horizon);
c.lineTo(w / 2 + i * w * 0.16, h);
c.stroke();
}
for (let i = 0; i < 6; i++) {
const y = horizon + (h - horizon) * ((i + (t * 0.35) % 1) / 6) ** 1.8;
c.beginPath(); c.moveTo(0, y); c.lineTo(w, y); c.stroke();
}
c.globalAlpha = 1;
const inset = Math.min(w, h) * 0.08;
const bulbs = 64;
const perimeter = 2 * (w + h - 4 * inset);
for (let i = 0; i < bulbs; i++) {
let d = (i / bulbs) * perimeter;
const across = w - 2 * inset;
const down = h - 2 * inset;
let x = inset, y = inset;
if (d < across) x += d;
else if ((d -= across) < down) { x += across; y += d; }
else if ((d -= down) < across) { x += across - d; y += down; }
else { y += down - (d - across); }
const lit = (i + Math.floor(t * 9)) % 4 === 0;
c.beginPath();
c.arc(x, y, Math.max(1.5, w * 0.005), 0, Math.PI * 2);
c.fillStyle = lit ? k.paper : k.ember;
c.globalAlpha = lit ? 1 : 0.45;
c.shadowColor = k.ember;
c.shadowBlur = lit ? 14 : 0;
c.fill();
}
c.globalAlpha = 1;
const size = w * 0.12;
c.font = `italic 900 ${size}px ${k.font}`;
c.textAlign = 'center';
c.textBaseline = 'middle';
const flicker = Math.sin(t * 23) > 0.96 ? 0.55 : 1;
c.shadowColor = k.ember;
c.shadowBlur = size * 0.35;
c.lineWidth = Math.max(1.5, size * 0.035);
c.strokeStyle = k.ember;
c.globalAlpha = flicker;
c.strokeText('BUMPER', w / 2, h * 0.36);
c.strokeText('CITY', w / 2, h * 0.36 + size * 0.95);
c.shadowBlur = 0;
c.fillStyle = k.paper;
c.globalAlpha = 0.9 * flicker;
c.font = `600 ${Math.max(9, w * 0.014)}px ${k.font}`;
c.fillText('T I L T Y A R D P R E S E N T S', w / 2, h * 0.2);
c.globalAlpha = 1;
}
const stars = Array.from({ length: 90 }, (_, i) => [(Math.sin(i * 91.7) * 0.5 + 0.5), (Math.sin(i * 47.3 + 2) * 0.5 + 0.5), (i % 7) / 7]);
function paintMoth(c, w, h, t, k) {
c.fillStyle = k.plum;
c.fillRect(0, 0, w, h);
const lamp = [w * 0.5, h * 0.56];
const glow = c.createRadialGradient(lamp[0], lamp[1], 0, lamp[0], lamp[1], w * 0.42);
glow.addColorStop(0, k.orchid);
glow.addColorStop(0.08, k.lilac);
glow.addColorStop(1, 'transparent');
c.globalAlpha = 0.55 + Math.sin(t * 2.1) * 0.05;
c.fillStyle = glow;
c.fillRect(0, 0, w, h);
for (const [x, y, z] of stars) {
c.globalAlpha = 0.25 + 0.6 * Math.abs(Math.sin(t * (0.6 + z) + x * 9));
c.fillStyle = k.paper;
c.fillRect(x * w, ((y + t * 0.004 * (1 + z)) % 1) * h * 0.8, 1.6 + z, 1.6 + z);
}
c.globalAlpha = 1;
c.fillStyle = k.paper;
c.beginPath();
c.arc(lamp[0], lamp[1], w * 0.028, 0, Math.PI * 2);
c.fill();
for (let m = 0; m < 3; m++) {
const a = t * (0.9 + m * 0.35) + m * 2.1;
const r = w * (0.11 + m * 0.07);
const x = lamp[0] + Math.cos(a) * r;
const y = lamp[1] + Math.sin(a * 1.3) * r * 0.55;
const flap = 0.55 + Math.abs(Math.sin(t * 14 + m)) * 0.6;
const s = w * (0.034 - m * 0.006);
c.save();
c.translate(x, y);
c.rotate(Math.cos(a) * 0.4);
c.fillStyle = m === 0 ? k.orchid : k.lilac;
for (const side of [-1, 1]) {
c.beginPath();
c.ellipse(side * s * 0.9 * flap, -s * 0.2, s * flap, s * 0.7, side * 0.5, 0, Math.PI * 2);
c.fill();
c.beginPath();
c.ellipse(side * s * 0.6 * flap, s * 0.55, s * 0.55 * flap, s * 0.45, side * -0.4, 0, Math.PI * 2);
c.fill();
}
c.fillStyle = k.plum;
c.fillRect(-s * 0.12, -s * 0.6, s * 0.24, s * 1.4);
c.restore();
}
c.fillStyle = k.paper;
c.textAlign = 'center';
c.textBaseline = 'middle';
c.font = `500 ${w * 0.1}px ${k.font}`;
c.fillText('moth hour', w / 2, h * 0.2);
}
const MAZE = 9;
const walls = (() => {
const lines = [];
let seed = 7;
const random = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
for (let y = 0; y <= MAZE; y++) for (let x = 0; x < MAZE; x++) if (y === 0 || y === MAZE || random() > 0.62) lines.push([x, y, x + 1, y]);
for (let x = 0; x <= MAZE; x++) for (let y = 0; y < MAZE; y++) if (x === 0 || x === MAZE || random() > 0.62) lines.push([x, y, x, y + 1]);
return lines;
})();
const route = [[0.5, 8.5], [0.5, 4.5], [3.5, 4.5], [3.5, 1.5], [6.5, 1.5], [6.5, 6.5], [8.5, 6.5], [8.5, 8.5], [4.5, 8.5], [0.5, 8.5]];
function paintMaze(c, w, h, t, k) {
c.fillStyle = k.crt;
c.fillRect(0, 0, w, h);
const side = Math.min(w, h) * 0.7;
const step = side / MAZE;
const ox = (w - side) / 2;
const oy = (h - side) / 2 + h * 0.04;
c.strokeStyle = k.phosphor;
c.lineWidth = Math.max(1.5, step * 0.08);
c.lineCap = 'square';
c.shadowColor = k.phosphor;
c.shadowBlur = 8;
c.globalAlpha = 0.9;
c.beginPath();
for (const [x1, y1, x2, y2] of walls) { c.moveTo(ox + x1 * step, oy + y1 * step); c.lineTo(ox + x2 * step, oy + y2 * step); }
c.stroke();
const lengths = route.slice(1).map((p, i) => Math.hypot(p[0] - route[i][0], p[1] - route[i][1]));
let d = (t * 2.2) % lengths.reduce((a, b) => a + b, 0);
let i = 0;
while (d > lengths[i]) d -= lengths[i++];
const f = d / lengths[i];
const px = route[i][0] + (route[i + 1][0] - route[i][0]) * f;
const py = route[i][1] + (route[i + 1][1] - route[i][1]) * f;
c.globalAlpha = 1;
c.fillStyle = k.phosphor;
c.shadowBlur = 16;
c.beginPath();
c.arc(ox + px * step, oy + py * step, step * 0.22, 0, Math.PI * 2);
c.fill();
c.shadowBlur = 0;
c.font = `800 ${Math.max(10, w * 0.045)}px ${k.font}`;
c.textAlign = 'center';
c.fillText('SIGNAL MAZE', w / 2, oy - step * 0.9);
c.globalAlpha = 0.18;
c.fillStyle = k.ink;
for (let y = (t * 30) % 3; y < h; y += 3) c.fillRect(0, y, w, 1);
const vignette = c.createRadialGradient(w / 2, h / 2, side * 0.4, w / 2, h / 2, Math.max(w, h) * 0.75);
vignette.addColorStop(0, 'transparent');
vignette.addColorStop(1, k.ink);
c.globalAlpha = 0.7;
c.fillStyle = vignette;
c.fillRect(0, 0, w, h);
c.globalAlpha = 1;
}
const painters = { bumper: paintBumper, moth: paintMoth, maze: paintMaze };
function run(canvas) {
const context = canvas.getContext('2d');
const paint = painters[canvas.dataset.art];
const palette = colours(canvas);
let frame = 0;
const draw = (seconds) => paint(context, canvas.clientWidth, canvas.clientHeight, seconds, palette);
const fit = () => {
const density = Math.min(2, devicePixelRatio || 1);
canvas.width = canvas.clientWidth * density;
canvas.height = canvas.clientHeight * density;
context.setTransform(density, 0, 0, density, 0, 0);
draw(performance.now() / 1000);
};
const tick = (now) => { draw(now / 1000); frame = requestAnimationFrame(tick); };
new ResizeObserver(fit).observe(canvas);
new IntersectionObserver(([entry]) => {
cancelAnimationFrame(frame);
if (entry.isIntersecting && !still.matches) frame = requestAnimationFrame(tick);
}).observe(canvas);
document.fonts.ready.then(fit);
}
for (const root of document.querySelectorAll('.projects')) root.querySelectorAll('.projects__art').forEach(run);
})();
</script>