MustafaMulla29/wireless-mouse-pcb
This code defines a 3.3V low dropout voltage regulator chip (AP2112K-3.3TRG1) with five pins (VIN, GND, Enable, NC, VOUT) and its associated PCB footprint and 3D models for hardware implementation.
- Version
- 1.0.6
- License
- unset
- Stars
- 0
sections/shared.tsx
import {
Children,
Fragment,
cloneElement,
isValidElement,
type ReactElement,
type ReactNode,
} from "react"
export const SIGNAL_TRACE = "0.15mm"
export const POWER_TRACE = "0.2mm"
export const withSchematicSheet = (
sheetName: string,
node: ReactNode,
schematicOffsetX = 0,
schematicOffsetY = 0,
): ReactNode => {
if (!isValidElement(node)) return node
if (node.type === Fragment) {
const fragmentProps = node.props as { children?: ReactNode }
return (
<>
{Children.map(fragmentProps.children, (child) =>
withSchematicSheet(
sheetName,
child,
schematicOffsetX,
schematicOffsetY,
),
)}
</>
)
}
const element = node as ReactElement<{ schX?: number; schY?: number }>
const schX = element.props.schX
const schY = element.props.schY
return cloneElement(element as ReactElement<any>, {
schSheetName: sheetName,
...(typeof schX === "number" && schematicOffsetX !== 0
? { schX: schX + schematicOffsetX }
: {}),
...(typeof schY === "number" && schematicOffsetY !== 0
? { schY: schY + schematicOffsetY }
: {}),
})
}
interface NetTraceProps {
name?: string
from: string
to: string
width?: string
schSheetName?: string
}
export const NetTrace = ({
name,
from,
to,
width = SIGNAL_TRACE,
}: NetTraceProps) => (
<trace
name={name ?? ("TRACE_" + from + "_" + to).replace(/[^A-Za-z0-9_]+/g, "_")}
schDisplayLabel={name ?? ""}
from={from}
to={to}
width={width}
/>
)