Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions generated/COMPONENT_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export const rotationPoint3 = z.object({
y: z.union([z.number(), z.string()]),
z: z.union([z.number(), z.string()]),
})
export const cadModelAxisDirections = [
"x+",
"x-",
"y+",
"y-",
"z+",
"z-",
] as const
export interface CadModelBase {
rotationOffset?:
| number
Expand All @@ -21,6 +29,8 @@ export interface CadModelBase {
}
size?: { x: number | string; y: number | string; z: number | string }
modelUnitToMmScale?: Distance
modelBoardNormalDirection?: CadModelAxisDirection
pcbRotationOffset?: number
zOffsetFromSurface?: Distance
showAsTranslucentModel?: boolean
}
Expand All @@ -29,6 +39,8 @@ export const cadModelBase = z.object({
positionOffset: point3.optional(),
size: point3.optional(),
modelUnitToMmScale: distance.optional(),
modelBoardNormalDirection: cadModelAxisDirection.optional(),
pcbRotationOffset: z.number().optional(),
zOffsetFromSurface: distance.optional(),
showAsTranslucentModel: z.boolean().optional(),
})
Expand Down
2 changes: 2 additions & 0 deletions generated/PROPS_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ export interface CadModelBase {
}
size?: { x: number | string; y: number | string; z: number | string }
modelUnitToMmScale?: Distance
modelBoardNormalDirection?: CadModelAxisDirection
pcbRotationOffset?: number
zOffsetFromSurface?: Distance
showAsTranslucentModel?: boolean
}
Expand Down
17 changes: 17 additions & 0 deletions lib/common/cadModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ export const rotationPoint3 = z.object({
z: z.union([z.number(), z.string()]),
})

export const cadModelAxisDirections = [
"x+",
"x-",
"y+",
"y-",
"z+",
"z-",
] as const

export type CadModelAxisDirection = (typeof cadModelAxisDirections)[number]

export const cadModelAxisDirection = z.enum(cadModelAxisDirections)

export interface CadModelBase {
rotationOffset?:
| number
Expand All @@ -22,6 +35,8 @@ export interface CadModelBase {
}
size?: { x: number | string; y: number | string; z: number | string }
modelUnitToMmScale?: Distance
modelBoardNormalDirection?: CadModelAxisDirection
pcbRotationOffset?: number
zOffsetFromSurface?: Distance
showAsTranslucentModel?: boolean
}
Expand All @@ -31,6 +46,8 @@ export const cadModelBase = z.object({
positionOffset: point3.optional(),
size: point3.optional(),
modelUnitToMmScale: distance.optional(),
modelBoardNormalDirection: cadModelAxisDirection.optional(),
pcbRotationOffset: z.number().optional(),
zOffsetFromSurface: distance.optional(),
showAsTranslucentModel: z.boolean().optional(),
})
Expand Down
16 changes: 16 additions & 0 deletions tests/cadmodel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,19 @@ test("cadmodel accepts showAsTranslucentModel", () => {

expect(parsed.showAsTranslucentModel).toBe(true)
})

test("cadmodel accepts modelBoardNormalDirection and pcbRotationOffset", () => {
const raw: CadModelPropsInput = {
modelUrl: "https://example.com/model.stl",
modelBoardNormalDirection: "z+",
pcbRotationOffset: 90,
}

const parsed = cadmodelProps.parse(raw) as Exclude<
CadModelPropsInput,
null | string
>

expect(parsed.modelBoardNormalDirection).toBe("z+")
expect(parsed.pcbRotationOffset).toBe(90)
})
Comment on lines +117 to +131
Copy link
Contributor

Choose a reason for hiding this comment

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

This test file violates the rule that a *.test.ts file may have AT MOST one test(...) function. The file already contains at least one test() function (as evidenced by the existing test ending at line 115), and this diff adds a second test() function starting at line 117. To fix this violation, the new test should be moved to a separate numbered test file, such as 'cadmodel2.test.ts' or similar.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Loading