Skip to content

Commit 77a21ac

Browse files
authored
Merge pull request #58 from AnasSarkiz/main
Enforce Include All LBRN Layers and Remove Inclusion Toggles
2 parents 750b67f + 799e199 commit 77a21ac

File tree

2 files changed

+14
-126
lines changed

2 files changed

+14
-126
lines changed

lib/components/settings-panel.tsx

Lines changed: 2 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useRef, useCallback } from "react"
22

33
import { Button } from "@/components/ui/button"
44
import { Separator } from "@/components/ui/separator"
5-
import { Cpu, Layers, Settings, Target, Upload, Zap } from "lucide-react"
5+
import { Cpu, Layers, Settings, Upload, Zap } from "lucide-react"
66
import { useWorkspace } from "./workspace-context"
77

88
export function SettingsPanel() {
@@ -132,29 +132,6 @@ export function SettingsPanel() {
132132
await processCircuitFile(files[0])
133133
}
134134
}
135-
// Helper function to create toggle buttons
136-
const ToggleButton = ({
137-
value,
138-
onChange,
139-
label,
140-
}: {
141-
value: boolean
142-
onChange: (value: boolean) => void
143-
label: string
144-
}) => (
145-
<div className="flex items-center justify-between min-w-0">
146-
<span className="text-sm truncate">{label}</span>
147-
<Button
148-
variant={value ? "default" : "outline"}
149-
size="sm"
150-
onClick={() => onChange(!value)}
151-
className="w-16"
152-
>
153-
{value ? "On" : "Off"}
154-
</Button>
155-
</div>
156-
)
157-
158135
// Helper function for numeric controls
159136
const NumericControl = ({
160137
value,
@@ -284,107 +261,10 @@ export function SettingsPanel() {
284261
</div>
285262
</div>
286263

287-
<Separator />
288-
289-
{/* Basic Settings Section */}
290-
<div className="space-y-3">
291-
<div className="flex items-center gap-2">
292-
<Layers className="size-4" />
293-
<h4 className="text-sm font-medium">Basic Settings</h4>
294-
</div>
295-
<div className="space-y-3 pl-6">
296-
<ToggleButton
297-
value={lbrnOptions.includeCopper ?? true}
298-
onChange={(value) =>
299-
setLbrnOptions({ ...lbrnOptions, includeCopper: value })
300-
}
301-
label="Include Copper"
302-
/>
303-
<ToggleButton
304-
value={lbrnOptions.includeSoldermask ?? false}
305-
onChange={(value) =>
306-
setLbrnOptions({ ...lbrnOptions, includeSoldermask: value })
307-
}
308-
label="Include Soldermask"
309-
/>
310-
<ToggleButton
311-
value={lbrnOptions.includeCopperCutFill ?? false}
312-
onChange={(value) =>
313-
setLbrnOptions({ ...lbrnOptions, includeCopperCutFill: value })
314-
}
315-
label="Include Copper Cut Fill"
316-
/>
317-
{/* Layer Selection */}
318-
<div className="flex items-center justify-between">
319-
<span className="text-sm">Layers</span>
320-
<div className="flex gap-1">
321-
<Button
322-
variant={
323-
(lbrnOptions.includeLayers ?? ["top", "bottom"]).includes(
324-
"top",
325-
)
326-
? "default"
327-
: "outline"
328-
}
329-
size="sm"
330-
className="w-16"
331-
onClick={() =>
332-
setLbrnOptions({
333-
...lbrnOptions,
334-
includeLayers: (
335-
lbrnOptions.includeLayers ?? ["top", "bottom"]
336-
).includes("top")
337-
? (lbrnOptions.includeLayers ?? ["top", "bottom"]).filter(
338-
(l: "top" | "bottom") => l !== "top",
339-
)
340-
: [
341-
...(lbrnOptions.includeLayers ?? ["top", "bottom"]),
342-
"top",
343-
],
344-
})
345-
}
346-
>
347-
Top
348-
</Button>
349-
<Button
350-
variant={
351-
(lbrnOptions.includeLayers ?? ["top", "bottom"]).includes(
352-
"bottom",
353-
)
354-
? "default"
355-
: "outline"
356-
}
357-
size="sm"
358-
className="w-16"
359-
onClick={() =>
360-
setLbrnOptions({
361-
...lbrnOptions,
362-
includeLayers: (
363-
lbrnOptions.includeLayers ?? ["top", "bottom"]
364-
).includes("bottom")
365-
? (lbrnOptions.includeLayers ?? ["top", "bottom"]).filter(
366-
(l: "top" | "bottom") => l !== "bottom",
367-
)
368-
: [
369-
...(lbrnOptions.includeLayers ?? ["top", "bottom"]),
370-
"bottom",
371-
],
372-
})
373-
}
374-
>
375-
Bottom
376-
</Button>
377-
</div>
378-
</div>
379-
</div>
380-
</div>
381-
382-
<Separator />
383-
384264
{/* Advanced Settings Section */}
385265
<div className="space-y-3">
386266
<div className="flex items-center gap-2">
387-
<Target className="size-4" />
267+
<Layers className="size-4" />
388268
<h4 className="text-sm font-medium">Advanced Settings</h4>
389269
</div>
390270
<div className="space-y-3 pl-6">

lib/components/workspace-context.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export function WorkspaceProvider({ children }: { children: ReactNode }) {
6161
const [lbrnOptions, setLbrnOptionsState] =
6262
useState<ConvertCircuitJsonToLbrnOptions>({
6363
includeCopper: true,
64-
includeSoldermask: false,
65-
includeSilkscreen: false,
66-
includeCopperCutFill: false,
64+
includeSoldermask: true,
65+
includeSilkscreen: true,
66+
includeCopperCutFill: true,
6767
includeLayers: ["top", "bottom"],
6868
laserSpotSize: 0.005,
6969
traceMargin: 0,
@@ -84,7 +84,15 @@ export function WorkspaceProvider({ children }: { children: ReactNode }) {
8484
const setLbrnOptions = (
8585
options: Partial<ConvertCircuitJsonToLbrnOptions>,
8686
) => {
87-
setLbrnOptionsState((prev) => ({ ...prev, ...options }))
87+
setLbrnOptionsState((prev) => ({
88+
...prev,
89+
...options,
90+
includeCopper: true,
91+
includeSoldermask: true,
92+
includeSilkscreen: true,
93+
includeCopperCutFill: true,
94+
includeLayers: ["top", "bottom"],
95+
}))
8896
}
8997

9098
// Auto-convert to LBRN when circuit is loaded

0 commit comments

Comments
 (0)