kitbash Sign in Connect agent
Components

Card rail

A ruled rail of cards, each a name, one line and a painted picture. A card in hand gets a violet strip on top and the violet band rises over the foot of its picture. Arrow columns appear at the ends and slide the rail by one card; on phones the rail becomes a stack with the picture first.

Part of the style

Violet Difference

7 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&family=Fraunces:ital,opsz,wght@1,9..144,400..600&display=swap");
:root {
  --paper: #f1f1f1;
  --ink: #000002;
  --idle: #bcbbb8;
  --tray: #e3e2e2;
  --plate: #898680;
  --violet: #c94f47;
  --font-mark: "Fraunces", Georgia, serif;
  --font-caps: "Fraunces", Georgia, serif;
  --font-text: "Inter", "Helvetica Neue", Arial, sans-serif;
}
</style>

<section class="roster" aria-label="Quarries">
  <div class="roster__rail">
    <a class="roster__card" href="#">
      <span class="roster__name">Carrig Mór</span>
      <span class="roster__line">Green marble, one bench at a time</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="A hill cut into pale benches above ploughed fields" data-scene='{"seed":3,"eye":0.5,"horizon":0.36,"site":[-0.15,1.2,0.4],"cut":0.6}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
    <a class="roster__card" href="#">
      <span class="roster__name">Pedreira do Corvo</span>
      <span class="roster__line">The black schist of the north</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="An open pit of curved benches seen from its rim" data-scene='{"seed":11,"eye":0.8,"horizon":0.18,"site":[0.1,1.3,0.5],"dig":-1,"cut":0.75}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
    <a class="roster__card" href="#">
      <span class="roster__name">Kergonan</span>
      <span class="roster__line">Sea-washed granite, two tides a day</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="A worked headland above a pale sea" data-scene='{"seed":19,"eye":0.45,"horizon":0.42,"site":[0.3,1.8,0.5],"cut":0.4,"sea":0.02,"haze":0.4}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
    <a class="roster__card" href="#">
      <span class="roster__name">Scarth How</span>
      <span class="roster__line">Slate split by hand since 1911</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="A deep pit with many narrow benches" data-scene='{"seed":31,"eye":0.7,"horizon":0.1,"site":[-0.1,1.5,0.6],"dig":-1.4,"cut":0.85,"haze":0.2}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
    <a class="roster__card" href="#">
      <span class="roster__name">Monte da Rola</span>
      <span class="roster__line">Pink marble from a single pit</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="A small pale cutting on a distant wooded ridge" data-scene='{"seed":5,"eye":0.42,"horizon":0.5,"site":[0.2,2.2,0.5],"cut":0.3,"haze":0.3}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
    <a class="roster__card" href="#">
      <span class="roster__name">Penrallt</span>
      <span class="roster__line">The blue pennant revival</span>
      <span class="roster__frame">
        <canvas class="roster__picture" width="640" height="480" role="img" aria-label="A stepped stone hill close up, lit from the right" data-scene='{"seed":23,"eye":0.55,"horizon":0.3,"site":[0,0.9,0.3],"cut":0.9,"sun":1}'></canvas>
        <span class="roster__band" aria-hidden="true"></span>
      </span>
    </a>
  </div>
  <button class="roster__step roster__step--back" type="button" aria-label="Earlier quarries">
    <svg class="roster__arrow" viewBox="0 0 12 20" aria-hidden="true" focusable="false"><path d="M10 2 2 10l8 8"/></svg>
  </button>
  <button class="roster__step roster__step--on" type="button" aria-label="More quarries">
    <svg class="roster__arrow" viewBox="0 0 12 20" aria-hidden="true" focusable="false"><path d="m2 2 8 8-8 8"/></svg>
  </button>
</section>

