feat(standalone): bottom-right version + source badge

A small fixed bottom-right overlay (VersionBadge) shown app-wide — on the home
page AND inside the loaded editor — surfacing this build's release tag and a
link to the source. The tag links to the exact commit when known (the pcbjam
commit pins the kicad + wxwidgets submodule revisions → our GPLv3
corresponding-source pointer, mirroring site Footer's BUILD_SHA), else the tag's
release page, else the repo root.

build-demo.mjs injects VITE_APP_TAG / VITE_GIT_SHA / VITE_REPO_URL (new --repo
flag, defaults to github.com/emergence-engineering/pcbjam).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gergő Törcsvári 2026-06-20 08:01:50 +02:00
commit 0f53984407
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322
5 changed files with 112 additions and 7 deletions

View file

@ -0,0 +1,49 @@
import { Github } from "lucide-react";
import { APP_GIT_SHA, APP_TAG, REPO_URL } from "@/lib/config";
/**
* Small bottom-right overlay showing this build's version + a link to the
* source. The standalone is GPLv3, so the tag links to the exact commit
* (corresponding-source pointer — the repo commit pins the kicad + wxwidgets
* submodule revisions) when known, else the tag's release page, else the repo
* root. Mounted app-wide (App.tsx) so it shows on the home page AND inside the
* loaded editor. `fixed` keeps it viewport-anchored on every route; z-20 sits
* under the editor's boot overlay (z-30) so it's hidden until the tool is up.
*/
export function VersionBadge() {
const tag = APP_TAG ?? "dev";
const versionUrl = APP_GIT_SHA
? `${REPO_URL}/commit/${APP_GIT_SHA}`
: APP_TAG
? `${REPO_URL}/releases/tag/${APP_TAG}`
: REPO_URL;
const versionTitle = APP_GIT_SHA
? `commit ${APP_GIT_SHA.slice(0, 12)} — GPL corresponding source`
: APP_TAG
? `release ${APP_TAG}`
: "source repository";
return (
<div className="fixed bottom-3 right-3 z-20 flex items-center gap-2 rounded bg-black/70 px-2.5 py-1 font-mono text-[11px] text-white/80 shadow">
<a
href={versionUrl}
target="_blank"
rel="noreferrer"
title={versionTitle}
className="hover:text-white"
>
pcbjam {tag}
</a>
<span className="text-white/30">·</span>
<a
href={REPO_URL}
target="_blank"
rel="noreferrer"
title="Source on GitHub"
className="inline-flex items-center gap-1 hover:text-white"
>
<Github size={12} /> source
</a>
</div>
);
}