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

feat: Introduce <stampboard /> #637

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ export { Crystal } from "./normal-components/Crystal"
export { Transistor } from "./normal-components/Transistor"
export { Mosfet } from "./normal-components/Mosfet"
export { Switch } from "./normal-components/Switch"
export { Stampboard } from "./normal-components/StampBoard"
18 changes: 18 additions & 0 deletions lib/components/normal-components/StampBoard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type StampboardProps, stampboardProps } from "@tscircuit/props"
import { Board } from "./Board"

export class Stampboard extends Board {
get config() {
return {
componentName: "Stampboard",
zodProps: stampboardProps,
}
}

doInitialPcbComponentRender(): void {
if (this.root?.pcbDisabled) return
super.doInitialPcbComponentRender()

const props = this._parsedProps as unknown as StampboardProps
}
}
1 change: 1 addition & 0 deletions lib/fiber/intrinsic-jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface TscircuitElements {
transistor: Props.TransistorProps
switch: Props.SwitchProps
mosfet: Props.MosfetProps
stampboard: Props.StampboardProps
jscad: any
}

Expand Down
1 change: 1 addition & 0 deletions lib/register-catalogue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Components from "./components"
import { Stampboard } from "./components/normal-components/StampBoard"
import { extendCatalogue } from "./fiber/catalogue"

// Register all components, generally you don't need to manually
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@tscircuit/footprinter": "^0.0.124",
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
"@tscircuit/math-utils": "^0.0.9",
"@tscircuit/props": "^0.0.152",
"@tscircuit/props": "^0.0.154",
"@tscircuit/schematic-autolayout": "^0.0.6",
"@tscircuit/soup-util": "^0.0.41",
"circuit-json": "^0.0.139",
Expand Down
44 changes: 44 additions & 0 deletions tests/components/normal-components/stampboard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { it, expect, describe } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

it("should render a default stampboard and have the correct config", async () => {
const { circuit } = getTestFixture()
circuit.add(
<board width="10mm" height="10mm">
<stampboard name="S1" />
</board>,
)
circuit.render()

const stampboardInstance = circuit.selectOne("Stampboard")
expect(stampboardInstance).not.toBeNull()
expect(stampboardInstance!.config.componentName).toBe("Stampboard")
})

it("should render a stampboard with custom properties", async () => {
const { circuit } = getTestFixture()
circuit.add(
<board width="10mm" height="10mm">
<stampboard
name="S2"
leftPinCount={4}
rightPinCount={4}
topPins={["TP1", "TP2"]}
bottomPins={["BP1", "BP2"]}
pinPitch="2mm"
innerHoles={true}
/>
</board>,
)
circuit.render()

const stampboardInstance = circuit.selectOne("Stampboard")
expect(stampboardInstance).not.toBeNull()
const props = stampboardInstance!._parsedProps as any
expect(props.leftPinCount).toBe(4)
expect(props.rightPinCount).toBe(4)
expect(props.topPins).toEqual(["TP1", "TP2"])
expect(props.bottomPins).toEqual(["BP1", "BP2"])
expect(props.pinPitch).toBe(2)
expect(props.innerHoles).toBe(true)
Comment on lines +37 to +43
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why are you checking the passing props, check the circuit_json which is being rendered.

})