<style>
  .roster {
    position: relative;
    border-block: var(--rule) solid var(--ink);
    background: var(--paper);
  }
  .roster__rail {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .roster__rail::-webkit-scrollbar {
    display: none;
  }

  /* Three and a bit cards across, so the cut-off one says there is more. */
  .roster__card {
    position: relative;
    flex: 0 0 calc(100% / 3.25);
    display: flex;
    flex-direction: column;
    padding: var(--space-l) var(--inset) var(--inset);
    border-right: var(--rule) solid var(--ink);
    color: var(--ink);
    font-family: var(--font-caps);
    line-height: var(--leading-caps);
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    scroll-snap-align: start;
  }
  .roster__card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: var(--flag);
    background: var(--violet);
    opacity: 0;
    transition: opacity var(--time) var(--ease);
  }
  .roster__name {
    font-size: var(--caps-l);
    line-height: 1.05;
    text-wrap: balance;
  }
  .roster__line {
    margin: var(--space-s) 0 var(--space-l);
    font-size: var(--caps-xs);
    text-wrap: balance;
  }
  .roster__frame {
    position: relative;
    display: block;
    margin-top: auto;
    overflow: hidden;
    background: var(--plate);
    isolation: isolate;
  }
  .roster__picture {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    opacity: 0;
    transition: opacity var(--time-slow) var(--ease);
  }
  .roster__picture.is-painted {
    opacity: 1;
  }

  /* At rest only a hairline of the violet band shows at the foot of the picture. In hand, it rises and is subtracted from the picture. */
  .roster__band {
    position: absolute;
    inset: auto 0 0;
    height: 20%;
    background: var(--violet);
    mix-blend-mode: difference;
    transform: translateY(calc(100% - var(--rule)));
    transition: transform var(--time-slow) var(--ease);
  }
  .roster__card:hover::before,
  .roster__card:focus-visible::before {
    opacity: 1;
  }
  .roster__card:hover .roster__band,
  .roster__card:focus-visible .roster__band {
    transform: translateY(0);
  }
  .roster__card:focus-visible {
    outline: none;
  }

  .roster__step {
    position: absolute;
    top: 0;
    bottom: 0;
    display: grid;
    place-items: center;
    width: var(--tap);
    padding: 0;
    border: 0 solid var(--ink);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--time) var(--ease), visibility 0s var(--time);
  }
  .roster__step--back {
    left: 0;
    border-right-width: var(--rule);
  }
  .roster__step--on {
    right: 0;
    border-left-width: var(--rule);
  }
  .roster__arrow {
    width: 0.75rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
  }
  .roster:hover .roster__step,
  .roster:focus-within .roster__step {
    opacity: 1;
  }
  .roster__step:hover,
  .roster__step:focus-visible {
    background: var(--violet);
    outline: none;
  }
  .roster .roster__step.is-spent {
    opacity: 0;
    visibility: hidden;
  }
  @media (hover: none) {
    .roster__step {
      opacity: 1;
    }
  }

  @media (max-width: 64rem) {
    .roster__card {
      flex-basis: calc(100% / 2.25);
    }
  }

  /* On a phone the rail becomes a plain stack: picture first, then the name. */
  @media (max-width: 40rem) {
    .roster__rail {
      display: block;
      overflow: visible;
    }
    .roster__card {
      padding: var(--inset) var(--gutter) var(--space-l);
      border-right: 0;
    }
    .roster__card + .roster__card {
      border-top: var(--rule) solid var(--ink);
    }
    .roster__frame {
      order: -1;
      margin: 0 0 var(--space-l);
    }
    .roster__line {
      margin-bottom: 0;
    }
    .roster__step {
      display: none;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .roster__card::before,
    .roster__picture,
    .roster__band,
    .roster__step {
      transition-duration: 0s;
    }
  }
</style>

<script>
(() => {
  /* Paints one grey landscape into a canvas: ground seen from the air, drawn column by column from near to far,
     with haze, a hill or pit cut into stone benches, and film grain. The same block sits in every part that shows a picture. */
  function paintPlate(canvas, scene) {
    const W = canvas.width, H = canvas.height;
    const context = canvas.getContext("2d");
    const image = context.createImageData(W, H);
    const s = { seed: 1, eye: 0.62, horizon: 0.3, haze: 0.25, site: [0.25, 1.5, 0.42], dig: 1, cut: 0.5, sea: -1, sun: -1, blocks: [], ...scene };

    let state = Math.imul(s.seed, 2654435761) >>> 0;
    const random = () => (state = (Math.imul(state ^ (state >>> 15), 2246822507) + 0x9e3779b9) >>> 0) / 4294967296;
    const lattice = new Uint8Array(512);
    for (let i = 0; i < 256; i++) lattice[i] = i;
    for (let i = 255; i > 0; i--) { const j = (random() * (i + 1)) | 0, kept = lattice[i]; lattice[i] = lattice[j]; lattice[j] = kept; }
    lattice.copyWithin(256, 0, 256);
    const noise = (x, y) => {
      const xi = Math.floor(x), yi = Math.floor(y);
      let fx = x - xi, fy = y - yi;
      fx *= fx * (3 - 2 * fx); fy *= fy * (3 - 2 * fy);
      const a = lattice[xi & 255], b = lattice[(xi + 1) & 255], lo = yi & 255, hi = (yi + 1) & 255;
      const n00 = lattice[a + lo], n01 = lattice[a + hi], n10 = lattice[b + lo], n11 = lattice[b + hi];
      return (n00 + (n10 - n00) * fx + (n01 - n00) * fy + (n00 - n10 - n01 + n11) * fx * fy) / 255;
    };
    const layered = (x, y, finest) => {
      let sum = 0, gain = 0.5, scale = 1;
      for (let i = 0; i < 9 && 1 / scale > finest; i++) { sum += gain * noise(x * scale + i * 17.3, y * scale - i * 9.1); gain *= 0.5; scale *= 2.03; }
      return sum;
    };
    const ramp = (lo, hi, v) => { const t = Math.min(1, Math.max(0, (v - lo) / (hi - lo))); return t * t * (3 - 2 * t); };

    /* Height and surface tone of the ground at one point. `cell` is the size of one sample there, so far ground gets less detail. */
    const spot = { height: 0, tone: 0, flat: 0 };
    const ground = (x, y, cell) => {
      const dx = x - s.site[0], dy = y - s.site[1];
      const mound = Math.exp(-(dx * dx + dy * dy) / (s.site[2] * s.site[2]));
      const range = ramp(3, 8.5, y);
      let height = layered(x * 1.1, y * 1.1, cell * 2.2) * 0.36 + s.dig * mound * 0.26 - 0.12 + range * s.eye * (0.35 + 1.5 * noise(x * 0.55 + 3, y * 0.3));
      const farmed = ramp(0.5, 0.62, noise(x * 1.7 + 40, y * 1.7 + 11)) * (1 - ramp(0.2, 0.5, mound)) * (1 - ramp(0, 0.3, range));
      height = height * (1 - 0.72 * farmed) + 0.03 * farmed;
      if (cell < 0.03) height += (1 - farmed) * 0.014 * noise(x * 60, y * 60);
      let tone = 0.1 + 0.14 * noise(x * 3.1, y * 3.1) + (cell < 0.012 ? 0.2 * (noise(x * 150, y * 150) - 0.5) : 0);
      if (farmed > 0.02) {
        const turn = Math.floor(noise(x * 2.3 + 7, y * 2.3) * 5) * 1.3;
        const furrow = cell < 0.006 ? 0.14 * Math.sin((x * Math.cos(turn) + y * Math.sin(turn)) * 190) : 0;
        tone += (0.4 + 0.22 * noise(x * 2.3 + 7, y * 2.3 + 60) + furrow - tone) * ramp(0.02, 0.5, farmed);
      }
      const track = Math.abs(noise(x * 0.9 + 80, y * 0.9 + 5) - 0.5);
      if (track < 0.006 + cell * 0.4) tone += (0.7 - tone) * 0.8 * (1 - ramp(1.8, 3.2, y));
      const worked = ramp(1 - s.cut, 1.12 - s.cut, mound + 0.25 * noise(x * 4, y * 4));
      if (worked > 0) {
        const bench = 0.03, level = height / bench, tread = Math.floor(level) + ramp(0.72, 1, level - Math.floor(level));
        height += (tread * bench - height) * worked;
        tone += (0.78 + 0.2 * noise(x * 30, y * 6) - tone) * worked;
      }
      spot.flat = 0;
      if (height < s.sea) { height = s.sea; tone = 0.6 + 0.2 * noise(x * 9, y * 40); spot.flat = 1; }
      for (const [left, front, wide, deep, tall, pale] of s.blocks) {
        const u = (x - left) / wide, v = (y - front) / deep;
        if (u > 0 && u < 1 && v > 0 && v < 1) { height += tall; tone = pale || v < 0.45 ? 1 : 0.25; spot.flat = 1; }
      }
      spot.height = height; spot.tone = tone;
    };

    const focal = H * 1.25, horizon = H * s.horizon, spread = 1.15 * W / H * 0.5625, depths = 460, reach = 9;
    const nearest = Math.max(0.1, (s.eye - 0.4) * focal / (H - horizon));
    const depth = Float32Array.from({ length: depths }, (_, k) => nearest * Math.pow(reach / nearest, k / (depths - 1)));
    const heights = new Float32Array(depths * W), tones = new Float32Array(depths * W), flats = new Uint8Array(depths * W);
    for (let k = 0; k < depths; k++) {
      const cell = depth[k] * spread / W;
      for (let c = 0; c < W; c++) {
        ground((c / W - 0.5) * depth[k] * spread, depth[k], cell);
        heights[k * W + c] = spot.height; tones[k * W + c] = spot.tone; flats[k * W + c] = spot.flat;
      }
    }

    const grey = new Float32Array(W * H), mist = 0.86;
    for (let c = 0; c < W; c++) {
      let floor = H, below = -1;
      for (let k = 1; k < depths - 1 && floor > 0; k++) {
        const i = k * W + c;
        const row = Math.max(0, Math.floor(horizon + (s.eye - heights[i]) * focal / depth[k]));
        if (row >= floor) continue;
        const slopeAcross = (heights[i + (c < W - 1)] - heights[i - (c > 0)]) / (2 * depth[k] * spread / W);
        const slopeAway = (heights[i + W] - heights[i - W]) / (depth[k + 1] - depth[k - 1]);
        const facing = (0.5 + s.sun * 0.8 * slopeAcross - 0.55 * slopeAway) / Math.sqrt(1 + slopeAcross * slopeAcross + slopeAway * slopeAway);
        const lit = tones[i] * (flats[i] ? 1 : 0.3 + 1.25 * Math.max(0, facing));
        const value = lit + (mist - 0.07 - lit) * (1 - Math.exp(-Math.pow(depth[k] * s.haze, 1.25)));
        for (let r = floor - 1; r >= row; r--) grey[r * W + c] = below < 0 ? value : below + (value - below) * (floor - r) / (floor - row);
        floor = row; below = value;
      }
      for (let r = 0; r < floor; r++) {
        const up = Math.max(0, 1 - r / (horizon + H * 0.14));
        const cloud = layered(c / W * 2.6 * spread + 9, up * 7 + s.seed, 0.01) - 0.5;
        grey[r * W + c] = mist - 0.3 * up + 0.36 * cloud * ramp(0.03, 0.45, up);
      }
    }
    for (let i = 0; i < W * H; i++) {
      const corner = Math.hypot((i % W) / W - 0.5, ((i / W) | 0) / H - 0.5);
      let v = Math.min(1, Math.max(0, grey[i] * 1.12 - 0.05));
      v = (0.75 * v * v * (3 - 2 * v) + 0.25 * v) * (1 - 0.5 * corner * corner * corner) + (random() - 0.5) * 0.075;
      image.data[i * 4] = image.data[i * 4 + 1] = image.data[i * 4 + 2] = 255 * v;
      image.data[i * 4 + 3] = 255;
    }
    context.putImageData(image, 0, 0);
    canvas.classList.add("is-painted");
  }

  /* Pictures are painted one per task, so a page full of them never blocks for long. */
  function paintInTurn(canvases) {
    const waiting = [...canvases];
    const next = () => {
      const canvas = waiting.shift();
      if (!canvas) return;
      paintPlate(canvas, JSON.parse(canvas.dataset.scene || "{}"));
      setTimeout(next, 0);
    };
    next();
  }

  document.querySelectorAll(".roster").forEach((root) => {
    const rail = root.querySelector(".roster__rail");
    const back = root.querySelector(".roster__step--back");
    const on = root.querySelector(".roster__step--on");
    const calm = matchMedia("(prefers-reduced-motion: reduce)");

    const slide = (direction) => {
      const card = rail.querySelector(".roster__card");
      rail.scrollBy({ left: direction * card.offsetWidth, behavior: calm.matches ? "auto" : "smooth" });
    };
    const markEnds = () => {
      back.classList.toggle("is-spent", rail.scrollLeft < 2);
      on.classList.toggle("is-spent", rail.scrollLeft > rail.scrollWidth - rail.clientWidth - 2);
    };

    back.addEventListener("click", () => slide(-1));
    on.addEventListener("click", () => slide(1));
    rail.addEventListener("scroll", markEnds, { passive: true });
    new ResizeObserver(markEnds).observe(rail);
    paintInTurn(root.querySelectorAll(".roster__picture"));
  });
})();
</script>

Similar components

Glass feature cards

Glass feature cards

This week

This week

Colour specimen

Colour specimen

Numbered stages on a blob

Numbered stages on a blob

Hairline feature grid

Hairline feature grid

Feature cards

Feature cards

Stepped service cards

Stepped service cards

Swatch service tiles

Swatch service tiles