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

PCB Grid Proposal/Experiments #461

Open
seveibar opened this issue Dec 28, 2024 · 0 comments
Open

PCB Grid Proposal/Experiments #461

seveibar opened this issue Dec 28, 2024 · 0 comments
Assignees

Comments

@seveibar
Copy link
Contributor

seveibar commented Dec 28, 2024

There are two ways to do PCB Grid, but both require formalizing a framework feature I'm not totally sure about yet.

Method 1: Custom Components <PcbGrid />

Allow users to define custom components, this requires we standardize the API for defining new components which could make us less flexible in the future.

For <PCBGrid />, we'd need a way to override the transform that a parent can apply to children. Basically to do this there would need to be a lot of formalization around how layout happens, which we're almost ready for and could maybe benefit from, but until we have a decent autolayout engine it's not clear if we want to bet on any particular architecture (in case we make things less flexible)

Method 2: <group pcbGrid={{ xSpacing: 10, ySpacing: 10 }} /> and optionally <pcbgrid /> shorthand

This is kind of "html-esque" where we basically just keep extending the language spec for every use case rather than allowing users to tap into the underlying layout engine. The HTML philosophy is more like "ahhh well we'll let people cancel out an entire class of layout functions by changing a display type later"

This is the best approach if we really want to innovate on layout pipeline (we deem flexbox to be totally unsuitable in any way because of a fundamental difference in the order/process for laying out)

Method 3: Incorporate flexbox/CSS grid

There's a lot of potential here but i need to do more investigation to check the feasibility of it. But could be very good and use the yoga engine. Would allow us to kick the can and remain standard.

Method 4: @tscircuit/math-utils

This keeps tscircuit core simpler and relies on third party modules.

You can just import whatever shape you want and it won't have any special layout adjustment

import { grid } from "@tscircuit/math-utils"

// ...

<group>
{grid({ rows: 5, cols: 5, xSpacing: 10, ySpacing: 10 }).map(({ center }) => (
  <resistor pcbX={center.x} pcbY={center.y} />
))}
</group>
@seveibar seveibar self-assigned this Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant