Skip to content

Commit

Permalink
feat(frontend): display accessibility issues on top
Browse files Browse the repository at this point in the history
Add function to copy the a11y issue target into the clipboard
  • Loading branch information
jmiguelv committed Jul 19, 2024
1 parent 93af00b commit 6fc8cb9
Showing 1 changed file with 59 additions and 34 deletions.
93 changes: 59 additions & 34 deletions frontend/src/routes/_qa/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,27 @@
/** @type {import('./$types').PageData} */
export let data;
/**
* @param {string} text
*/
function copyTargetToClipboard(text) {
navigator.clipboard.writeText(`inspect($$("${text}")[0])`);
alert('Copied to clipboard!');
}
</script>

<article>
<h1>QA</h1>

{#if data.prerender}
<section id="qa">
<hgroup>
<h2>Build errors</h2>
<p><strong>{data.prerender.length}</strong> build errors found!</p>
</hgroup>
<table>
<thead>
<tr>
<th>Timestamp</th>
<th>Path</th>
<th>Referrer</th>
<th>Message</th>
</tr>
</thead>
<tbody>
{#each data.prerender as error}
<tr>
<td>{error.timestamp}</td>
<td>{error.path}</td>
<td><BaseLink href={error.referrer}>{error.referrer}</BaseLink></td>
<td>{error.message}</td>
</tr>
{/each}
</tbody>
</table>
</section>
{/if}

{#if Object.keys(data.axe).length > 0}
<section id="axe">
<h2>Accessibility issues</h2>
{#each Object.keys(data.axe) as page}
<hgroup>
<h3><BaseLink href={page}>{page}</BaseLink></h3>
<p><strong>{data.axe[page].length}</strong> accessibility issues found!</p>
</hgroup>
<h3>
<BaseLink href={page}>{page}</BaseLink>
<small>{data.axe[page].length.toLocaleString()} accessibility issues found!</small>
</h3>
<table>
<thead>
<tr>
Expand All @@ -61,7 +40,14 @@
<td>{violation.id}</td>
<td>{violation.impact}</td>
<td>{violation.description}</td>
<td>{violation.nodes[0].target}</td>
<td>
<a
href="#"
class="copy-to-clipboard"
on:click|preventDefault={copyTargetToClipboard(violation.nodes[0].target)}
>{violation.nodes[0].target}</a
>
</td>
<td><a href={violation.helpUrl}>{violation.help}</a></td>
</tr>
{/each}
Expand All @@ -70,4 +56,43 @@
{/each}
</section>
{/if}

{#if data.prerender}
<section id="qa">
<hgroup>
<h2>Build errors</h2>
<h3><small>{data.prerender.length} build errors found!</small></h3>
</hgroup>
<table>
<thead>
<tr>
<th>Timestamp</th>
<th>Path</th>
<th>Referrer</th>
<th>Message</th>
</tr>
</thead>
<tbody>
{#each data.prerender as error}
<tr>
<td>{error.timestamp}</td>
<td>{error.path}</td>
<td><BaseLink href={error.referrer}>{error.referrer}</BaseLink></td>
<td>{error.message}</td>
</tr>
{/each}
</tbody>
</table>
</section>
{/if}
</article>

<style>
table {
width: 100%;
}
.copy-to-clipboard {
cursor: copy;
}
</style>

0 comments on commit 6fc8cb9

Please sign in to comment.