Skip to content

Commit b48bbf8

Browse files
support pinout svg (#5)
1 parent 3bde309 commit b48bbf8

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default () => (
4545
</board>
4646
)
4747
`,
48-
"pcb" // or "schematic" for schematic view
48+
"pcb" // or "schematic", "3d", or "pinout"
4949
)
5050

5151
// Returns URL pointing to https://svg.tscircuit.com

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function getUncompressedSnippetString(
2929

3030
export function createSvgUrl(
3131
tscircuitCode: string,
32-
svgType: "pcb" | "schematic" | "3d",
32+
svgType: "pcb" | "schematic" | "3d" | "pinout",
3333
) {
3434
const base64Data = getCompressedBase64SnippetString(tscircuitCode)
3535
return `https://svg.tscircuit.com/?svg_type=${svgType}&code=${encodeURIComponent(base64Data)}`

tests/test3-svg-url.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from "bun:test"
22
import { createSvgUrl } from "lib"
33

4-
test("create snippets url", () => {
4+
test("create pcb svg url", () => {
55
const url = createSvgUrl(
66
`
77
export default () => (
@@ -17,3 +17,20 @@ export default () => (
1717
`"https://svg.tscircuit.com/?svg_type=pcb&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`,
1818
)
1919
})
20+
21+
test("create pinout svg url", () => {
22+
const url = createSvgUrl(
23+
`
24+
export default () => (
25+
<board width="10mm" height="10mm">
26+
<resistor resistance="1k" footprint="0402" name="R1" schX={3} pcbX={3} />
27+
</board>
28+
)
29+
`,
30+
"pinout",
31+
)
32+
33+
expect(url).toMatchInlineSnapshot(
34+
`"https://svg.tscircuit.com/?svg_type=pinout&code=H4sIAJsBqGcAAy2NTQ7CIBhE9z3FhFW7KlWXhUO4ckuBClF%2BAp%2FRxHh30Xb3JvMyY185FYKxq3rcCf0AIdF3wLwkVQye3pATbOIhMDjrr472JJvUtGKrr5QKNlBR2ybcGNaUKBcfm89P%2FMAQVWjVeWKo2l3E%2B%2FhB1ssG429tHv%2Bfshu%2BlSYxzJYAAAA%3D"`,
35+
)
36+
})

0 commit comments

Comments
 (0)