Skip to content

Commit

Permalink
wip: working
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole Watts committed Sep 6, 2024
1 parent c4432ff commit 569eb2f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ describe("MafsGraph", () => {
type: "point",
numPoints: 2,
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 447 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
hasBeenInteractedWith: true,
range: [
[-10, 10],
Expand Down Expand Up @@ -700,6 +701,7 @@ describe("MafsGraph", () => {
type: "point",
numPoints: "unlimited",
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 704 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
hasBeenInteractedWith: true,
range: [
[-10, 10],
Expand Down Expand Up @@ -734,6 +736,7 @@ describe("MafsGraph", () => {
type: "point",
numPoints: "unlimited",
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 739 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.test.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
hasBeenInteractedWith: true,
range: [
[-10, 10],
Expand Down
54 changes: 43 additions & 11 deletions packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import {type InteractiveGraphAction} from "./reducer/interactive-graph-action";
import {actions} from "./reducer/interactive-graph-action";
import {GraphConfigContext} from "./reducer/use-graph-config";

import type {InteractiveGraphState, InteractiveGraphProps} from "./types";
import type {
InteractiveGraphState,
InteractiveGraphProps,
PointGraphState,
} from "./types";
import type {vec} from "mafs";

import "mafs/core.css";
Expand Down Expand Up @@ -168,21 +172,49 @@ export const MafsGraph = (props: MafsGraphProps) => {
};

const renderPointGraphControls = (props: {
state: InteractiveGraphState;
state: PointGraphState;
dispatch: (action: InteractiveGraphAction) => unknown;
}) => (
<Button
kind="secondary"
<View
style={{
width: "100%",
marginLeft: "20px",
}}
onClick={() => {
props.dispatch(actions.pointGraph.addPoint([0, 0]));
flexDirection: "row",
}}
>
Add Point
</Button>
<Button
kind="secondary"
style={{
width: "100%",
marginLeft: "20px",
}}
onClick={() => {
props.dispatch(actions.pointGraph.addPoint([0, 0]));
}}
>
Add Point
</Button>
{(props.state.focusedPointIndex !== null ||
props.state.previouslyFocusedPointIndex !== null) && (

Check failure on line 196 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?

Check failure on line 196 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?

Check failure on line 196 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Publish npm snapshot (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?
<Button
kind="secondary"
color="destructive"
style={{
width: "100%",
marginLeft: "20px",
}}
onClick={(event) => {
event.preventDefault();
console.log(props.state.focusedPointIndex);

Check failure on line 206 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Unexpected console statement
props.dispatch(
actions.pointGraph.removePoint(
props.state.previouslyFocusedPointIndex!,

Check failure on line 209 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?

Check failure on line 209 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?

Check failure on line 209 in packages/perseus/src/widgets/interactive-graphs/mafs-graph.tsx

View workflow job for this annotation

GitHub Actions / Publish npm snapshot (ubuntu-latest, 20.x)

Property 'previouslyFocusedPointIndex' does not exist on type 'PointGraphState'. Did you mean 'previouslyFocusedPoint'?
),
);
}}
>
Remove Point
</Button>
)}
</View>
);

const renderGraphControls = (props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function initializeGraphState(
coords: getPointCoords(graph, range, step),
numPoints: graph.numPoints || 0,
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 81 in packages/perseus/src/widgets/interactive-graphs/reducer/initialize-graph-state.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?

Check failure on line 81 in packages/perseus/src/widgets/interactive-graphs/reducer/initialize-graph-state.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?

Check failure on line 81 in packages/perseus/src/widgets/interactive-graphs/reducer/initialize-graph-state.ts

View workflow job for this annotation

GitHub Actions / Publish npm snapshot (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
};
case "circle":
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const basePointGraphState: InteractiveGraphState = {
[-10, 10],
],
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 34 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.test.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
snapStep: [1, 1],
coords: [],
};
Expand All @@ -44,6 +45,7 @@ const baseUnlimitedPointGraphState: PointGraphState = {
[-10, 10],
],
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 48 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.test.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
snapStep: [1, 1],
coords: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function doBlurPoint(
case "point":
return {
...state,
previouslyFocusedPointIndex: state.focusedPointIndex,

Check failure on line 144 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?

Check failure on line 144 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.ts

View workflow job for this annotation

GitHub Actions / Publish npm snapshot (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
focusedPointIndex: null,
};
default:
Expand Down Expand Up @@ -605,6 +606,7 @@ function doRemovePoint(
...state,
coords: state.coords.filter((_, i) => i !== action.index),
focusedPointIndex: null,
previouslyFocusedPointIndex: null,

Check failure on line 609 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.ts

View workflow job for this annotation

GitHub Actions / Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?

Check failure on line 609 in packages/perseus/src/widgets/interactive-graphs/reducer/interactive-graph-reducer.ts

View workflow job for this annotation

GitHub Actions / Publish npm snapshot (ubuntu-latest, 20.x)

Object literal may only specify known properties, but 'previouslyFocusedPointIndex' does not exist in type 'PointGraphState'. Did you mean to write 'previouslyFocusedPoint'?
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/perseus/src/widgets/interactive-graphs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface PointGraphState extends InteractiveGraphStateCommon {
coords: Coord[];
numPoints?: number | "unlimited";
focusedPointIndex: number | null;
previouslyFocusedPoint: number | null;
}

export interface RayGraphState extends InteractiveGraphStateCommon {
Expand Down

0 comments on commit 569eb2f

Please sign in to comment.