kitbash Connect agent
Components

Project panes

Floating panes with corner brackets for drawing, text and credits; they open in sequence, drag around, close and reopen.

Part of the style

Shelf Atelier

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #f8e2c6;
  --paper: #20201f;
  --line: #58584e;
  --line-soft: #3d3d37;
  --scrim: rgba(248, 226, 198, 0.2);
}
</style>

<section class="panes" aria-label="Project _A01, Casa Ribera">
  <div class="panes__bar">
    <span class="panes__code">_A01</span>
    <button class="panes__reopen" type="button">_reopen all</button>
  </div>

  <article class="panes__pane panes__pane--drawing" style="--x: 4%; --y: 72px;">
    <button class="panes__close" type="button" aria-label="Close drawing">
      <svg width="17" height="17" viewBox="0 0 17 17" fill="none" aria-hidden="true"><path d="M1 1L16 16M16 1L1 16" /></svg>
    </button>
    <svg class="panes__drawing" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Isometric line drawing of a house on a garden plot"></svg>
  </article>

  <article class="panes__pane panes__pane--text" style="--x: 37%; --y: 16px;">
    <button class="panes__close" type="button" aria-label="Close text">
      <svg width="17" height="17" viewBox="0 0 17 17" fill="none" aria-hidden="true"><path d="M1 1L16 16M16 1L1 16" /></svg>
    </button>
    <p class="panes__place">RIBERA ALTA (ES)</p>
    <h2 class="panes__title">Casa Ribera</h2>
    <p class="panes__subtitle">A house for two families and one long table</p>
    <div class="panes__body is-truncated">
      <p>The plot is an old orange grove, narrow and long, with a well at the far end. The house stays low and thin so the trees can keep their light, and every room opens onto the same covered walk.</p>
      <p>We drew it first as a model the size of a shoebox and kept it on the studio shelf for a year. Each time someone moved it, the roof turned a little, until it faced the well.</p>
      <p>The table runs the whole length of the walk: forty seats for the harvest, four on a Tuesday.</p>
    </div>
    <button class="panes__more" type="button">_read more</button>
  </article>

  <article class="panes__pane panes__pane--credits" style="--x: 66%; --y: 250px;">
    <button class="panes__close" type="button" aria-label="Close credits">
      <svg width="17" height="17" viewBox="0 0 17 17" fill="none" aria-hidden="true"><path d="M1 1L16 16M16 1L1 16" /></svg>
    </button>
    <dl class="panes__facts">
      <div><dt>Team:</dt> <dd>Ojeda_Brandt</dd></div>
      <div class="panes__list"><dt>Collaborators:</dt>
        <dd>Lucía Ferrer_structure</dd>
        <dd>Bram De Wolf_landscape</dd>
      </div>
      <div><dt>Status:</dt> <dd>Under construction</dd></div>
      <div><dt>Size:</dt> <dd>M</dd></div>
      <div><dt>Year:</dt> <dd>2024</dd></div>
    </dl>
  </article>
</section>

