Skip to content

Conversation

Excellencedev
Copy link
Contributor

@Excellencedev Excellencedev commented Oct 4, 2025

/claim #1371
/closes #1371

DESCRIPTION :

This PR introduces two new props for the Board component: boardAnchorPosition and boardAnchorAlignment. These props allow developers to specify the anchor point and alignment for a board, which is particularly useful for auto-sizing boards.

  • boardAnchorPosition: A point object { x: number, y: number } that specifies the anchor point.
  • boardAnchorAlignment: A string that specifies how the board should be aligned to the anchor point. Possible values are "center", "top_left", "top_right", "bottom_left", "bottom_right", "top", "bottom", "left", and "right".

The implementation modifies the doInitialPcbBoardAutoSize method in the Board component to calculate the board's center based on these new props.

Logs from the test:

USER@DESKTOP-1PHUG1C MINGW64 ~/3D Objects/core (issue-1371-fix)
$ bun test tests/examples/example34-board-anchor1.test.tsx tests/examples/example34-board-anchor2.test.tsx tests/examples/example34-board-anchor3.test.tsx
bun test v1.2.20 (6ad208bc)

tests\examples\example34-board-anchor1.test.tsx:
✓ Board Anchor > should anchor the board to the top-left [172.00ms]

tests\examples\example34-board-anchor2.test.tsx:
✓ Board Anchor > should anchor the board to the bottom-right [94.00ms]

tests\examples\example34-board-anchor3.test.tsx:
✓ Board Anchor > should anchor the board to the center [94.00ms]

3 pass
0 fail
3 expect() calls
Ran 3 tests across 3 files. [2.17s]

Copy link

vercel bot commented Oct 4, 2025

@Excellencedev is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

@Excellencedev
Copy link
Contributor Author

@seveibar Please review

@Excellencedev
Copy link
Contributor Author

@seveibar Please review this PR

Copy link
Member

@imrishabh18 imrishabh18 left a comment

Choose a reason for hiding this comment

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

The snapshots are blank, I don't know what the change did. Make sure the tests demonstrate what the change you did

@Excellencedev
Copy link
Contributor Author

The snapshots are blank, I don't know what the change did. Make sure the tests demonstrate what the change you did

will do so now

@Excellencedev
Copy link
Contributor Author

The snapshots are blank, I don't know what the change did. Make sure the tests demonstrate what the change you did

@imrishabh18 I have fixed that and the snapshots now represent the changes

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

looks ok but the tests need to make it clear that it's actually working, use silkscreen_text to indicate positions e.g. have some text say "(0,0)" or other points of interest on each diagram

also add text that indicates the anchorAlignment of the board and the board anchor position

@Excellencedev
Copy link
Contributor Author

looks ok but the tests need to make it clear that it's actually working, use silkscreen_text to indicate positions e.g. have some text say "(0,0)" or other points of interest on each diagram

also add text that indicates the anchorAlignment of the board and the board anchor position

@seveibar I have added it.

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

Dont set the resistor position so that we can determine if auto positioning works (we may accept even if it doesnt)

Clarify in the silscreen by sating board.anchor , and place the text at that anchor

@Excellencedev
Copy link
Contributor Author

Dont set the resistor position so that we can determine if auto positioning works (we may accept even if it doesnt)

Clarify in the silscreen by sating board.anchor , and place the text at that anchor

@seveibar done that

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

Please create a test that shows what happens if you dont set width and height so we can snapshot what happens with auto sizing, you will need two resistors so that there are elements to autosize

After we document that behavior you should be good

@Excellencedev
Copy link
Contributor Author

Please create a test that shows what happens if you dont set width and height so we can snapshot what happens with auto sizing, you will need two resistors so that there are elements to autosize

After we document that behavior you should be good

@seveibar fixed

@Excellencedev Excellencedev requested a review from seveibar October 7, 2025 16:05
Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

The autosizing implementation should be adjusted to include the anchor point. It wont be fully fixed but good enough to claim.

@Excellencedev
Copy link
Contributor Author

The autosizing implementation should be adjusted to include the anchor point. It wont be fully fixed but good enough to claim.

@seveibar I have done that
And also, what else do I need to do for this PR to get merged @seveibar

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

See comment

Suggested by seievebar

Co-authored-by: Severin Ibarluzea <[email protected]>
@Excellencedev
Copy link
Contributor Author

See comment

@seveibar I committed suggestion

@seveibar seveibar merged commit b5dc93f into tscircuit:main Oct 7, 2025
9 of 10 checks passed
@Excellencedev Excellencedev deleted the issue-1371-fix branch October 7, 2025 17:28
@Excellencedev Excellencedev restored the issue-1371-fix branch October 7, 2025 17:28
@Excellencedev
Copy link
Contributor Author

@seveibar Thanks for reviewing and merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement boardAnchorPosition and boardAnchorAlignment (which specifies what XY coordinates a board will appear and grow into for auto-sizing)

3 participants