Skip to content

Commit fa19dbc

Browse files
authored
Move getLines to polygon.tsx (#1398)
## 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: #1398
1 parent cb4f23b commit fa19dbc

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.changeset/brave-rats-speak.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
Internal: move the getLines function to polygon.tsx

packages/perseus/src/widgets/interactive-graphs/graphs/polygon.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {PolygonAngle} from "./components/angle-indicators";
99
import {StyledMovablePoint} from "./components/movable-point";
1010
import {TextLabel} from "./components/text-label";
1111
import {useDraggable} from "./use-draggable";
12-
import {getLines} from "./utils";
1312

1413
import type {MafsGraphProps, PolygonGraphState} from "../types";
14+
import type {CollinearTuple} from "@khanacademy/perseus";
1515

1616
type Props = MafsGraphProps<PolygonGraphState>;
1717

@@ -124,3 +124,10 @@ export const PolygonGraph = (props: Props) => {
124124
</>
125125
);
126126
};
127+
128+
function getLines(points: readonly vec.Vector2[]): CollinearTuple[] {
129+
return points.map((point, i) => {
130+
const next = points[(i + 1) % points.length];
131+
return [point, next];
132+
});
133+
}

packages/perseus/src/widgets/interactive-graphs/graphs/utils.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type {CollinearTuple} from "../../../perseus-types";
21
import type {Interval, vec} from "mafs";
32

43
/**
@@ -42,13 +41,6 @@ export const getIntersectionOfRayWithBox = (
4241
}
4342
};
4443

45-
export const getLines = (points: readonly vec.Vector2[]): CollinearTuple[] => {
46-
return points.map((point, i) => {
47-
const next = points[(i + 1) % points.length];
48-
return [point, next];
49-
});
50-
};
51-
5244
function isBetween(x: number, low: number, high: number) {
5345
return x >= low && x <= high;
5446
}

0 commit comments

Comments
 (0)