Skip to content

The design language that makes your AI harness better at design.

JavaScript
21.5 KB
Raw Blame
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Region map · Impeccable</title>
  <style>
    /* Fonts ship beside this page (fonts/), declared with their variable weight ranges. */
    @font-face { font-family: "Albert Sans"; src: url(fonts/albertsans.ttf); font-weight: 100 900; }
    @font-face { font-family: "Alumni Sans"; src: url(fonts/alumnisans.ttf); font-weight: 100 900; }
    @font-face { font-family: "JetBrains Mono"; src: url(fonts/jetbrainsmono.ttf); font-weight: 100 800; }
/*__KS_KIT__*/
    :root { font: 400 14px/1.5 var(--ks-font); color: var(--ks-text); background: var(--ks-paper); }
    button, a { font: inherit; }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body { margin: 0; }
    button, select, a { font: inherit; }
    :is(button, select, a, summary):focus-visible { outline: 2px solid var(--ks-focus-ring); outline-offset: 3px; }
    ::selection { background: oklch(82% 0.07 188); }
    header {
      min-height: 72px;
      display: flex;
      align-items: baseline;
      gap: 20px;
      padding: 18px 28px 14px;
      border-bottom: 1px solid var(--ks-rule);
    }
    h1 { font: 300 34px/1.04 var(--ks-font-display); font-variation-settings: 'wght' 300; color: var(--ks-ink); margin: 0; }
    header p { margin: 0; color: var(--ks-text-muted); font-size: var(--ks-type-ui-size); }
    header a { margin-left: auto; font-size: var(--ks-type-ui-size); }
    #sheets { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; font-size: var(--ks-type-ui-size); }
    #sheets:empty { display: none; }
    .layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: calc(100dvh - 72px); }
    nav { border-right: 1px solid var(--ks-rule); overflow: auto; padding: 18px 14px; }
    #related { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: var(--ks-type-label-size); color: var(--ks-text-muted); }
    #related:empty { display: none; }
    main { min-width: 0; overflow: auto; padding: 26px 28px; }
    .heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 22px; }
    h2 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 8px; font-weight: 500; color: var(--ks-ink); }
    #explanation { margin: 0; max-width: 65ch; }
    #explanation.error { color: var(--ks-vermilion); }
    #next { white-space: nowrap; }
    .inspection { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
    .section-title { display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: 12px; margin-bottom: 12px; }
    h3 { font: 400 var(--ks-type-eyebrow-size)/1.3 var(--ks-mono); letter-spacing: var(--ks-type-eyebrow-track); text-transform: uppercase; color: var(--ks-text-muted); margin: 0; }
    .section-title label { font-size: var(--ks-type-label-size); color: var(--ks-text-muted); }
    .context { height: clamp(280px, 48vh, 580px); box-shadow: 0 0 0 1px var(--ks-rule); }
    .context svg { display: block; width: 100%; height: 100%; }
    .pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
    figure { margin: 0; min-width: 0; }
    figcaption { font-size: var(--ks-type-label-size); color: var(--ks-text-muted); margin-bottom: 8px; }
    .crop {
      height: clamp(220px, 35vh, 440px);
      box-shadow: 0 0 0 1px var(--ks-rule);
      display: grid;
      place-items: center;
      overflow: auto;
    }
    .crop svg { display: block; width: 100%; height: 100%; }
    .crop.zoom { display: block; }
    .crop.zoom svg { max-width: none; max-height: none; margin: auto; }
    .legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; color: var(--ks-text-muted); font-size: var(--ks-type-label-size); }
    .key { display: inline-flex; align-items: center; gap: 7px; }
    .swatch { width: 12px; height: 12px; border: 2px solid var(--ks-patina-deep); }
    .swatch.covering { border: 2px dashed var(--ks-vermilion); }
    #impact { font-size: var(--ks-type-ui-size); margin: 14px 0; max-width: 55ch; }
    .details { margin-top: 32px; border-top: 1px solid var(--ks-rule); padding-top: 16px; }
    details { margin: 0 0 16px; }
    summary { cursor: pointer; font-size: var(--ks-type-ui-size); color: var(--ks-text-muted); }
    summary:hover { color: var(--ks-ink); }
    details p { font-size: var(--ks-type-label-size); margin: 8px 0; overflow-wrap: anywhere; }
    .issue { padding: 10px 0; font-size: var(--ks-type-label-size); border-bottom: 1px solid var(--ks-rule); }
    .issue b { display: block; font-weight: 600; color: var(--ks-ink); }
    .issue.error b { color: var(--ks-vermilion); }
    .empty { color: var(--ks-text-muted); font-size: var(--ks-type-ui-size); }
    @media(max-width: 1000px) {
      .layout { grid-template-columns: 196px minmax(0, 1fr); }
      .inspection { grid-template-columns: 1fr; }
      .context { height: 360px; }
      .crop { height: 280px; }
    }
    @media(max-width: 600px) {
      header { min-height: 0; padding: 16px; flex-wrap: wrap; gap: 6px 16px; }
      h1 { font-size: 28px; }
      header p { font-size: var(--ks-type-label-size); }
      .layout { display: block; height: auto; }
      nav { height: 190px; border-right: 0; border-bottom: 1px solid var(--ks-rule); }
      main { padding: 18px 16px; }
      .heading { flex-wrap: wrap; }
      .context { height: 300px; }
      .crop { height: 220px; }
    }
    .strip-row { margin-bottom: 18px; }
    .strip-row .ks-instrument-strip { width: 100%; }
    .strip-row .ks-instrument-key { flex: 1; justify-content: center; }
    nav.docs-kinpaku .skills-sidebar-list a { display: flex; align-items: baseline; gap: 10px; overflow-wrap: anywhere; }
    nav.docs-kinpaku .skills-sidebar-list a .name { flex: 1; }
    .status { font: 500 var(--ks-type-label-size)/1 var(--ks-mono); white-space: nowrap; color: var(--ks-text); font-variant-numeric: tabular-nums; font-weight: 500; }
    .is-error .status { color: var(--ks-vermilion); }
    .text-action { border: 0; background: none; padding: 0 2px; color: var(--ks-link-on-paper); font: inherit; text-decoration: underline; text-decoration-color: var(--ks-link-on-paper-line); text-underline-offset: 3px; cursor: pointer; }
    .text-action:hover { text-decoration-color: var(--ks-link-on-paper-line-hover); }
    a { color: var(--ks-link-on-paper); text-decoration-color: var(--ks-link-on-paper-line); text-underline-offset: 3px; }
    a:hover { text-decoration-color: var(--ks-link-on-paper-line-hover); }
    #related .text-action { font-size: var(--ks-type-label-size); }
    .zoom-strip .ks-instrument-key { padding: 0 12px 0 10px; }
  </style>