<style>
  .panes {
    position: relative;
    height: clamp(560px, 62vw, 700px);
    overflow: hidden;
    padding: var(--edge);
    background: var(--paper);
    color: var(--ink);
    touch-action: pan-y;
  }
  .panes__bar {
    position: absolute;
    left: var(--edge);
    right: var(--edge);
    bottom: var(--edge);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: -12px;
  }
  .panes__code {
    font-weight: var(--weight-bold);
  }
  .panes__reopen,
  .panes__more {
    min-height: calc(var(--tap) / 0.88);
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: var(--weight-bold);
    letter-spacing: inherit;
    cursor: pointer;
  }
  .panes__reopen:hover,
  .panes__more:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--hair);
    text-underline-offset: 3px;
  }
  .panes button:focus-visible {
    outline: var(--hair) solid var(--ink);
    outline-offset: 2px;
  }

  /* No border: four thin corner brackets drawn as background strokes. */
  .panes__pane {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 32%;
    padding: 32px;
    background:
      linear-gradient(var(--ink), var(--ink)) left top / var(--corner) var(--hair),
      linear-gradient(var(--ink), var(--ink)) left top / var(--hair) var(--corner),
      linear-gradient(var(--ink), var(--ink)) right top / var(--corner) var(--hair),
      linear-gradient(var(--ink), var(--ink)) right top / var(--hair) var(--corner),
      linear-gradient(var(--ink), var(--ink)) left bottom / var(--corner) var(--hair),
      linear-gradient(var(--ink), var(--ink)) left bottom / var(--hair) var(--corner),
      linear-gradient(var(--ink), var(--ink)) right bottom / var(--corner) var(--hair),
      linear-gradient(var(--ink), var(--ink)) right bottom / var(--hair) var(--corner),
      var(--paper);
    background-repeat: no-repeat;
    cursor: grab;
    user-select: none;
    opacity: 0;
    scale: 0.9;
    pointer-events: none;
    transition: opacity var(--time) var(--ease), scale 250ms var(--ease);
    transition-delay: calc(var(--order, 0) * 120ms);
  }
  .panes__pane.is-active {
    opacity: 1;
    scale: 1;
    pointer-events: auto;
  }
  .panes__pane.is-dragging {
    cursor: grabbing;
  }
  .panes__pane--text {
    width: 28%;
  }
  .panes__pane--credits {
    width: 30%;
  }
  /* Panes open from scale 0.9, so their controls are drawn a little larger to stay 44 px at every moment. */
  .panes__close {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: calc(var(--tap) / 0.88);
    height: calc(var(--tap) / 0.88);
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
  }
  .panes__close path {
    stroke: currentColor;
    stroke-width: var(--hair);
  }
  .panes__drawing {
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .panes__drawing polygon,
  .panes__drawing polyline {
    fill: var(--paper);
    stroke: var(--ink);
    stroke-width: var(--stroke);
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  .panes__drawing .panes__ground {
    stroke: var(--line);
  }
  .panes__place,
  .panes__title,
  .panes__subtitle {
    margin: 0;
    font-size: var(--text);
    font-weight: var(--weight-bold);
  }
  .panes__subtitle {
    margin-bottom: var(--space-m);
  }
  .panes__body p {
    margin: 0 0 var(--space-m);
  }
  .panes__body.is-truncated {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 8;
  }
  .panes__body.is-truncated p {
    display: inline;
  }
  .panes__body.is-truncated p + p::before {
    content: " ";
  }
  .panes__more[hidden] {
    display: none;
  }
  .panes__facts {
    margin: 0;
  }
  .panes__facts dt {
    display: inline;
    font-weight: var(--weight-bold);
  }
  .panes__facts dd {
    display: inline;
    margin: 0;
  }
  .panes__list dd {
    display: block;
    padding-left: var(--indent);
  }

  /* Narrow screens: the panes stack in reading order and stay put. */
  @media (max-width: 900px) {
    .panes {
      height: auto;
      padding-bottom: calc(var(--edge) + var(--tap) + var(--space-s));
    }
    .panes__pane,
    .panes__pane--text,
    .panes__pane--credits {
      position: relative;
      left: auto;
      top: auto;
      width: auto;
      margin-bottom: var(--space-m);
      cursor: auto;
      translate: none !important;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .panes__pane {
      transition: none;
    }
  }
</style>

<script>
  (() => {
    const NS = 'http://www.w3.org/2000/svg';
    const COS30 = Math.cos(Math.PI / 6);
    const project = ([x, y, z]) => [(x - y) * COS30, (x + y) * 0.5 - z];
    const pointsOf = (corners) => corners.map((corner) => project(corner).map((n) => n.toFixed(2)).join(',')).join(' ');
    const face = (corners, className) => {
      const node = document.createElementNS(NS, 'polygon');
      node.setAttribute('points', pointsOf(corners));
      if (className) node.setAttribute('class', className);
      return node;
    };
    const box = (x, y, z, w, d, h) => [
      face([[x + w, y, z], [x + w, y + d, z], [x + w, y + d, z + h], [x + w, y, z + h]]),
      face([[x, y + d, z], [x + w, y + d, z], [x + w, y + d, z + h], [x, y + d, z + h]]),
      face([[x, y, z + h], [x + w, y, z + h], [x + w, y + d, z + h], [x, y + d, z + h]]),
    ];
    const gableHouse = (x, y, z, w, d, h, roof) => {
      const eave = z + h;
      return [
        ...box(x, y, z, w, d, h).slice(0, 2),
        face([[x, y, eave], [x + w, y, eave], [x + w, y + d / 2, eave + roof], [x, y + d / 2, eave + roof]]),
        face([[x, y + d, eave], [x + w, y + d, eave], [x + w, y + d / 2, eave + roof], [x, y + d / 2, eave + roof]]),
        face([[x + w, y, eave], [x + w, y + d, eave], [x + w, y + d / 2, eave + roof]]),
      ];
    };

    function drawHouse(svg) {
      svg.append(face([[0, 0, 0], [160, 0, 0], [160, 70, 0], [0, 70, 0]], 'panes__ground'));
      for (let tree = 0; tree < 4; tree += 1) svg.append(...box(14 + tree * 22, 6, 0, 8, 8, 14 + (tree % 2) * 6));
      svg.append(...gableHouse(20, 30, 0, 110, 22, 14, 10));
      svg.append(...box(20, 54, 0, 110, 10, 2));
      svg.append(...box(140, 20, 0, 10, 10, 6));
      const bounds = svg.getBBox();
      svg.setAttribute('viewBox', `${bounds.x - 4} ${bounds.y - 4} ${bounds.width + 8} ${bounds.height + 8}`);
    }

    const stacked = matchMedia('(max-width: 900px)');

    function makeDraggable(root, pane, raise) {
      let start = null;
      pane.addEventListener('pointerdown', (event) => {
        if (stacked.matches || event.target.closest('button')) return;
        raise(pane);
        const box = pane.getBoundingClientRect();
        const area = root.getBoundingClientRect();
        start = { x: event.clientX, y: event.clientY, left: box.left - area.left, top: box.top - area.top, area, box };
        pane.setPointerCapture(event.pointerId);
        pane.classList.add('is-dragging');
      });
      pane.addEventListener('pointermove', (event) => {
        if (!start) return;
        const left = Math.min(Math.max(0, start.left + event.clientX - start.x), start.area.width - start.box.width);
        const top = Math.min(Math.max(0, start.top + event.clientY - start.y), start.area.height - start.box.height);
        pane.style.left = `${left}px`;
        pane.style.top = `${top}px`;
      });
      const stop = () => {
        start = null;
        pane.classList.remove('is-dragging');
      };
      pane.addEventListener('pointerup', stop);
      pane.addEventListener('pointercancel', stop);
    }

    function setUp(root) {
      const panes = [...root.querySelectorAll('.panes__pane')];
      let layer = 1;
      const raise = (pane) => {
        layer += 1;
        pane.style.zIndex = layer;
      };
      const openAll = () => panes.forEach((pane) => pane.classList.add('is-active'));

      drawHouse(root.querySelector('.panes__drawing'));
      panes.forEach((pane, order) => {
        pane.style.setProperty('--order', order);
        makeDraggable(root, pane, raise);
        pane.querySelector('.panes__close').addEventListener('click', () => pane.classList.remove('is-active'));
      });
      root.querySelector('.panes__reopen').addEventListener('click', openAll);

      const body = root.querySelector('.panes__body');
      const more = root.querySelector('.panes__more');
      more.addEventListener('click', () => {
        body.classList.remove('is-truncated');
        more.hidden = true;
      });

      const firstView = new IntersectionObserver((entries) => {
        if (!entries.some((entry) => entry.isIntersecting)) return;
        firstView.disconnect();
        openAll();
      }, { threshold: 0.2 });
      firstView.observe(root);
    }

    document.querySelectorAll('.panes').forEach(setUp);
  })();
</script>

Similar components

Work cards

Work cards

Colour specimen

Colour specimen

Feature cards

Feature cards

Fret tiles

Fret tiles

News cards

News cards

Edition slips

Edition slips

Feature cells

Feature cells

Card rail

Card rail