Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: schematic x and y props using parsed value in mm #588

Merged
merged 1 commit into from
Jan 30, 2025
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
3 changes: 2 additions & 1 deletion lib/components/base-components/PrimitiveComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export abstract class PrimitiveComponent<
* schematic components
*/
computeSchematicPropsTransform(): Matrix {
return compose(translate(this.props.schX ?? 0, this.props.schY ?? 0))
const { _parsedProps: props } = this
return compose(translate(props.schX ?? 0, props.schY ?? 0))
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/repros/__snapshots__/repo8-resistor-schX-schematic.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions tests/repros/repo8-resistor-schX.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { test, expect } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

test("board with resistor being passed schX and pcbX in mm", () => {
const { circuit } = getTestFixture()

circuit.add(
<board width="10mm" height="10mm">
<resistor
resistance="1k"
footprint="0402"
name="R1"
schX="2mm"
pcbX="-2mm"
/>
</board>,
)

circuit.render()

expect(circuit.db.schematic_component.list()).toMatchInlineSnapshot(`
[
{
"center": {
"x": 2,
"y": 0,
},
"rotation": 0,
"schematic_component_id": "schematic_component_0",
"size": {
"height": 0.388910699999999,
"width": 1.0583332999999997,
},
"source_component_id": "source_component_0",
"symbol_display_value": "1kΩ",
"symbol_name": "boxresistor_right",
"type": "schematic_component",
},
]
`)

expect(circuit.db.pcb_component.list()).toMatchInlineSnapshot(`
[
{
"center": {
"x": -2,
"y": 0,
},
"height": 0.6000000000000001,
"layer": "top",
"pcb_component_id": "pcb_component_0",
"rotation": 0,
"source_component_id": "source_component_0",
"subcircuit_id": "subcircuit_source_group_0",
"type": "pcb_component",
"width": 1.5999999999999999,
},
]
`)

expect(circuit).toMatchSchematicSnapshot(import.meta.path)
})