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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resistorProps.parse({ resistance: "10k" } as ResistorPropsInput);
| `<board />` | [`BoardProps`](#boardprops-board) |
| `<breakout />` | [`BreakoutProps`](#breakoutprops-breakout) |
| `<breakoutpoint />` | [`BreakoutPointProps`](#breakoutpointprops-breakoutpoint) |
| `<bus />` | [`BusProps`](#busprops-bus) |
| `<cadassembly />` | [`CadAssemblyProps`](#cadassemblyprops-cadassembly) |
| `<cadmodel />` | [`CadModelProps`](#cadmodelprops-cadmodel) |
| `<capacitor />` | [`CapacitorProps`](#capacitorprops-capacitor) |
Expand Down Expand Up @@ -429,6 +430,18 @@ export interface BreakoutPointProps extends Omit<

[Source](https://github.com/tscircuit/props/blob/main/lib/components/breakoutpoint.ts)

### BusProps `<bus />`

```ts
export interface BusProps {
name?: string;
/** Trace names or port selectors for the connections in the bus. */
connections: string[];
}
```

[Source](https://github.com/tscircuit/props/blob/main/lib/components/bus.ts)

### CadAssemblyProps `<cadassembly />`

```ts
Expand Down
18 changes: 18 additions & 0 deletions generated/COMPONENT_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,24 @@ export const breakoutPointProps = pcbLayoutProps
})
```

### bus

```typescript
/**
* Declares a group of connections that an autorouter should keep together.
* Each connection may be a trace name or a port selector.
*/
export interface BusProps {
name?: string
connections: string[]
}
/** Trace names or port selectors for the connections in the bus. */
export const busProps = z.object({
name: z.string().optional(),
connections: z.array(z.string()).min(2),
})
```

### cadassembly

```typescript
Expand Down
7 changes: 7 additions & 0 deletions generated/PROPS_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ export interface BreakoutProps
}


export interface BusProps {
name?: string
/** Trace names or port selectors for the connections in the bus. */
connections: string[]
}


export interface CadAssemblyProps {
/**
* The layer that the CAD assembly is designed for. If you set this to "top"
Expand Down
20 changes: 20 additions & 0 deletions lib/components/bus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expectTypesMatch } from "lib/typecheck"
import { z } from "zod"

/**
* Declares a group of connections that an autorouter should keep together.
* Each connection may be a trace name or a port selector.
*/
export interface BusProps {
name?: string
/** Trace names or port selectors for the connections in the bus. */
connections: string[]
}

export const busProps = z.object({
name: z.string().optional(),
connections: z.array(z.string()).min(2),
})

type InferredBusProps = z.input<typeof busProps>
expectTypesMatch<BusProps, InferredBusProps>(true)
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export * from "./components/smtpad"
export * from "./components/solderpaste"
export * from "./components/hole"
export * from "./components/trace"
export * from "./components/bus"
export * from "./components/differentialpair"
export * from "./components/footprint"
export * from "./components/symbol"
Expand Down
20 changes: 20 additions & 0 deletions tests/bus.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from "bun:test"
import { busProps, type BusProps } from "lib/components/bus"

test("busProps accepts two or more connection references", () => {
const rawProps: BusProps = {
name: "DATA",
connections: ["D0", ".U1 > .D1"],
}

expect(busProps.parse(rawProps)).toEqual(rawProps)
})

test("busProps rejects a single connection", () => {
expect(
busProps.safeParse({
name: "DATA",
connections: ["D0"],
}).success,
).toBe(false)
})
Comment on lines +1 to +20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file contains two test(...) calls, which violates the rule that a *.test.ts file may have AT MOST one test(...). Please split this into two separate numbered files, e.g. bus1.test.ts (for 'busProps accepts two or more connection references') and bus2.test.ts (for 'busProps rejects a single connection').

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

Fix in Graphite


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

Loading