Skip to content

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

Skill page: on a screen under 360px the top bar leaves out the version, so the name no longer runs into the Skill link

Lucas Marques9f66be137515
diff --git a/apps/site/app/globals.css b/apps/site/app/globals.css
index 2e77133..b12e2e3 100644
--- a/apps/site/app/globals.css
+++ b/apps/site/app/globals.css
@@ -58,6 +58,8 @@ a.topbar-link::after { content: ""; position: absolute; inset: -5px 0; }
footer a { position: relative; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; transition: text-decoration-color 150ms ease; }
@media (hover: hover) { footer a:hover { text-decoration-color: currentColor; } }
footer a::after { content: ""; position: absolute; inset: -12px -8px; }
+/* under 360px the name and the first link would run together: the version, the item least needed there, goes */
+@media (max-width: 359px) { .topbar [data-version] { display: none; } }
.btn {
display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.ts
index f45788c..2eb83e1 100644
--- a/apps/site/test/skill.spec.ts
+++ b/apps/site/test/skill.spec.ts
@@ -173,9 +173,16 @@ test("the top bar's Skill link opens /skill", async ({ page }) => {
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
});
-test("the top bar fits a 320px screen with its five items on one row", async ({ page }) => {
+test("the top bar fits a 320px screen on one row, the version left out so the name stands clear of the links", async ({ page }) => {
await page.setViewportSize({ width: 320, height: 700 });
await page.goto("/skill");
+ await expect(page.locator(".topbar [data-version]")).toBeHidden();
+ // from the name's last letter to the Skill link's first: at least the 20px the links keep between each other
+ const gap = await page.evaluate(() => {
+ const text = (el: Element) => { const r = document.createRange(); r.selectNodeContents(el); return r.getBoundingClientRect(); };
+ return text(document.querySelector(".topbar-link")!).left - text(document.querySelector(".topbar > a")!).right;
+ });
+ expect(gap).toBeGreaterThanOrEqual(20);
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);
const tops = await page.locator(".topbar nav > *").evaluateAll((els) => els.filter((el) => getComputedStyle(el).display !== "none").map((el) => Math.round(el.getBoundingClientRect().top)));
expect(new Set(tops).size).toBe(1);