Skip to content

Commit

Permalink
Added schematic-text [sch_box_name , and MPN] to createSvgObjectsFrom…
Browse files Browse the repository at this point in the history
…SchematicComponentWithBox
  • Loading branch information
AnasSarkiz committed Dec 21, 2024
1 parent c4d0e4e commit 9194bd9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createSvgObjectsFromSchematicComponentWithSymbol } from "./create-svg-o
import { createSvgObjectsFromSchPortOnBox } from "./create-svg-objects-from-sch-port-on-box"
import { getSchStrokeSize } from "lib/utils/get-sch-stroke-size"
import { getSchScreenFontSize } from "lib/utils/get-sch-font-size"
import { createSvgSchText } from "./create-svg-objects-for-sch-text"

export const createSvgObjectsFromSchematicComponentWithBox = ({
component: schComponent,
Expand Down Expand Up @@ -72,6 +73,13 @@ export const createSvgObjectsFromSchematicComponentWithBox = ({
children: [],
})

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

for (const schText of schTexts) {
svgObjects.push(createSvgSchText(schText, transform))
}
// // Process ports
const schematicPorts = su(circuitJson as any).schematic_port.list({
schematic_component_id: schComponent.schematic_component_id,
Expand Down
4 changes: 2 additions & 2 deletions 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.
4 changes: 2 additions & 2 deletions 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.
2 changes: 1 addition & 1 deletion tests/sch/__snapshots__/schText.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions tests/sch/transform-attribute.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ 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="([^"]+)"/)

// @ts-ignore
expect(match[1]).toMatchInlineSnapshot(
`"matrix(54.5454545455,0,0,-54.5454545455,600,300)"`,
)
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)",
)
}
})

0 comments on commit 9194bd9

Please sign in to comment.