</head>
<body>
  <header>
    <h1>Region map</h1>
    <p id="summary"></p>
    <a href="report.json" target="_blank" rel="noopener">Technical report</a>
  </header>
  <div class="layout">
    <nav class="docs-kinpaku" aria-label="Regions">
      <div class="strip-row"><div class="ks-instrument-strip is-paper" role="group" aria-label="Which regions to list">
        <button type="button" class="ks-instrument-key" id="problems" aria-pressed="true">Inspect</button>
        <button type="button" class="ks-instrument-key" id="all" aria-pressed="false">All regions</button>
      </div></div>
      <ul class="skills-sidebar-list" id="list"></ul>
    </nav>
    <main>
      <div class="heading">
        <div><h2 id="title">Check the region map</h2><p id="explanation"></p><div id="related"></div></div>
        <button type="button" class="ks-button ks-button-secondary" id="next">Next check</button>
      </div>
      <div id="sheets" aria-label="Comparison sheets"></div>
      <div id="inspection" class="inspection">
        <section>
          <div class="section-title"><h3>In the comp</h3><button type="button" class="ks-switch" id="context-toggle" aria-pressed="false"><span class="ks-switch-track" aria-hidden="true"><span class="ks-switch-knob"></span></span><span class="ks-switch-label">Whole comp</span></button></div>
          <div class="context"><svg id="context" role="img" aria-label="Selected asset and overlapping boxes in the original comp"></svg></div>
          <div class="legend">
            <span class="key"><span class="swatch"></span><span id="asset-key">This asset</span></span>
            <span class="key" id="covering-key"><span class="swatch covering"></span>Box covering it</span>
          </div>
        </section>
        <section>
          <div class="section-title"><h3>What gets compared</h3><div class="ks-instrument-strip is-paper zoom-strip" id="zoom" role="group" aria-label="Zoom"><button type="button" class="ks-instrument-key" data-zoom="fit" aria-pressed="true">Fit</button><button type="button" class="ks-instrument-key" data-zoom="1" aria-pressed="false">100%</button><button type="button" class="ks-instrument-key" data-zoom="2" aria-pressed="false">200%</button><button type="button" class="ks-instrument-key" data-zoom="4" aria-pressed="false">400%</button></div></div>
          <div class="pair">
            <figure><figcaption>Original crop</figcaption><div class="crop" id="original"></div></figure>
            <figure><figcaption id="ignored-label">Pixels ignored by the checker</figcaption><div class="crop" id="ignored"></div></figure>
          </div>
          <p id="impact"></p>
        </section>
      </div>
      <div class="details">
        <details><summary>Region details</summary><div id="details"></div></details>
        <details id="diagnostics"><summary id="diagnostics-label">Other map findings</summary><div id="issues"></div></details>
      </div>
    </main>
  </div>
  <script type="application/json" id="data">__REPORT_JSON__</script>
  <script>
    const data = JSON.parse(document.getElementById('data').textContent);
    const $ = id => document.getElementById(id);
    const ns = 'http://www.w3.org/2000/svg';
    const errors = id => data.issues.filter(i => i.regionId === id && i.severity === 'error');
    // A partial exclusion needs visual inspection even when all boxes are valid.
    // Do not claim it is a failed asset or let zero hard errors hide it.
    const partialMasks = data.regions.filter(r => r.reference?.excludedPixels > 0 && !r.reference.fullyExcluded);
    const problemRegions = data.regions.filter(r => errors(r.id).length || r.reference?.excludedPixels > 0)
      .sort((a, b) => Number(!!errors(b.id).length) - Number(!!errors(a.id).length)
        || (b.reference?.excludedFraction || 0) - (a.reference?.excludedFraction || 0));
    const affectedBy = id => data.regions.filter(r => r.reference?.regions.some(m => m.id === id));
    const percent = ref => (100 * ref.excludedFraction).toFixed(1).replace(/\.0$/, '');
    let selected = null;
    let filter = problemRegions.length ? 'problems' : 'all';
    let wholeComp = false;
    let zoomValue = 'fit';

    function name(region) {
      return region.id.replace(/-plate$/, /photo/i.test(region.note || '') ? ' photo' : ' artwork').replace(/-/g, ' ').replace(/^./, c => c.toUpperCase());
    }
    function element(tag, text, className) {
      const el = document.createElement(tag);
      el.textContent = text;
      if (className) el.className = className;
      return el;
    }
    function svgElement(tag, attrs) {
      const el = document.createElementNS(ns, tag);
      for (const [key, value] of Object.entries(attrs)) el.setAttribute(key, value);
      return el;
    }
    function renderList() {
      $('list').replaceChildren();
      $('problems').textContent = `Inspect (${problemRegions.length})`;
      $('all').textContent = `All (${data.regions.length})`;
      for (const key of ['problems', 'all']) $(key).setAttribute('aria-pressed', String(filter === key));
      for (const r of filter === 'problems' ? problemRegions : data.regions) {
        const li = document.createElement('li');
        const link = element('a', '', errors(r.id).length ? 'is-error' : r.reference?.excludedPixels ? 'is-masked' : '');
        link.href = `#region=${encodeURIComponent(r.id)}`;
        if (selected?.id === r.id) link.setAttribute('aria-current', 'page');
        link.append(element('span', name(r), 'name'));
        if (errors(r.id).length || r.reference?.excludedPixels) {
          const label = errors(r.id).length ? 'Error' : `${percent(r.reference)}%`;
          const badge = element('span', label, 'status');
          badge.title = errors(r.id).length ? 'Map error' : `${label} excluded. Inspect the foreground bounds.`;
          link.setAttribute('aria-description', badge.title);
          link.append(badge);
        }
        link.onclick = event => { event.preventDefault(); select(r); };
        li.append(link);
        $('list').append(li);
      }
      if (!$('list').children.length) $('list').append(element('li', 'No drawable regions have errors or masked pixels. Crop accuracy still needs visual inspection; rejected entries are in Other map findings.', 'empty'));
    }
    function renderContext() {
      if (!selected) return;
      const svg = $('context');
      svg.replaceChildren();
      const covering = selected.reference ? selected.reference.regions.map(m => data.regions.find(r => r.id === m.id)).filter(Boolean) : affectedBy(selected.id);
      const boxes = [selected, ...covering];
      const left = Math.min(...boxes.map(r => r.px.x));
      const top = Math.min(...boxes.map(r => r.px.y));
      const right = Math.max(...boxes.map(r => r.px.x + r.px.w));
      const bottom = Math.max(...boxes.map(r => r.px.y + r.px.h));
      const padding = Math.max(25, (right - left) * .18);
      const x = Math.max(0, left - padding), y = Math.max(0, top - padding);
      const w = Math.min(data.compSize.width, right + padding) - x;
      const h = Math.min(data.compSize.height, bottom + padding) - y;
      svg.setAttribute('viewBox', wholeComp ? `0 0 ${data.compSize.width} ${data.compSize.height}` : `${x} ${y} ${w} ${h}`);
      svg.append(svgElement('image', { href: 'comp.png', width: data.compSize.width, height: data.compSize.height }));
      for (const r of covering) {
        svg.append(svgElement('rect', { x: r.px.x, y: r.px.y, width: r.px.w, height: r.px.h, fill: 'oklch(52% 0.16 35 / 0.07)', stroke: 'oklch(52% 0.16 35)', 'stroke-width': 2, 'stroke-dasharray': '6 3', 'vector-effect': 'non-scaling-stroke' }));
      }
      svg.append(svgElement('rect', { x: selected.px.x, y: selected.px.y, width: selected.px.w, height: selected.px.h, fill: 'none', stroke: 'oklch(45% 0.10 190)', 'stroke-width': 3, 'vector-effect': 'non-scaling-stroke' }));
      $('covering-key').hidden = covering.length === 0;
      $('covering-key').lastChild.textContent = selected.reference ? ' Overlapping foreground' : ' Affected artwork';
      $('context-toggle').setAttribute('aria-pressed', String(wholeComp));
    }
    function renderCrop(target, ignored) {
      target.replaceChildren();
      const svg = svgElement('svg', { viewBox: `0 0 ${selected.px.w} ${selected.px.h}`, role: 'img', 'aria-label': `${ignored ? 'Ignored pixels on' : 'Original crop of'} ${name(selected)}` });
      svg.append(svgElement('image', { href: selected.cropPath, width: selected.px.w, height: selected.px.h }));
      if (ignored && selected.reference) {
        const defs = svgElement('defs', {});
        const pattern = svgElement('pattern', { id: 'excluded', width: 8, height: 8, patternUnits: 'userSpaceOnUse' });
        pattern.append(svgElement('rect', { width: 8, height: 8, fill: 'oklch(52% 0.16 35 / 0.12)' }));
        pattern.append(svgElement('path', { d: 'M-2 2L2-2M0 8L8 0M6 10L10 6', stroke: 'oklch(52% 0.16 35)', 'stroke-width': 1.2 }));
        defs.append(pattern); svg.append(defs);
        for (const mask of selected.reference.regions) {
          const p = mask.cropPx;
          svg.append(svgElement('rect', { x: p.x, y: p.y, width: p.w, height: p.h, fill: 'url(#excluded)' }));
        }
      }
      const zoom = zoomValue;
      target.className = `crop ${zoom === 'fit' ? '' : 'zoom'}`;
      if (zoom !== 'fit') {
        svg.style.width = `${selected.px.w * Number(zoom)}px`;
        svg.style.height = `${selected.px.h * Number(zoom)}px`;
      }
      target.append(svg);
    }
    function select(r) {
      selected = r;
      $('title').textContent = name(r);
      const ref = r.reference;
      const percentage = ref ? percent(ref) : '0';
      const sources = (ref?.regions || []).map(m => data.regions.find(r => r.id === m.id)).filter(Boolean);
      const affected = affectedBy(r.id);
      const covering = sources.map(name).join(', ');
      $('explanation').className = errors(r.id).length ? 'error' : '';
      if (ref?.fullyExcluded) {
        $('explanation').textContent = `The “${covering}” box hides this entire asset from the checker.`;
        $('impact').textContent = 'Every hatched pixel is ignored. Nothing remains to compare, even if the generated asset is perfect. The covering box needs correcting.';
      } else if (ref?.excludedPixels) {
        $('explanation').textContent = `${percentage}% excluded. Check the foreground bounds.`;
        $('impact').textContent = 'Hatching should cover foreground text or controls only. If it covers artwork in the gaps, split the foreground into tighter boxes. Keep every text element.';
      } else if (affected.length) {
        $('explanation').textContent = `This box excludes pixels from ${affected.length} ${affected.length === 1 ? 'asset' : 'assets'}.`;
        $('impact').textContent = 'The entire overlap is masked, including empty space. Bound separate text elements separately; use a container only to describe their layout, retaining every child.';
      } else {
        $('explanation').textContent = ref ? 'No overlapping text or controls hide this asset from the checker.' : 'This region is built in code. Check that its box names one element.';
        $('impact').textContent = ref ? 'All pixels in this crop remain available for comparison. Still check that the crop contains the right artwork.' : 'Code regions that overlap artwork can exclude those pixels from asset comparison. Containers are treated separately.';
      }
      $('related').replaceChildren();
      const related = ref ? sources : affected;
      if (related.length) {
        $('related').append(element('span', ref ? 'Excluding boxes:' : 'Inspect affected assets:'));
        for (const other of related) {
          const button = element('button', name(other), 'text-action');
          button.onclick = () => select(other);
          $('related').append(button);
        }
      }
      $('ignored-label').textContent = ref ? `Ignored pixels · ${percentage}%` : 'Same region';
      $('asset-key').textContent = ref ? 'Asset boundary' : 'Region boundary';
      $('details').replaceChildren();
      for (const text of [r.id, r.note, `${r.kind} · ${r.px.w} × ${r.px.h} original pixels · x ${r.px.x}, y ${r.px.y}`, r.parentId && `Parent: ${r.parentId}`, r.reviewGroup && `Review group: ${r.reviewGroup} (every member retained)`].filter(Boolean)) $('details').append(element('p', text));
      if (r.referencePath) {
        const p = element('p', '');
        const link = element('a', 'Open the actual checker reference');
        link.href = r.referencePath; link.target = '_blank'; link.rel = 'noopener';
        p.append(link); $('details').append(p);
      }
      $('details').append(element('p', 'Reference only. These images cannot ship as page assets. Inspection does not change build state or approvals.'));
      $('next').hidden = problemRegions.length < 2;
      const queueIndex = problemRegions.findIndex(p => p.id === r.id);
      $('next').textContent = queueIndex >= 0 ? `Next check (${queueIndex + 1}/${problemRegions.length})` : 'Next check';
      history.replaceState(null, '', `#region=${encodeURIComponent(r.id)}`);
      renderList(); renderContext(); renderCrop($('original'), false); renderCrop($('ignored'), true);
    }
    for (const key of ['all', 'problems']) $(key).onclick = () => { filter = key; renderList(); };
    $('next').onclick = () => select(problemRegions[(problemRegions.findIndex(r => r.id === selected.id) + 1) % problemRegions.length]);
    $('context-toggle').onclick = () => { wholeComp = !wholeComp; renderContext(); };
    for (const key of document.querySelectorAll('[data-zoom]')) key.onclick = () => {
      zoomValue = key.dataset.zoom;
      for (const other of document.querySelectorAll('[data-zoom]')) other.setAttribute('aria-pressed', String(other === key));
      if (selected) { renderCrop($('original'), false); renderCrop($('ignored'), true); }
    };
    $('summary').textContent = `${data.inputRegionCount} regions · ${data.issues.filter(i => i.severity === 'error').length} errors · ${partialMasks.length} partial masks to inspect`;
    for (const [index, sheet] of (data.comparisonSheets || []).entries()) {
      const link = element('a', `Comparison sheet ${index + 1}`);
      link.href = sheet.path; link.target = '_blank'; link.rel = 'noopener';
      $('sheets').append(link);
    }
    const otherIssues = data.issues.filter(i => i.code !== 'fully-masked' && i.code !== 'foreground-mask');
    $('diagnostics-label').textContent = `Other map findings (${otherIssues.length})`;
    for (const i of otherIssues) {
      const item = element('div', '', `issue ${i.severity}`);
      item.append(element('b', i.regionId || i.code.replaceAll('-', ' ')), element('span', i.message));
      $('issues').append(item);
    }
    const requestedRegion = new URLSearchParams(location.hash.slice(1)).get('region');
    if (data.regions.length) select(data.regions.find(r => r.id === requestedRegion) || problemRegions[0] || data.regions[0]);
    else { $('inspection').hidden = true; $('next').hidden = true; $('diagnostics').open = true; renderList(); }
  </script>
  <script>/*__KS_STRIP__*/</script>
</body>
</html>