-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update deps to range limits. Begin work on a dev testbed.
- Loading branch information
Broch Stilley
authored and
Broch Stilley
committed
May 7, 2024
1 parent
6f6e4b7
commit 334613a
Showing
10 changed files
with
5,614 additions
and
3,604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>svg-to-excalidraw</title> | ||
<style> | ||
html { | ||
height: 100%; | ||
width: 100%; | ||
font-family: Verdana, Geneva, sans-serif; | ||
} | ||
|
||
body { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
margin: 0; | ||
height: 100%; | ||
} | ||
|
||
header { | ||
text-align: center; | ||
font-size: 1.6rem; | ||
text-transform: uppercase; | ||
background-color: cornflowerblue; | ||
color: cornsilk; | ||
} | ||
|
||
header > h1 { | ||
padding: 0.5rem; | ||
} | ||
|
||
main { | ||
display: flex; | ||
flex-direction: row; | ||
height: 100%; | ||
} | ||
|
||
main > aside { | ||
display: flex; | ||
flex-direction: column; | ||
align-content: center; | ||
flex: 1; | ||
background-color: rgba(100, 149, 237, 0.3); | ||
padding: 0.8rem; | ||
} | ||
|
||
main > textarea { | ||
flex: 3; | ||
} | ||
|
||
.custom-file-upload { | ||
display: inline-block; | ||
cursor: pointer; | ||
margin: 1rem 0; | ||
border-radius: 0.2rem; | ||
background-color: #fff; | ||
border: 1px solid #333; | ||
color: #333; | ||
padding: 0.5rem; | ||
} | ||
|
||
#source { | ||
display: none; | ||
} | ||
|
||
#result { | ||
margin: 1rem; | ||
padding: 0.5rem; | ||
<head> | ||
<title>svg-to-excalidraw</title> | ||
<link rel="stylesheet" href="/src/css/style.css" /> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/themes/light.css" /> | ||
</head> | ||
|
||
<body> | ||
<main> | ||
<sl-split-panel> | ||
<div id="left-main-panel" slot="start"> | ||
<header> | ||
<h1>SVG to Excalidraw Testbed</h1> | ||
</header> | ||
<sl-divider></sl-divider> | ||
<sl-textarea id="svg-textarea" placeholder="Paste SVG here"></sl-textarea> | ||
<div style="margin: 1rem 0;"> | ||
<sl-button id="convert-btn">Convert</sl-button> | ||
</div> | ||
</div> | ||
<div id="right-main-panel" slot="end"> | ||
<div id="json-viewer-btns"> | ||
<sl-button id="expand-all-btn">Expand All</sl-button> | ||
<sl-button id="collapse-all-btn">Collapse All</sl-button> | ||
<sl-button id="copy-btn">Copy JSON</sl-button> | ||
</div> | ||
<sl-divider></sl-divider> | ||
<div id="json-viewer-wrapper"> | ||
<json-viewer></json-viewer> | ||
</div> | ||
</div> | ||
</sl-split-panel> | ||
</main> | ||
<!-- Import Map --> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"svg-to-excalidraw": "/dist/esm-bundle.js" | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<header><h1>svg-to-excalidraw</h1></header> | ||
<main> | ||
<aside> | ||
<div>File to convert :</div> | ||
<label for="source" class="custom-file-upload">Pick a SVG file</label> | ||
<input type="file" id="source" accept=".svg" /> | ||
</aside> | ||
<textarea | ||
id="result" | ||
placeholder="Result in excalidraw file format should be output here" | ||
></textarea> | ||
</main> | ||
<script type="module"> | ||
import svgParse from "../dist/esm-bundle.js"; | ||
|
||
const fileSelector = document.getElementById("source"); | ||
const output = document.getElementById("result"); | ||
|
||
output.addEventListener("click", function (event) { | ||
this.select(); | ||
}); | ||
|
||
fileSelector.addEventListener("change", (event) => { | ||
const fileList = event.target.files; | ||
readFile(fileList[0]); | ||
}); | ||
|
||
function readFile(file) { | ||
if (file.type && file.type !== "image/svg+xml") { | ||
console.log("File is not SVG."); | ||
</script> | ||
|
||
return; | ||
} | ||
<!-- Shoelace web components: https://shoelace.style/ --> | ||
<script type="module" | ||
src="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/shoelace-autoloader.js"></script> | ||
|
||
const reader = new FileReader(); | ||
<!-- JSON Viewer web component: https://github.com/alenaksu/json-viewer --> | ||
<script src="https://unpkg.com/@alenaksu/[email protected]/dist/json-viewer.bundle.js"></script> | ||
|
||
reader.readAsText(file); | ||
reader.addEventListener("load", (event) => { | ||
const parsingResult = svgParse.parse(event.target.result); | ||
<script type="module" src="/src/js/main.mjs"></script> | ||
</body> | ||
|
||
output.value = JSON.stringify(parsingResult, null, 2); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@font-face { | ||
font-family: 'Virgil'; | ||
src: url('../fonts/Virgil.woff2') format('woff2'); | ||
} | ||
|
||
html { | ||
height: 100%; | ||
width: 100%; | ||
font-family: Verdana, Geneva, sans-serif; | ||
} | ||
|
||
main { | ||
height: 100vh; | ||
} | ||
|
||
h1 { | ||
padding: 0.5rem; | ||
font-size: 2rem; | ||
font-family: 'Virgil', sans-serif; | ||
} | ||
|
||
sl-split-panel { | ||
height: 100%; | ||
} | ||
|
||
#left-main-panel { | ||
height: 100%; | ||
margin: 1rem; | ||
} | ||
|
||
#right-main-panel { | ||
height: 100%; | ||
margin: 1rem; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import svgToEx from "svg-to-excalidraw"; | ||
|
||
function addConvertBtnEvents() { | ||
const convertBtn = document.querySelector("#convert-btn"); | ||
|
||
convertBtn.addEventListener("click", async () => { | ||
const svg = document.querySelector("#svg-textarea").value; | ||
|
||
const { content } = await svgToEx.convert(svg); | ||
|
||
const jsonViewer = document.querySelector("json-viewer"); | ||
jsonViewer.data = content; | ||
jsonViewer.expandAll(); | ||
}); | ||
} | ||
|
||
function addJsonViewerBtnEvents() { | ||
const jsonViewer = document.querySelector("json-viewer"); | ||
|
||
const expandAllBtn = document.querySelector("#expand-all-btn"); | ||
const collapseAllBtn = document.querySelector("#collapse-all-btn"); | ||
const copyBtn = document.querySelector("#copy-btn"); | ||
|
||
expandAllBtn.addEventListener("click", () => { | ||
jsonViewer.expandAll(); | ||
}); | ||
|
||
collapseAllBtn.addEventListener("click", () => { | ||
jsonViewer.collapseAll(); | ||
}); | ||
|
||
copyBtn.addEventListener("click", () => { | ||
navigator.clipboard.writeText(JSON.stringify(jsonViewer.data, null, 2)); | ||
}); | ||
} | ||
|
||
async function main() { | ||
addJsonViewerBtnEvents(); | ||
addConvertBtnEvents(); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", main); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"rewrites": [{ | ||
"source": "/", | ||
"destination": "/dev/index.html" | ||
}, { | ||
"source": "/src/:asset/:path*", | ||
"destination": "/dev/src/:asset/:path*" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.