From 4e9391ca29da6c7c3137b0d99181d0e62f09f2ea Mon Sep 17 00:00:00 2001 From: taweechok Date: Sat, 16 May 2026 22:52:38 +0700 Subject: [PATCH] fix: add Load Example button and fix example download link (#11) - Add 'Load Example' button that fetches the example circuit JSON from the raw GitHub URL and loads it directly into the viewer - Change footer link from GitHub blob URL to raw GitHub URL with download attribute so the file actually downloads - Fixes https://github.com/tscircuit/circuitjson.com/issues/11 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/App.tsx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f0c27ea..2c0346e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -96,6 +96,19 @@ export const App = () => { [loadJsonString], ) + const loadExample = useCallback(async () => { + try { + const response = await fetch( + "https://raw.githubusercontent.com/tscircuit/circuitjson.com/main/assets/usb-c-flashlight.json", + ) + if (!response.ok) throw new Error(`HTTP ${response.status}`) + const text = await response.text() + loadJsonString(text) + } catch (err) { + setErrorMsg("Failed to load example file. Please try again.") + } + }, [loadJsonString]) + return (
{ Choose File +
@@ -215,9 +235,10 @@ export const App = () => {
)}

- View{" "} + Download{" "} example circuit json file