Skip to content

Commit

Permalink
Once again succumb to react-docgen-typescript's unreliability
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpetryk committed Feb 19, 2024
1 parent 1f2d933 commit cb41cf2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"test:unit": "jest",
"test:e2e": "tsx scripts/testgen.ts && playwright test",
"build": "tsx scripts/build.ts",
"build:docs": "pnpm -s docgen && cd docs && pnpm -s build",
"docgen": "tsx scripts/docgen.ts",
"api-report:update": "pnpm tsc && api-extractor run --local",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
Expand Down
2 changes: 1 addition & 1 deletion scripts/docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const writePath = path.join(projectRoot, "docs/generated-docgen.tsx")

const contents = `
// prettier-ignore
const docgenInfo = ${JSON.stringify(docgenInfo)} as const;
const docgenInfo = ${JSON.stringify(docgenInfo, null, 2)} as const;
export default docgenInfo;
`

Expand Down
6 changes: 4 additions & 2 deletions src/display/Plot.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OfX, OfY } from "./Plot/Simple"
import { OfX } from "./Plot/OfX"
import { OfY } from "./Plot/OfY"
import { Parametric } from "./Plot/Parametric"
import { VectorField } from "./Plot/VectorField"
import { Inequality } from "./Plot/Inequality"
Expand All @@ -12,7 +13,8 @@ export const Plot = {
}

import type { InequalityProps } from "./Plot/Inequality"
import type { OfXProps, OfYProps } from "./Plot/Simple"
import type { OfXProps } from "./Plot/OfX"
import type { OfYProps } from "./Plot/OfY"
import type { ParametricProps } from "./Plot/Parametric"
import type { VectorFieldProps } from "./Plot/VectorField"
export type { InequalityProps, OfXProps, OfYProps, ParametricProps, VectorFieldProps }
18 changes: 0 additions & 18 deletions src/display/Plot/Simple.tsx → src/display/Plot/OfX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,3 @@ export function OfX({ y, ...props }: OfXProps) {
}

OfX.displayName = "Plot.OfX"

export interface OfYProps extends Omit<ParametricProps, "xy" | "t"> {
x: (y: number) => number
svgPathProps?: React.SVGProps<SVGPathElement>
}

export function OfY({ x, ...props }: OfYProps) {
const {
yPaneRange: [yMin, yMax],
} = usePaneContext()

const xy = React.useCallback<ParametricProps["xy"]>((y) => [x(y), y], [x])
const t = React.useMemo<vec.Vector2>(() => [yMin, yMax], [yMin, yMax])

return <Parametric xy={xy} t={t} {...props} />
}

OfY.displayName = "Plot.OfY"
22 changes: 22 additions & 0 deletions src/display/Plot/OfY.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from "react"
import { usePaneContext } from "../../context/PaneContext"
import { Parametric, ParametricProps } from "./Parametric"
import { vec } from "../../vec"

export interface OfYProps extends Omit<ParametricProps, "xy" | "t"> {
x: (y: number) => number
svgPathProps?: React.SVGProps<SVGPathElement>
}

export function OfY({ x, ...props }: OfYProps) {
const {
yPaneRange: [yMin, yMax],
} = usePaneContext()

const xy = React.useCallback<ParametricProps["xy"]>((y) => [x(y), y], [x])
const t = React.useMemo<vec.Vector2>(() => [yMin, yMax], [yMin, yMax])

return <Parametric xy={xy} t={t} {...props} />
}

OfY.displayName = "Plot.OfY"
4 changes: 4 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"buildCommand": "pnpm -s docgen && cd docs && pnpm -s build",
"outputDirectory": "docs/build"
}

0 comments on commit cb41cf2

Please sign in to comment.