Skip to content

Commit

Permalink
add defaultTraceWidth prop to board and group (#51)
Browse files Browse the repository at this point in the history
* add defaultTraceWidth prop to board and group

* formatbot: Automatically format code

---------

Co-authored-by: tscircuitbot <tscircuitbot@users.noreply.github.com>
  • Loading branch information
seveibar and tscircuitbot authored Sep 17, 2024
1 parent b0a8305 commit a4728fe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/common/distance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { z } from "zod"

export type Distance = number | string

export { distance } from "@tscircuit/soup"
export { distance, length } from "@tscircuit/soup"
4 changes: 4 additions & 0 deletions lib/components/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { z } from "zod"
import { distance } from "@tscircuit/soup"
import { point, type Point } from "lib/common/point"
import { expectTypesMatch } from "lib/typecheck"
import type { SubcircuitGroupProps } from "./group"
import type { Distance } from "lib/common/distance"

export interface BoardProps {
width?: number | string
Expand All @@ -12,6 +14,7 @@ export interface BoardProps {
layout?: any
routingDisabled?: boolean
children?: any
defaultTraceWidth?: Distance
}

export const boardProps = z.object({
Expand All @@ -23,6 +26,7 @@ export const boardProps = z.object({
layout: z.any().optional(),
routingDisabled: z.boolean().optional(),
children: z.any(),
defaultTraceWidth: distance.optional(),
})

expectTypesMatch<BoardProps, z.input<typeof boardProps>>(true)
4 changes: 4 additions & 0 deletions lib/components/group.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { z } from "zod"
import { commonLayoutProps, type CommonLayoutProps } from "lib/common/layout"
import { length } from "@tscircuit/soup"
import type { LayoutBuilder } from "@tscircuit/layout"
import { expectTypesMatch } from "lib/typecheck"
import type { Distance } from "lib/common/distance"

export interface BaseGroupProps extends CommonLayoutProps {
name?: string
Expand All @@ -12,6 +14,7 @@ export interface SubcircuitGroupProps extends BaseGroupProps {
subcircuit: true
layout?: LayoutBuilder
routingDisabled?: boolean
defaultTraceWidth?: Distance
}

export type GroupProps = SubcircuitGroupProps | BaseGroupProps
Expand All @@ -25,6 +28,7 @@ export const subcircuitGroupProps = baseGroupProps.extend({
subcircuit: z.literal(true),
layout: z.custom<LayoutBuilder>((v) => true).optional(),
routingDisabled: z.boolean().optional(),
defaultTraceWidth: length.optional(),
})

export const groupProps = z.union([baseGroupProps, subcircuitGroupProps])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@biomejs/biome": "^1.9.0",
"@biomejs/biome": "^1.9.1",
"@tscircuit/layout": "^0.0.11",
"@tscircuit/soup": "^0.0.69",
"@types/bun": "^1.1.8",
Expand Down

0 comments on commit a4728fe

Please sign in to comment.