svgnest remove back to main

This commit is contained in:
makearmy 2025-10-15 20:58:01 -04:00
parent 582cafca0b
commit 130db9725a

View file

@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from "react";
/**
* SVGNest panel same-origin iframe wrapper (clean, frameless).
* Also hides the legacy pages heading/tagline for a minimal look.
* Hides the legacy pages heading/tagline and the "Back to Main" link.
*/
export default function SVGNestPanel() {
const iframeRef = useRef<HTMLIFrameElement | null>(null);
@ -18,16 +18,16 @@ export default function SVGNestPanel() {
const onLoad = () => {
setReady(true);
// Hide the legacy heading/tagline inside svgnest without touching the vendor files.
// Tidy up the embedded vendor page (no edits to files on disk)
try {
const doc = el.contentDocument;
if (!doc) return;
// 1) Hide the first H1 (their title)
// 1) Hide the first H1 (their big title)
const h1 = doc.querySelector("h1");
if (h1) (h1 as HTMLElement).style.display = "none";
// 2) Hide any node that literally contains that tagline text
// 2) Hide the tagline "automatically nests parts and exports svg"
const all = Array.from(doc.querySelectorAll<HTMLElement>("body *"));
for (const n of all) {
const t = (n.textContent || "").trim().toLowerCase();
@ -36,10 +36,24 @@ export default function SVGNestPanel() {
}
}
// 3) Optional: tighten top padding/margins so content sits snugly
// 3) Hide "Back to Main" link(s)
const anchors = Array.from(doc.querySelectorAll<HTMLAnchorElement>("a"));
for (const a of anchors) {
const text = (a.textContent || "").trim().toLowerCase();
const href = a.getAttribute("href") || "";
const isBackText = text === "back to main" || text === "← back to main";
const isRootHref =
href === "/" ||
/^https?:\/\/[^/]+\/?$/.test(href); // absolute site root
if (isBackText || isRootHref) {
(a as HTMLElement).style.display = "none";
}
}
// 4) Tighten top spacing a touch
(doc.body as HTMLElement).style.marginTop = "4px";
} catch {
// ignore; same-origin so this should succeed
// same-origin, so this *should* succeed; ignore if not
}
};