From f5711a331f6fce02d8c5f753e752fd8665b90344 Mon Sep 17 00:00:00 2001 From: Ben Christel Date: Tue, 9 Jul 2024 09:21:11 -0700 Subject: [PATCH] Resolve a couple TODO comments (#1391) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: none ## Test plan: `yarn test` Author: benchristel Reviewers: mark-fitzgerald, nicolecomputer, SonicScrewdriver Required Reviewers: Approved By: mark-fitzgerald Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1391 --- .changeset/serious-bananas-build.md | 5 +++++ .../src/widgets/interactive-graphs/axis-ticks.tsx | 8 ++------ .../graphs/components/axis-tick-labels.tsx | 9 ++------- .../graphs/components/movable-point-view.tsx | 4 +--- 4 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 .changeset/serious-bananas-build.md diff --git a/.changeset/serious-bananas-build.md b/.changeset/serious-bananas-build.md new file mode 100644 index 0000000000..12d2cf7f78 --- /dev/null +++ b/.changeset/serious-bananas-build.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Internal: Resolve TODO comments diff --git a/packages/perseus/src/widgets/interactive-graphs/axis-ticks.tsx b/packages/perseus/src/widgets/interactive-graphs/axis-ticks.tsx index 2c5ec61e66..73114597b3 100644 --- a/packages/perseus/src/widgets/interactive-graphs/axis-ticks.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/axis-ticks.tsx @@ -120,12 +120,8 @@ export const AxisTicks = () => { height, }; - // TODO(benchristel): destructure these in one line - const [xMin, xMax] = range[X]; - const [yMin, yMax] = range[Y]; - - const yTickStep = tickStep[Y]; - const xTickStep = tickStep[X]; + const [[xMin, xMax], [yMin, yMax]] = range; + const [xTickStep, yTickStep] = tickStep; const yGridTicks = generateTickLocations(yTickStep, yMin, yMax); const xGridTicks = generateTickLocations(xTickStep, xMin, xMax); diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/components/axis-tick-labels.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/components/axis-tick-labels.tsx index ba945832f0..5113f0c80b 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/components/axis-tick-labels.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/components/axis-tick-labels.tsx @@ -1,6 +1,5 @@ import * as React from "react"; -import {X, Y} from "../../math"; import useGraphConfig from "../../reducer/use-graph-config"; import {pointToPixel} from "../use-transform"; @@ -42,12 +41,8 @@ export const AxisTickLabels = () => { const graphConfig = useGraphConfig(); const {tickStep, range} = graphConfig; - // TODO(benchristel): use destructuring here - const [xMin, xMax] = range[X]; - const [yMin, yMax] = range[Y]; - - const yTickStep = tickStep[Y]; - const xTickStep = tickStep[X]; + const [[xMin, xMax], [yMin, yMax]] = range; + const [xTickStep, yTickStep] = tickStep; const yGridTicks = generateTickLocations(yTickStep, yMin, yMax); const xGridTicks = generateTickLocations(xTickStep, xMin, xMax); diff --git a/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-point-view.tsx b/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-point-view.tsx index 453b49d6e3..35eb6dcc9b 100644 --- a/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-point-view.tsx +++ b/packages/perseus/src/widgets/interactive-graphs/graphs/components/movable-point-view.tsx @@ -57,9 +57,7 @@ export const MovablePointView = forwardRef( const [[x, y]] = useTransformVectorsToPixels(point); - // TODO(benchristel): destructure range in one line - const [xMin, xMax] = range[X]; - const [yMin, yMax] = range[Y]; + const [[xMin, xMax], [yMin, yMax]] = range; const [[verticalStartX]] = useTransformVectorsToPixels([xMin, 0]); const [[verticalEndX]] = useTransformVectorsToPixels([xMax, 0]);