Skip to content

Commit

Permalink
Merge branch 'main' into issue-171
Browse files Browse the repository at this point in the history
  • Loading branch information
mrudulpatil18 committed Nov 15, 2024
2 parents 974bb42 + 08d1b6a commit 4f9e6ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@tscircuit/3d-viewer": "^0.0.36",
"@tscircuit/footprinter": "^0.0.86",
"@tscircuit/footprinter": "^0.0.87",
"@tscircuit/layout": "^0.0.29",
"@tscircuit/mm": "^0.0.8",
"@tscircuit/pcb-viewer": "^1.10.16",
Expand All @@ -79,6 +79,7 @@
"codemirror": "^6.0.1",
"country-list": "^2.3.0",
"date-fns": "^4.1.0",
"dsn-converter": "^0.0.8",
"easyeda": "^0.0.62",
"embla-carousel-react": "^8.3.0",
"extract-codefence": "^0.0.4",
Expand Down Expand Up @@ -113,7 +114,7 @@
"@babel/standalone": "^7.25.6",
"@biomejs/biome": "^1.9.2",
"@playwright/test": "^1.48.0",
"@tscircuit/core": "^0.0.172",
"@tscircuit/core": "^0.0.177",
"@tscircuit/prompt-benchmarks": "^0.0.15",
"@types/babel__standalone": "^7.1.7",
"@types/bun": "^1.1.10",
Expand All @@ -125,7 +126,7 @@
"@typescript/vfs": "^1.6.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"circuit-to-svg": "^0.0.75",
"circuit-to-svg": "^0.0.76",
"globals": "^15.9.0",
"postcss": "^8.4.47",
"prismjs": "^1.29.0",
Expand Down
13 changes: 13 additions & 0 deletions src/components/DownloadButtonAndMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@/components/ui/dropdown-menu"
import { toast, useNotImplementedToast } from "@/hooks/use-toast"
import { downloadCircuitJson } from "@/lib/download-fns/download-circuit-json-fn"
import { downloadDsnFile } from "@/lib/download-fns/download-dsn-file-fn"
import { downloadFabricationFiles } from "@/lib/download-fns/download-fabrication-files"
import { downloadSchematicSvg } from "@/lib/download-fns/download-schematic-svg"
import { AnyCircuitElement } from "circuit-json"
Expand Down Expand Up @@ -127,6 +128,18 @@ export function DownloadButtonAndMenu({
svg
</span>
</DropdownMenuItem>
<DropdownMenuItem
className="text-xs"
onSelect={() => {
downloadDsnFile(circuitJson, snippetUnscopedName || "circuit")
}}
>
<Download className="mr-1 h-3 w-3" />
<span className="flex-grow mr-6">Download DSN file</span>
<span className="text-[0.6rem] opacity-80 bg-blue-500 text-white font-mono rounded-md px-1 text-center py-0.5 mr-1">
dsn
</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/lib/download-fns/download-dsn-file-fn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AnyCircuitElement } from "circuit-json"
import { saveAs } from "file-saver"
import { convertCircuitJsonToDsnString } from "dsn-converter"

export const downloadDsnFile = (
circuitJson: AnyCircuitElement[],
fileName: string,
) => {
const dsnString = convertCircuitJsonToDsnString(circuitJson)
const blob = new Blob([dsnString], { type: "text/plain" })
saveAs(blob, fileName + ".dsn")
}

0 comments on commit 4f9e6ce

Please sign in to comment.