Skip to content

Commit

Permalink
Removed duplicate of schematic text
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasSarkiz committed Dec 21, 2024
1 parent 9194bd9 commit 75acdda
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion lib/sch/convert-circuit-json-to-schematic-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export function convertCircuitJsonToSchematicSvg(
} else if (elm.type === "schematic_net_label") {
schNetLabel.push(...createSvgObjectsForSchNetLabel(elm, transform))
} else if (elm.type === "schematic_text") {
schText.push(createSvgSchText(elm, transform))
if (!elm.schematic_component_id.includes("schematic_component")) {
schText.push(createSvgSchText(elm, transform))
}
} else if (elm.type === "schematic_voltage_probe") {
voltageProbeSvgs.push(
...createSvgObjectsFromSchVoltageProbe(elm, transform),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ export const createSvgObjectsFromSchematicComponentWithBox = ({
children: [],
})

const schTexts = su(circuitJson as any).schematic_text.list({
schematic_component_id: schComponent.schematic_component_id,
})
const schTexts = su(circuitJson as any).schematic_text.list()

for (const schText of schTexts) {
svgObjects.push(createSvgSchText(schText, transform))
if (
schText.schematic_component_id === schComponent.schematic_component_id
) {
svgObjects.push(createSvgSchText(schText, transform))
}
}
// // Process ports
const schematicPorts = su(circuitJson as any).schematic_port.list({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@storybook/react": "^8.2.5",
"@storybook/react-vite": "^8.2.5",
"@storybook/test": "^8.2.5",
"@tscircuit/core": "^0.0.229",
"@tscircuit/core": "^0.0.233",
"@tscircuit/plop": "^0.0.10",
"@types/bun": "^1.1.9",
"biome": "^0.3.3",
Expand Down
2 changes: 1 addition & 1 deletion tests/sch/__snapshots__/kicad-theme-demo.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/sch/__snapshots__/rp2040.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 4 additions & 7 deletions tests/sch/transform-attribute.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ test("svg should have data-real-to-screen-transform attribute", () => {

// Extract the transform value and verify it's a valid matrix string
const match = svg.match(/data-real-to-screen-transform="([^"]+)"/)
expect(match).not.toBeNull() // Ensure match exists before accessing [1]
if (match) {
const transformValue = match[1]
expect(transformValue).toBe(
"matrix(54.5454545455,0,0,-54.5454545455,600,300)",
)
}
// @ts-ignore
expect(match[1]).toMatchInlineSnapshot(
`"matrix(54.5454545455,0,0,-54.5454545455,600,300)"`,
)
})

0 comments on commit 75acdda

Please sign in to comment.