From 6757c2e882e22db54534430abe97f805d7b7b950 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:35:20 +0000 Subject: [PATCH 01/13] fix version finding bug --- scripts/web_startup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/web_startup.py b/scripts/web_startup.py index 9e24293..1977a97 100644 --- a/scripts/web_startup.py +++ b/scripts/web_startup.py @@ -6,7 +6,6 @@ import re import js import json -from operator import itemgetter import warnings import micropip @@ -68,12 +67,13 @@ async def switch_version(): print("Loading all versions... ", end="") -versions_all = json.load( +foo = json.load( get("https://api.github.com/repos/dragoncoder047/schemascii/contents/dist")) +foo = filter(lambda x: x["name"].endswith(".whl"), foo) +foo = map(lambda x: x["path"], foo) versions_to_wheel_map = dict( - zip(map(itemgetter("name"), versions_all), map(itemgetter("path"), versions_all))) + zip(map(lambda x: re.search(r"""/schemascii-([\d.]+)-""", x).group(1), foo), foo)) all_versions = list(versions_to_wheel_map.keys()) -all_versions.append("DEV") latest_version = re.search( r'''version = "([\d.]+)"''', get("pyproject.toml").read()).group(1) print(all_versions, "latest =", latest_version) From c625572397b7a8ac17b574389175bd3e84e04c9b Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:41:39 +0000 Subject: [PATCH 02/13] mixed up lazy iteration --- scripts/web_startup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/web_startup.py b/scripts/web_startup.py index 1977a97..b4b8ac0 100644 --- a/scripts/web_startup.py +++ b/scripts/web_startup.py @@ -70,7 +70,7 @@ async def switch_version(): foo = json.load( get("https://api.github.com/repos/dragoncoder047/schemascii/contents/dist")) foo = filter(lambda x: x["name"].endswith(".whl"), foo) -foo = map(lambda x: x["path"], foo) +foo = list(map(lambda x: x["path"], foo)) versions_to_wheel_map = dict( zip(map(lambda x: re.search(r"""/schemascii-([\d.]+)-""", x).group(1), foo), foo)) all_versions = list(versions_to_wheel_map.keys()) From f44028cff791a95d228164ee60523895e4f0372d Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:55:18 +0000 Subject: [PATCH 03/13] add download button --- index.html | 2 +- scripts/web_startup.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 098f57c..eafbbbb 100644 --- a/index.html +++ b/index.html @@ -61,7 +61,7 @@

Schemascii Source

CSS

-

Result

+

Result

Messages


diff --git a/scripts/web_startup.py b/scripts/web_startup.py
index b4b8ac0..8a3b93a 100644
--- a/scripts/web_startup.py
+++ b/scripts/web_startup.py
@@ -1,5 +1,3 @@
-from pyodide.http import pyfetch as fetch, open_url as get
-from pyodide.ffi import create_proxy as event_handler
 import asyncio
 import functools
 import sys
@@ -7,6 +5,8 @@
 import js
 import json
 import warnings
+from pyodide.http import pyfetch as fetch, open_url as get
+from pyodide.ffi import create_proxy as event_handler
 import micropip
 
 
@@ -57,6 +57,13 @@ async def switch_version():
     version = ver_switcher.value
     await micropip.install(versions_to_wheel_map[version])
 
+@event_handler
+def download_svg():
+    a = js.document.createElement("a")
+    a.setAttribute("href", js.URL.createObjectURL(js.Blob.new([output.innerHTML], {"type": "application/svg+xml"})))
+    a.setAttribute("download", f"schemascii_playground_{js.Date.new.toISOString()}_no_css.svg")
+    a.click()
+
 output = js.document.getElementById("output")
 css_box = js.document.getElementById("css")
 console = js.document.getElementById("console")
@@ -64,6 +71,7 @@ async def switch_version():
 style_elem = js.document.getElementById("custom-css")
 errors = js.document.getElementById("errors")
 ver_switcher = js.document.getElementById("version")
+download_button = js.document.getElementById("download")
 
 
 print("Loading all versions... ", end="")
@@ -93,6 +101,7 @@ async def switch_version():
 
 css_box.addEventListener("input", sync_css)
 source.addEventListener("input", render_catch_warnings)
+download_button.addEventListener("click", download_svg)
 
 source.removeAttribute("disabled")
 css_box.removeAttribute("disabled")

From b323c9a295ad9a3d4d8e071d928b2e89ef7ec598 Mon Sep 17 00:00:00 2001
From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com>
Date: Fri, 11 Aug 2023 19:29:51 +0000
Subject: [PATCH 04/13] kludges on event handlers

---
 index.html             | 20 +++++++++++++++-
 scripts/web_startup.py | 52 ++++++++----------------------------------
 2 files changed, 29 insertions(+), 43 deletions(-)

diff --git a/index.html b/index.html
index eafbbbb..7847b02 100644
--- a/index.html
+++ b/index.html
@@ -75,7 +75,11 @@ 

More Information

// cSpell:ignore pyodide pyproject var pyodide; var console = document.getElementById("console"); - var errors = document.getElementById("errors") + var errors = document.getElementById("errors"); + var css_box = document.getElementById("css"); + var source = document.getElementById("schemascii"); + var download_button = document.getElementById("download"); + var ver_switcher = document.getElementById("version"); async function main() { try { @@ -85,6 +89,13 @@

More Information

await pyodide.loadPackage("micropip", { errorCallback: error, messageCallback: () => { } }); info("done\n"); await pyodide.runPythonAsync(await fetch("scripts/web_startup.py").then(r => r.text())); + css_box.addEventListener("input", debounce(pyodide.globals.get("sync_css"))); + source.addEventListener("input", debounce(pyodide.globals.get("render_catch_warnings"))); + download_button.addEventListener("click", pyodide.globals.get("download_svg")); + ver_switcher.addEventListener("change", pyodide.globals.get("switch_version")); + source.removeAttribute("disabled"); + css_box.removeAttribute("disabled"); + console.textContent = "Ready"; } catch (e) { error(`\nFATAL ERROR:\n${e.stack}\n`); throw e; @@ -96,6 +107,13 @@

More Information

function error(text) { errors.textContent += text; } + function debounce(fun) { + var timeout; + return function() { + if (timeout) clearTimeout(timeout); + timeout = setTimeout(fun, 100); + } + } main(); diff --git a/scripts/web_startup.py b/scripts/web_startup.py index 8a3b93a..360902b 100644 --- a/scripts/web_startup.py +++ b/scripts/web_startup.py @@ -1,43 +1,17 @@ -import asyncio import functools import sys import re import js import json import warnings -from pyodide.http import pyfetch as fetch, open_url as get -from pyodide.ffi import create_proxy as event_handler +from pyodide.http import open_url as get import micropip -def debounced(fun): - timeout = None - - @functools.wraps(fun) - def inner(): - nonlocal timeout - if timeout: - js.clearTimeout(timeout) - timeout = js.setTimeout(fun, 100) - - return inner - - -def syncify(fun): - @functools.wraps(fun) - def inner(e): - return asyncio.ensure_future(fun(e)) - return inner - - -@event_handler -@debounced def sync_css(): style_elem.innerHTML = css_box.value -@event_handler -@debounced def render_catch_warnings(*args, **kwargs): import schemascii console.textContent = "" @@ -49,21 +23,23 @@ def render_catch_warnings(*args, **kwargs): return out -@event_handler -@syncify -async def switch_version(): +def switch_version(): if "schemascii" in sys.modules: del sys.modules["schemascii"] # Invalidate cache version = ver_switcher.value - await micropip.install(versions_to_wheel_map[version]) + js.eval( + f'''(async () => await pyodide.globals.get("micropip").install({versions_to_wheel_map[version]!r}))();''') + -@event_handler def download_svg(): a = js.document.createElement("a") - a.setAttribute("href", js.URL.createObjectURL(js.Blob.new([output.innerHTML], {"type": "application/svg+xml"}))) - a.setAttribute("download", f"schemascii_playground_{js.Date.new.toISOString()}_no_css.svg") + a.setAttribute("href", js.URL.createObjectURL(js.Blob.new( + [output.innerHTML], {"type": "application/svg+xml"}))) + a.setAttribute( + "download", f"schemascii_playground_{js.Date.new.toISOString()}_no_css.svg") a.click() + output = js.document.getElementById("output") css_box = js.document.getElementById("css") console = js.document.getElementById("console") @@ -98,11 +74,3 @@ def download_svg(): css_source = get("schemascii_example.css").read() style_elem.textContent = css_source css_box.value = css_source - -css_box.addEventListener("input", sync_css) -source.addEventListener("input", render_catch_warnings) -download_button.addEventListener("click", download_svg) - -source.removeAttribute("disabled") -css_box.removeAttribute("disabled") -console.textContent = "ready\n" From cf32b6cf08dd10ff6cbf320f6a22e3de897cb41d Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 20:46:36 +0000 Subject: [PATCH 05/13] move to js because pyodide is being annoying --- index.html | 46 +---------------- scripts/monkeypatch.py | 17 +++++++ scripts/web_startup.js | 110 +++++++++++++++++++++++++++++++++++++++++ scripts/web_startup.py | 76 ---------------------------- 4 files changed, 128 insertions(+), 121 deletions(-) create mode 100644 scripts/monkeypatch.py create mode 100644 scripts/web_startup.js delete mode 100644 scripts/web_startup.py diff --git a/index.html b/index.html index 7847b02..6f750b2 100644 --- a/index.html +++ b/index.html @@ -71,50 +71,6 @@

More Information

https://github.com/dragoncoder047/schemascii/

- + \ No newline at end of file diff --git a/scripts/monkeypatch.py b/scripts/monkeypatch.py new file mode 100644 index 0000000..affc0fd --- /dev/null +++ b/scripts/monkeypatch.py @@ -0,0 +1,17 @@ +import sys +if "schemascii" in sys.modules: + del sys.modules["schemascii"] + +import warnings +import schemascii + +print("monkeypatching... ", end="") + +def patched(src): + with warnings.catch_warnings(record=True) as captured_warnings: + out = schemascii.render("", src) + for warn in captured_warnings: + print("warning:", warn.message) + return out + +schemascii.patched_render = patched diff --git a/scripts/web_startup.js b/scripts/web_startup.js new file mode 100644 index 0000000..d2b1a0b --- /dev/null +++ b/scripts/web_startup.js @@ -0,0 +1,110 @@ +// cSpell:ignore pyodide pyproject +var pyodide; +var console = document.getElementById("console"); +var errors = document.getElementById("errors"); +var css_box = document.getElementById("css"); +var source = document.getElementById("schemascii"); +var download_button = document.getElementById("download"); +var ver_switcher = document.getElementById("version"); + +var schemascii; +var monkeysrc; + +var ver_map; + +async function main() { + try { + info("Loading Python... "); + pyodide = await loadPyodide({ stdout: info, stderr: error }); + info("done\nInstalling micropip..."); + await pyodide.loadPackage("micropip", { errorCallback: error, messageCallback: () => { } }); + info("done\nFetching versions... "); + monkeysrc = await fetch("scripts/monkeypatch.py").then(r => r.text()); + var foo = await fetch("https://api.github.com/repos/dragoncoder047/schemascii/contents/dist").then(r => r.json()); + foo = foo.filter(x => x.name.endsWith(".whl")).map(x => x.path); + ver_map = Object.fromEntries(foo.map(x => [/\/schemascii-([\d.]+)-/.exec(x)[1], x])) + var all_versions = Object.keys(ver_map); + //all_versions.push("DEV"); + for (var v of all_versions) { + var o = document.createElement("option"); + o.textContent = o.value = v; + ver_switcher.append(o); + } + var latest_version = await fetch("pyproject.toml").then(r => r.text()).then(r => /version = "([\d.]+)"/.exec(r)[0]); + ver_switcher.value = latest_version; + info(`["${all_versions.join('", "')}"]\nlatest=${latest_version}\n`); + await switch_version(); + css_box.addEventListener("input", debounce(sync_css)); + source.addEventListener("input", debounce(catched(render))); + download_button.addEventListener("click", download); + ver_switcher.addEventListener("change", acatched(switch_version)); + + source.removeAttribute("disabled"); + css_box.removeAttribute("disabled"); + console.textContent = "Ready"; + } catch (e) { + error(`\nFATAL ERROR:\n${e.stack}\n`); + throw e; + } +} +function monkeypatch() { + pyodide.runPython(monkeysrc); +} +function info(line) { + console.textContent += line; +} +function error(text) { + errors.textContent += text; +} +function debounce(fun) { + var timeout; + return function () { + if (timeout) clearTimeout(timeout); + timeout = setTimeout(fun.bind(this, arguments), 100); + }; +} +function catched(fun) { + return function () { + try { + fun.call(this, arguments); + } catch (e) { + error(e.stack); + } + }; +} +async function acatched(fun) { + return async function() { + try { + await fun.call(this, arguments); + } catch (e) { + error(e.stack); + } + }; +} +function sync_css() { + style_elem.innerHTML = css_box.value; +} +function render() { + console.textContent = ""; + errors.textContent = ""; + output.textContent = schemascii.patched_render(source.value); +} + +async function switch_version() { + info("Installing Schemascii version " + ver_switcher.value + "... ") + await pyodide.pyimport("micropip").install(ver_map[ver_switcher.value]); + monkeypatch(); + schemascii = pyodide.runPython("import schemascii; schemascii"); + info("done\n"); +} + +function download() { + var a = document.createElement("a"); + a.setAttribute("href", URL.createObjectURL(new Blob([output.innerHTML], {"type": "application/svg+xml"}))); + a.setAttribute("download", `schemascii_playground_${new Date().toISOString()}_no_css.svg`); + a.click(); +} + +main(); + +// fetch("https://github.com/dragoncoder047/schemascii/zipball/main/").then(r => r.arrayBuffer()).then(b => pyodide.unpackArchive(b, "zip")); diff --git a/scripts/web_startup.py b/scripts/web_startup.py deleted file mode 100644 index 360902b..0000000 --- a/scripts/web_startup.py +++ /dev/null @@ -1,76 +0,0 @@ -import functools -import sys -import re -import js -import json -import warnings -from pyodide.http import open_url as get -import micropip - - -def sync_css(): - style_elem.innerHTML = css_box.value - - -def render_catch_warnings(*args, **kwargs): - import schemascii - console.textContent = "" - errors.textContent = "" - with warnings.catch_warnings(record=True) as captured_warnings: - out = schemascii.render(*args, **kwargs) - for warn in captured_warnings: - print("warning:", warn.message) - return out - - -def switch_version(): - if "schemascii" in sys.modules: - del sys.modules["schemascii"] # Invalidate cache - version = ver_switcher.value - js.eval( - f'''(async () => await pyodide.globals.get("micropip").install({versions_to_wheel_map[version]!r}))();''') - - -def download_svg(): - a = js.document.createElement("a") - a.setAttribute("href", js.URL.createObjectURL(js.Blob.new( - [output.innerHTML], {"type": "application/svg+xml"}))) - a.setAttribute( - "download", f"schemascii_playground_{js.Date.new.toISOString()}_no_css.svg") - a.click() - - -output = js.document.getElementById("output") -css_box = js.document.getElementById("css") -console = js.document.getElementById("console") -source = js.document.getElementById("schemascii") -style_elem = js.document.getElementById("custom-css") -errors = js.document.getElementById("errors") -ver_switcher = js.document.getElementById("version") -download_button = js.document.getElementById("download") - - -print("Loading all versions... ", end="") -foo = json.load( - get("https://api.github.com/repos/dragoncoder047/schemascii/contents/dist")) -foo = filter(lambda x: x["name"].endswith(".whl"), foo) -foo = list(map(lambda x: x["path"], foo)) -versions_to_wheel_map = dict( - zip(map(lambda x: re.search(r"""/schemascii-([\d.]+)-""", x).group(1), foo), foo)) -all_versions = list(versions_to_wheel_map.keys()) -latest_version = re.search( - r'''version = "([\d.]+)"''', get("pyproject.toml").read()).group(1) -print(all_versions, "latest =", latest_version) - -for ver in all_versions: - opt = js.document.createElement("option") - opt.value = opt.textContent = ver - ver_switcher.append(opt) - -ver_switcher.value = latest_version -await micropip.install(versions_to_wheel_map[latest_version]) - - -css_source = get("schemascii_example.css").read() -style_elem.textContent = css_source -css_box.value = css_source From 6b9bf5145f1a6afa6787482bc1fb48d977173801 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:49:03 -0400 Subject: [PATCH 06/13] typo --- scripts/web_startup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index d2b1a0b..9547219 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -30,7 +30,7 @@ async function main() { o.textContent = o.value = v; ver_switcher.append(o); } - var latest_version = await fetch("pyproject.toml").then(r => r.text()).then(r => /version = "([\d.]+)"/.exec(r)[0]); + var latest_version = await fetch("pyproject.toml").then(r => r.text()).then(r => /version = "([\d.]+)"/.exec(r)[1]); ver_switcher.value = latest_version; info(`["${all_versions.join('", "')}"]\nlatest=${latest_version}\n`); await switch_version(); From 510aba8eb3bce4a6bff6218f199402ae24fbabb4 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:52:07 -0400 Subject: [PATCH 07/13] another typo --- scripts/web_startup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index 9547219..729c156 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -87,7 +87,7 @@ function sync_css() { function render() { console.textContent = ""; errors.textContent = ""; - output.textContent = schemascii.patched_render(source.value); + output.innerHTML = schemascii.patched_render(source.value); } async function switch_version() { From dbbee0dfd2c63b6d9b95eba2448b573382af8215 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:54:59 -0400 Subject: [PATCH 08/13] forgot to fetch css --- scripts/web_startup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index 729c156..a905ab9 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -39,6 +39,7 @@ async function main() { download_button.addEventListener("click", download); ver_switcher.addEventListener("change", acatched(switch_version)); + css_box.value = await fetch("schemascii_example.css").then(r => r.text()); source.removeAttribute("disabled"); css_box.removeAttribute("disabled"); console.textContent = "Ready"; From 43d70fffa7d6b230242fcf6370b0ace9e4a9a60a Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:01:16 -0400 Subject: [PATCH 09/13] missing objects --- scripts/web_startup.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index a905ab9..12b455e 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -6,6 +6,8 @@ var css_box = document.getElementById("css"); var source = document.getElementById("schemascii"); var download_button = document.getElementById("download"); var ver_switcher = document.getElementById("version"); +var style_elem = document.getElementById("custom-css"); +var output = document.getElementById("output"); var schemascii; var monkeysrc; @@ -34,6 +36,7 @@ async function main() { ver_switcher.value = latest_version; info(`["${all_versions.join('", "')}"]\nlatest=${latest_version}\n`); await switch_version(); + css_box.addEventListener("input", debounce(sync_css)); source.addEventListener("input", debounce(catched(render))); download_button.addEventListener("click", download); @@ -95,11 +98,13 @@ async function switch_version() { info("Installing Schemascii version " + ver_switcher.value + "... ") await pyodide.pyimport("micropip").install(ver_map[ver_switcher.value]); monkeypatch(); - schemascii = pyodide.runPython("import schemascii; schemascii"); + schemascii = pyodide.runPython("import schemascii\nschemascii"); info("done\n"); + output.innerHTML = ""; } function download() { + if (!output.innerHTML) return; var a = document.createElement("a"); a.setAttribute("href", URL.createObjectURL(new Blob([output.innerHTML], {"type": "application/svg+xml"}))); a.setAttribute("download", `schemascii_playground_${new Date().toISOString()}_no_css.svg`); From 52bb36d4eae0274c20bbfea5b01508c3e2d44c0d Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:03:59 -0400 Subject: [PATCH 10/13] guards around installing new version --- scripts/web_startup.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index 12b455e..00a45e9 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -95,12 +95,14 @@ function render() { } async function switch_version() { + source.setAttribute("disabled", true); info("Installing Schemascii version " + ver_switcher.value + "... ") await pyodide.pyimport("micropip").install(ver_map[ver_switcher.value]); monkeypatch(); schemascii = pyodide.runPython("import schemascii\nschemascii"); info("done\n"); output.innerHTML = ""; + source.removeAttribute("disabled"); } function download() { From a76158b6dfa26384f8e2fc8bdce52b5efca728bd Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:04:48 -0400 Subject: [PATCH 11/13] sync css to start --- scripts/web_startup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/web_startup.js b/scripts/web_startup.js index 00a45e9..db6ac5e 100644 --- a/scripts/web_startup.js +++ b/scripts/web_startup.js @@ -43,6 +43,7 @@ async function main() { ver_switcher.addEventListener("change", acatched(switch_version)); css_box.value = await fetch("schemascii_example.css").then(r => r.text()); + sync_css(); source.removeAttribute("disabled"); css_box.removeAttribute("disabled"); console.textContent = "Ready"; From 4889bbad2ffe686034acf2287a912955c5ef03e5 Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Mon, 16 Sep 2024 20:51:55 -0400 Subject: [PATCH 12/13] Use nested CSS --- schemascii_example.css | 108 +++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 59 deletions(-) diff --git a/schemascii_example.css b/schemascii_example.css index 617c61d..379ae3e 100644 --- a/schemascii_example.css +++ b/schemascii_example.css @@ -1,69 +1,59 @@ svg.schemascii { background: black; -} - -svg.schemascii .wire polyline { - stroke: var(--sch-color, blue); - stroke-width: 2; - stroke-linecap: round; - stroke-linejoin: round; - transition-duration: 0.2s; - fill: transparent; -} - -svg.schemascii .wire circle { - fill: var(--sch-color, blue); - transition-duration: 0.2s; -} - -svg.schemascii :is(.wire, .component):hover { - --sch-color: lime; -} - -svg.schemascii .component :is(polyline, path, line, polygon, rect, circle):not(.filled) { - stroke: var(--sch-color, red); - stroke-width: 2; - stroke-linecap: round; - transition-duration: 0.2s; - fill: transparent; -} - -svg.schemascii .component :is(polyline, path, line, polygon, rect, circle).filled { - fill: var(--sch-color, red); - stroke: none; - transition-duration: 0.2s; -} - - -svg.schemascii .component .plus :is(polyline, path, line) { - stroke-width: 1; -} - -svg.schemascii .component polygon { - fill: var(--sch-color, red); -} - -svg.schemascii .component text { - fill: white; - transition-duration: 0.2s; -} - -svg.schemascii .component:hover text { - font-weight: bold; -} -svg.schemascii .component tspan:is(.cmp-value, .part-num) { - opacity: 50%; + & .wire polyline { + stroke: var(--sch-color, blue); + stroke-width: 2; + stroke-linecap: round; + stroke-linejoin: round; + transition-duration: 0.2s; + fill: transparent; + } + & .wire circle { + fill: var(--sch-color, blue); + transition-duration: 0.2s; + } + & :is(.wire, .component):hover { + --sch-color: lime; + } + & .component :is(polyline, path, line, polygon, rect, circle):not(.filled) { + stroke: var(--sch-color, red); + stroke-width: 2; + stroke-linecap: round; + transition-duration: 0.2s; + fill: transparent; + } + & .component :is(polyline, path, line, polygon, rect, circle).filled { + fill: var(--sch-color, red); + stroke: none; + transition-duration: 0.2s; + } + & .component .plus :is(polyline, path, line) { + stroke-width: 1; + } + & .component polygon { + fill: var(--sch-color, red); + } + & .component text { + fill: white; + transition-duration: 0.2s; + } + & .component:hover text { + font-weight: bold; + } + & .component tspan:is(.cmp-value, .part-num) { + opacity: 50%; + } } @media all and (prefers-color-scheme: light) { svg.schemascii { background: white; - } - svg.schemascii .component text { - fill: black; - } - svg.schemascii :is(.wire, .component):hover { - --sch-color: lime; + & .component text { + fill: black; + } + & :is(.wire, .component):hover { + --sch-color: lime; + } } } From a4e968395668a7d8ba82633ba8bb881eb6d7e16f Mon Sep 17 00:00:00 2001 From: dragoncoder047 <101021094+dragoncoder047@users.noreply.github.com> Date: Fri, 16 May 2025 13:55:02 -0400 Subject: [PATCH 13/13] force monospaced font on textareas closes #10 --- index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 6f750b2..7d2e0e7 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,11 @@ resize: vertical; } + textarea, + pre { + font-family: "Fira Code", monospace; + } + #errors { color: red; } @@ -73,4 +78,4 @@

More Information

- \ No newline at end of file +