Skip to content

Open-source, local-first social media research agent for Instagram, TikTok, and LinkedIn. Jev routes read-only steps; socai CLI captures cited browser evidence.

feat(a11y): add local UI skip link (#91)

PandaHUN7776d989225b77c
diff --git a/public/index.html b/public/index.html
index bb92c65..208b4e9 100644
--- a/public/index.html
+++ b/public/index.html
@@ -12,6 +12,7 @@
</head>
<body>
<div class="app-shell">
+ <a class="skip-link" href="#main-content">Skip to main content</a>
<header class="topbar">
<a class="brand" href="/" aria-label="Jev Social home">
<span class="brand-mark"><i></i></span>
@@ -28,7 +29,7 @@
<button id="close-error" class="error-close" type="button" aria-label="Dismiss error">×</button>
</section>
- <main class="app-main">
+ <main id="main-content" class="app-main" tabindex="-1">
<section id="search-view" class="view search-view">
<div class="search-panel">
<p class="hero-lockup">JEV <span>×</span> socai</p>
diff --git a/public/styles.css b/public/styles.css
index 292c6db..2a078c8 100644
--- a/public/styles.css
+++ b/public/styles.css
@@ -30,6 +30,22 @@ button { cursor: pointer; }
}
.app-shell { height: 100vh; display: flex; flex-direction: column; }
+.skip-link {
+ position: absolute;
+ z-index: 30;
+ top: 12px;
+ left: 16px;
+ padding: 10px 14px;
+ border: 2px solid var(--ink);
+ background: var(--pink);
+ color: var(--ink);
+ font-weight: 700;
+ text-decoration: none;
+ transform: translateY(calc(-100% - 16px));
+}
+.skip-link:focus-visible {
+ transform: translateY(0);
+}
.topbar { position: relative; z-index: 20; flex: 0 0 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--ink); background: rgba(248, 251, 255, .94); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong { font: 800 18px/1 var(--mono); letter-spacing: -.055em; }
diff --git a/test/skip-link.test.js b/test/skip-link.test.js
new file mode 100644
index 0000000..7c5e52d
--- /dev/null
+++ b/test/skip-link.test.js
@@ -0,0 +1,40 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+
+const indexHtml = await readFile(
+ new URL("../public/index.html", import.meta.url),
+ "utf8",
+);
+const stylesCss = await readFile(
+ new URL("../public/styles.css", import.meta.url),
+ "utf8",
+);
+
+test("the local UI starts with a skip link to the focusable main region", () => {
+ const firstControl = indexHtml.match(/<(?:a|button|input|select|textarea)\b[^>]*>/i)?.[0];
+ assert.ok(firstControl, "expected a focusable control in the local UI");
+ assert.match(firstControl, /\bclass="skip-link"/i);
+
+ const skipLink = indexHtml.match(
+ /<a\b(?=[^>]*\bclass="skip-link")[^>]*>([\s\S]*?)<\/a>/i,
+ );
+ assert.ok(skipLink, "expected the local UI skip link");
+ assert.match(skipLink[0], /\bhref="#main-content"/i);
+ assert.equal(skipLink[1].trim(), "Skip to main content");
+
+ const main = indexHtml.match(/<main\b(?=[^>]*\bid="main-content")[^>]*>/i)?.[0];
+ assert.ok(main, "expected a main region with the skip-link target ID");
+ assert.match(main, /\btabindex="-1"/i);
+});
+
+test("the skip link is offscreen until focused and appears above the top bar", () => {
+ const linkStyle = stylesCss.match(/\.skip-link\s*\{([^}]*)\}/i)?.[1] ?? "";
+ const focusStyle = stylesCss.match(/\.skip-link:focus-visible\s*\{([^}]*)\}/i)?.[1] ?? "";
+ assert.match(linkStyle, /\bposition\s*:\s*absolute\b/i);
+ assert.match(linkStyle, /\btransform\s*:\s*translateY\(calc\(-100%/i);
+ assert.match(linkStyle, /\bbackground\s*:\s*var\(--pink\)/i);
+ assert.match(linkStyle, /\bcolor\s*:\s*var\(--ink\)/i);
+ assert.ok(Number(linkStyle.match(/\bz-index\s*:\s*(\d+)/i)?.[1]) > 20);
+ assert.match(focusStyle, /\btransform\s*:\s*translateY\(0\)/i);
+});