From fa19dbc9791e95143f6c7c784bc78332ab5cd5b0 Mon Sep 17 00:00:00 2001 From: Ben Christel Date: Tue, 9 Jul 2024 14:20:50 -0700 Subject: [PATCH] Move getLines to polygon.tsx (#1398) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: It's only used by the polygon graph, and doesn't seem like a good candidate for reuse (with a name like getLines, how would people find it?) so I moved it closer to its usage site. Issue: none ## Test plan: `yarn test` Author: benchristel Reviewers: Myranae, jeremywiebe, mark-fitzgerald, nicolecomputer, nishasy Required Reviewers: Approved By: Myranae Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1398 --- .changeset/brave-rats-speak.md | 5 +++++ .../src/widgets/interactive-graphs/graphs/polygon.tsx | 9 ++++++++- .../src/widgets/interactive-graphs/graphs/utils.ts | 8 -------- 3 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 .changeset/brave-rats-speak.md diff --git a/.changeset/brave-rats-speak.md b/.changeset/brave-rats-speak.md new file mode 100644 index 0000000000..d27f1e2b35 --- /dev/null +++ b/.changeset/brave-rats-speak.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Internal: move the getLines function to polygon.tsx diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx index 24d4fff15c..e379bb4b44 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx @@ -9,9 +9,9 @@ import {PolygonAngle} from "./components/angle-indicators"; import {StyledMovablePoint} from "./components/movable-point"; import {TextLabel} from "./components/text-label"; import {useDraggable} from "./use-draggable"; -import {getLines} from "./utils"; import type {MafsGraphProps, PolygonGraphState} from "../types"; +import type {CollinearTuple} from "@khanacademy/perseus"; type Props = MafsGraphProps; @@ -124,3 +124,10 @@ export const PolygonGraph = (props: Props) => { ); }; + +function getLines(points: readonly vec.Vector2[]): CollinearTuple[] { + return points.map((point, i) => { + const next = points[(i + 1) % points.length]; + return [point, next]; + }); +} diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/utils.ts b/packages/perseus/src/widgets/interactive-graphs/graphs/utils.ts index 011e9c774a..4c2fce42e4 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/utils.ts +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/utils.ts @@ -1,4 +1,3 @@ -import type {CollinearTuple} from "../../../perseus-types"; import type {Interval, vec} from "mafs"; /** @@ -42,13 +41,6 @@ export const getIntersectionOfRayWithBox = ( } }; -export const getLines = (points: readonly vec.Vector2[]): CollinearTuple[] => { - return points.map((point, i) => { - const next = points[(i + 1) % points.length]; - return [point, next]; - }); -}; - function isBetween(x: number, low: number, high: number) { return x >= low && x <= high; }