-
Notifications
You must be signed in to change notification settings - Fork 90
feat: Implement boardAnchorPosition and boardAnchorAlignment for boards #1438
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
09baa14
Fix this issue
Excellencedev be2ffe0
Divide tests
Excellencedev 521365f
Fix test files
Excellencedev e391a2f
Fix checks
Excellencedev 418fe23
Cleanup
Excellencedev 6252d5a
Add snapshots
Excellencedev 645f2a6
Fix format
Excellencedev 47058b6
Do snapshots well
Excellencedev 0ce5ff8
Add requested changes
Excellencedev b429b45
Add more changes
Excellencedev d201ff2
Add changes
Excellencedev 79db420
Post format changes
Excellencedev 2678b55
Update lib/components/normal-components/Board.ts
Excellencedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/examples/__snapshots__/example34-board-anchor1-pcb.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
tests/examples/__snapshots__/example34-board-anchor2-pcb.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
tests/examples/__snapshots__/example34-board-anchor3-pcb.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { describe, it, expect } from "bun:test" | ||
| import { getTestFixture } from "../fixtures/get-test-fixture" | ||
|
|
||
| describe("Board Anchor", () => { | ||
| it("should anchor the board to the top-left", async () => { | ||
| const { circuit } = getTestFixture() | ||
| const board = ( | ||
| <board | ||
| width="30mm" | ||
| height="30mm" | ||
| boardAnchorPosition={{ x: 0, y: 0 }} | ||
| boardAnchorAlignment="top_left" | ||
| > | ||
| <resistor name="R1" resistance="10k" footprint="0805" /> | ||
| <silkscreencircle pcbX={0} pcbY={0} radius="1mm" /> | ||
| <silkscreentext pcbX={1} pcbY={1} text="(0,0)" /> | ||
| <silkscreentext | ||
| pcbX={0} | ||
| pcbY={-2} | ||
| text="board.anchor: top_left @ (0,0)" | ||
| /> | ||
| </board> | ||
| ) | ||
|
|
||
| circuit.add(board) | ||
|
|
||
| await circuit.render() | ||
|
|
||
| expect(circuit).toMatchPcbSnapshot(import.meta.path) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, it, expect } from "bun:test" | ||
| import { getTestFixture } from "../fixtures/get-test-fixture" | ||
|
|
||
| describe("Board Anchor", () => { | ||
| it("should anchor the board to the bottom-right", async () => { | ||
| const { circuit } = getTestFixture() | ||
| const board = ( | ||
| <board | ||
| width="30mm" | ||
| height="30mm" | ||
| boardAnchorPosition={{ x: 10, y: 10 }} | ||
| boardAnchorAlignment="bottom_right" | ||
| > | ||
| <resistor name="R1" resistance="10k" footprint="0805" /> | ||
| <silkscreencircle pcbX={0} pcbY={0} radius="1mm" /> | ||
| <silkscreentext pcbX={1} pcbY={1} text="(0,0)" /> | ||
| <silkscreencircle pcbX={10} pcbY={10} radius="1mm" /> | ||
| <silkscreentext | ||
| pcbX={10} | ||
| pcbY={8} | ||
| text="board.anchor: bottom_right @ (10,10)" | ||
| /> | ||
| </board> | ||
| ) | ||
|
|
||
| circuit.add(board) | ||
|
|
||
| await circuit.render() | ||
|
|
||
| expect(circuit).toMatchPcbSnapshot(import.meta.path) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { describe, it, expect } from "bun:test" | ||
| import { getTestFixture } from "../fixtures/get-test-fixture" | ||
|
|
||
| describe("Board Anchor", () => { | ||
| it("should anchor the board to the center", async () => { | ||
| const { circuit } = getTestFixture() | ||
| const board = ( | ||
| <board | ||
| width="30mm" | ||
| height="30mm" | ||
| boardAnchorPosition={{ x: 5, y: 5 }} | ||
| boardAnchorAlignment="center" | ||
| > | ||
| <resistor name="R1" resistance="10k" footprint="0805" /> | ||
| <silkscreencircle pcbX={0} pcbY={0} radius="1mm" /> | ||
| <silkscreentext pcbX={1} pcbY={1} text="(0,0)" /> | ||
| <silkscreencircle pcbX={5} pcbY={5} radius="1mm" /> | ||
| <silkscreentext pcbX={5} pcbY={3} text="board.anchor: center @ (5,5)" /> | ||
| </board> | ||
| ) | ||
|
|
||
| circuit.add(board) | ||
|
|
||
| await circuit.render() | ||
|
|
||
| expect(circuit).toMatchPcbSnapshot(import.meta.path) | ||
| }) | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.