-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-index-page-html.ts
67 lines (66 loc) · 1.59 KB
/
get-index-page-html.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export const getIndexPageHtml = () => {
return `
<!DOCTYPE html>
<html>
<body>
<h1>browser-preview.tscircuit.com</h1>
<p>
Turn your tscircuit code into a preview automatically.
</p>
<p>
To do this programmatically see the <a href="https://github.com/tscircuit/create-snippet-url">create-snippet-url</a> package.
<button onclick="loadExample()" style="margin-left: 10px;">paste example</button>
</p>
<form action="/generate_url" method="GET">
<textarea
name="code"
id="code"
placeholder="Enter your tscircuit code here"
style="width: 100%; height: 200px;"
></textarea>
<button type="submit">Start Runframe</button>
</form>
<style>
body {
max-width: 800px;
margin: 0 auto;
padding: 20px;
font-family: sans-serif;
}
textarea {
margin: 20px 0;
}
button {
padding: 10px 20px;
font-size: 16px;
}
</style>
<script>
function loadExample() {
const exampleCode = \`export default () => (
<board width="10mm" height="10mm">
<resistor
resistance="2k"
footprint="0402"
name="R1"
schX={4}
pcbX={3}
/>
<capacitor
capacitance="4000pF"
footprint="0402"
name="C1"
schX={-3}
pcbX={-3}
/>
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
</board>
);
\`;
document.getElementById('code').value = exampleCode;
}
</script>
</body>
</html>
`
}