Skip to content

Commit ae08d79

Browse files
rushabhcodesrushabhcodes
andauthored
Refactor: Simplify VoltageSource imports and update intrinsic JSX types (#1681)
Co-authored-by: rushabhcodes <mail@rushabh.dev>
1 parent b2286b6 commit ae08d79

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

lib/components/normal-components/VoltageSource.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
1-
import { frequency, rotation, voltage } from "circuit-json"
2-
import {
3-
commonComponentProps,
4-
type CommonComponentProps,
5-
} from "@tscircuit/props"
6-
import { z } from "zod"
1+
import { voltageSourceProps } from "@tscircuit/props"
72
import { NormalComponent } from "../base-components/NormalComponent/NormalComponent"
8-
import { FTYPE, type BaseSymbolName, type Ftype } from "lib/utils/constants"
3+
import { type BaseSymbolName, type Ftype } from "lib/utils/constants"
94
import type { SimulationAcVoltageSource } from "circuit-json"
10-
import { Port } from "../primitive-components/Port"
5+
116
import type { RenderPhase } from "lib/components/base-components/Renderable"
127

138
export type WaveShape = "sinewave" | "square" | "triangle" | "sawtooth"
149

15-
export interface VoltageSourceProps extends CommonComponentProps {
16-
voltage?: number | string
17-
frequency?: number | string
18-
peakToPeakVoltage?: number | string
19-
waveShape?: WaveShape
20-
phase?: number | string
21-
dutyCycle?: number
22-
}
23-
24-
export const voltageSourceProps = commonComponentProps.extend({
25-
voltage: voltage.optional(),
26-
frequency: frequency.optional(),
27-
peakToPeakVoltage: voltage.optional(),
28-
waveShape: z.enum(["sinewave", "square", "triangle", "sawtooth"]).optional(),
29-
phase: rotation.optional(),
30-
dutyCycle: z.number().optional(),
31-
})
32-
3310
export class VoltageSource extends NormalComponent<
3411
typeof voltageSourceProps,
3512
"terminal1" | "terminal2"

lib/fiber/intrinsic-jsx.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type * as Props from "@tscircuit/props"
2-
import type { VoltageSourceProps } from "lib/components/normal-components/VoltageSource"
32
import type { DetailedHTMLProps, SVGProps } from "react"
43

54
export interface TscircuitElements {
@@ -75,7 +74,7 @@ export interface TscircuitElements {
7574
switch: Props.SwitchProps
7675
mosfet: Props.MosfetProps
7776
testpoint: Props.TestpointProps
78-
voltagesource: VoltageSourceProps
77+
voltagesource: Props.VoltageSourceProps
7978
voltageprobe: Props.VoltageProbeProps
8079
copperpour: Props.CopperPourProps
8180
analogsimulation: Props.AnalogSimulationProps

0 commit comments

Comments
 (0)