Skip to content

Add SchematicSheet props and introduce schSheetName common prop#705

Open
seveibar wants to merge 1 commit into
mainfrom
codex/introduce-schematicsheet-component
Open

Add SchematicSheet props and introduce schSheetName common prop#705
seveibar wants to merge 1 commit into
mainfrom
codex/introduce-schematicsheet-component

Conversation

@seveibar

Copy link
Copy Markdown
Contributor

Motivation

  • Provide a top-level schematic grouping similar to sections so schematics can have named sheets with display titles and nested children.
  • Expose a common schSheetName component prop to let components opt into being drawn on a specific sheet analogous to schSectionName.

Description

  • Add SchematicSheetProps and schematicSheetProps schema in lib/components/schematic-sheet.ts with required name and displayName and optional children.
  • Add schSheetName?: string to CommonComponentProps and the commonComponentProps Zod schema in lib/common/layout.ts with a descriptive comment matching the schSectionName pattern.
  • Export the new sheet component from the package entrypoint in lib/index.ts and update scripts/generate-readme-docs.ts so generated docs include the new sheet prop and schSheetName documentation.
  • Add unit tests in tests/schematic-sheet.test.ts that validate parsing with and without children and that displayName is required.

Testing

  • Ran the component/type generation and README scripts with bun scripts/generate-component-types.ts, bun scripts/generate-manual-edits-docs.ts, bun scripts/generate-readme-docs.ts, and bun scripts/generate-props-overview.ts and updated docs successfully.
  • Ran formatter with bun run format and ensured formatting completed without issues.
  • Ran unit tests with bun test tests/schematic-sheet.test.ts which reported 3 pass, 0 fail.
  • Ran TypeScript typecheck with bunx tsc --noEmit which completed without errors.

Codex Task

Comment on lines +1 to +34
import { expect, test } from "bun:test"
import {
schematicSheetProps,
type SchematicSheetProps,
} from "lib/components/schematic-sheet"
import { expectTypeOf } from "expect-type"

test("should parse schematic sheet with name, displayName, and children", () => {
const raw: SchematicSheetProps = {
name: "main",
displayName: "Main Sheet",
children: [{ type: "resistor", props: { name: "R1" } }],
}

expectTypeOf(raw).toMatchTypeOf<SchematicSheetProps>()
const parsed = schematicSheetProps.parse(raw)
expect(parsed.name).toBe("main")
expect(parsed.displayName).toBe("Main Sheet")
expect(parsed.children).toEqual([{ type: "resistor", props: { name: "R1" } }])
})

test("should parse schematic sheet without children", () => {
const raw: SchematicSheetProps = {
name: "power",
displayName: "Power Sheet",
}

const parsed = schematicSheetProps.parse(raw)
expect(parsed.children).toBeUndefined()
})

test("should fail without displayName", () => {
expect(() => schematicSheetProps.parse({ name: "main" })).toThrow()
})

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 three test(...) calls, but the rule states that a *.test.ts file may have AT MOST one test(...). Please split this into multiple numbered files, e.g. schematic-sheet1.test.ts, schematic-sheet2.test.ts, and schematic-sheet3.test.ts, each containing exactly one test.

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

Fix in Graphite


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant