Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

Skill page: to a screen reader each example is named by its prompt, and each copy button says which line it copies

Lucas Marquesaca20a82973c
diff --git a/apps/site/app/skill/page.tsx b/apps/site/app/skill/page.tsx
index a7771e0..9f27aef 100644
--- a/apps/site/app/skill/page.tsx
+++ b/apps/site/app/skill/page.tsx
@@ -42,15 +42,15 @@ export default function Skill() {
<p className="doc-p">Each figure below is the page the skill wrote for the line next to it. Move the pointer over one.</p>
<div>
{shown.map((e) => (
- <article key={e.file} className="example" data-example={e.name}>
+ <article key={e.file} className="example" data-example={e.name} aria-label={e.prompt}>
<div className="example-prompt">
{/* one exchange: the prompt, and the change asked for next */}
<div className="example-turns">
- <Command code={e.prompt} kind="prompt" label="Copy prompt" />
+ <Command code={e.prompt} kind="prompt" label={`Copy prompt: ${e.idea}`} />
{e.followUp && (
<>
<p className="example-then">then</p>
- <Command code={e.followUp} kind="follow-up" label="Copy follow-up" />
+ <Command code={e.followUp} kind="follow-up" label={`Copy follow-up: ${e.idea}`} />
</>
)}
</div>
diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.ts
index 02619ea..7df97de 100644
--- a/apps/site/test/skill.spec.ts
+++ b/apps/site/test/skill.spec.ts
@@ -96,6 +96,17 @@ test("each example shows the figure, its controls and what it means, without the
}
});
+test("each example is named by its prompt, and each copy button says which line it copies", async ({ page }) => {
+ await page.goto("/skill");
+ for (const idea of IDEAS) {
+ const row = page.getByRole("article", { name: `/hairline-create ${idea}`, exact: true });
+ await expect(row).toHaveCount(1);
+ await expect(row.getByRole("button", { name: `Copy prompt: ${idea}`, exact: true })).toHaveCount(1);
+ }
+ await expect(page.getByRole("button", { name: "Copy follow-up: git branches", exact: true })).toHaveCount(1);
+ await expect(page.getByRole("button", { name: "Copy follow-up: weather over a city", exact: true })).toHaveCount(1);
+});
+
test("the install command and a prompt copy as they are written", async ({ page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
await page.goto("/skill");