Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/components/normal-components/Board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export class Board extends Group<typeof boardProps> {
const { db } = this.root!
const { _parsedProps: props } = this

// Skip if width and height are explicitly provided
if (props.width && props.height) return
// Skip if width and height are explicitly provided or if outline is provided
if ((props.width && props.height) || props.outline) return

let minX = Infinity
let minY = Infinity
Expand Down Expand Up @@ -182,7 +182,7 @@ export class Board extends Group<typeof boardProps> {
const computedHeight = hasComponents ? maxY - minY + padding * 2 : 0

// Center the board around the components or use (0,0) for empty boards
let center = {
const center = {
x: hasComponents
? (minX + maxX) / 2 + (props.outlineOffsetX ?? 0)
: (props.outlineOffsetX ?? 0),
Expand All @@ -195,7 +195,7 @@ export class Board extends Group<typeof boardProps> {
const finalWidth = props.width ?? computedWidth
const finalHeight = props.height ?? computedHeight

let outline = props.outline
let outline = props.outline as { x: number; y: number }[] | undefined
if (
!outline &&
props.borderRadius != null &&
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

test("board outline dimension is calculated correctly", () => {
const { circuit } = getTestFixture()

circuit.add(
<board
outline={[
{ x: -8, y: -8 },
{ x: 8, y: -8 },
{ x: 8, y: 8 },
{ x: -8, y: 8 },
]}
>
<resistor name="R1" resistance="10k" footprint="0402" />
<capacitor name="C1" capacitance="10uF" footprint="0603" />
</board>,
)

circuit.render()

const pcb_board = circuit.db.pcb_board.list()[0]
expect(pcb_board.width).toBe(16)
expect(pcb_board.height).toBe(16)

expect(circuit).toMatchPcbSnapshot(import.meta.path)
})
Comment on lines +1 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File naming inconsistency: board-outline-dimension.test.tsx should use .test.ts extension instead of .test.tsx. The .tsx extension is reserved for React components containing JSX, while standard test files should use .ts to maintain consistency with the project's naming conventions.

Spotted by Graphite Agent (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.