Skip to content

Commit bc5e9d7

Browse files
committed
added changing strokeWidth of all transitions in other features too when stateSize is changed
1 parent 6ee3663 commit bc5e9d7

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

src/features/TestAString.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ const TestAString = (props: TestAStringProps) => {
258258
end: `${transition.end}ts`,
259259
};
260260
}),
261+
setTransitions: setTestAStringTransitions,
261262
currentStates: statesToHighlight.map((state) => `${state}ts`),
262263
stateSize: dataContext.stateSize,
263264
};

src/features/components/minimzeDfa/MinimizedDfa.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export const MinimizedDfa = (props: MinimizedDfaProps) => {
492492
const playgroundProps: ToolsPlaygroundProps = {
493493
states: minimizedDfaStates,
494494
transitions: minimizedDfaTransitions,
495+
setTransitions: setMinimizedDfaTransitions,
495496
canvasWidth: "150%",
496497
stateSize: props.stateSize,
497498
};

src/features/components/nfaToDfa/NullClosure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import PauseRoundedIcon from "@mui/icons-material/PauseRounded";
2828
import ReplayRoundedIcon from "@mui/icons-material/ReplayRounded";
2929
import { PossibleTransitionValues } from "../../../consts/PossibleTransitionValues";
3030
import { stateSelectedColor } from "../../../consts/Colors";
31-
import { DataContext } from "../../../components/Editor";
3231
import { StyledTransitionLabel } from "../playground/StyledTransitionLabel";
3332

3433
const numberOfColumns = 2; // one for state and one for null
@@ -233,6 +232,7 @@ export const NullClosure = (props: NullClosureProps) => {
233232
const playgroundProps: ToolsPlaygroundProps = {
234233
states: nullClosureStates,
235234
transitions: nullClosureTransitions,
235+
setTransitions: setNullClosureTransitions,
236236
stateSize: props.stateSize,
237237
};
238238

src/features/components/nfaToDfa/ResultantDfa.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ export const ResultantDfa = (props: ResultantDfaProps) => {
484484
const playgroundProps: ToolsPlaygroundProps = {
485485
states: resultantDfaStates,
486486
transitions: resultantDfaTransitions,
487+
setTransitions: setResultantDfaTransitions,
487488
stateSize: props.stateSize,
488489
};
489490

src/features/components/tools/Playground.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ import Draggable from "react-draggable";
66
import { startingStateColor, stateHoverColor } from "../../../consts/Colors";
77
import { XarrowCoreProps } from "../playground/props/XarrowProps";
88
import { Box } from "@mui/material";
9+
import { useEffect } from "react";
910

1011
export const ToolsPlayground = (props: ToolsPlaygroundProps) => {
1112
console.log("re rendering ToolsPlayground: props", props);
1213

1314
const updateXarrow = useXarrow();
1415

16+
useEffect(() => {
17+
props.setTransitions((transitions) =>
18+
transitions.map((t) => {
19+
return {
20+
...t,
21+
strokeWidth: props?.stateSize / 10,
22+
};
23+
})
24+
);
25+
}, [props?.stateSize]);
26+
1527
const stateToInquire = props.states?.at(0)?.id;
1628
const uniqueWord = // to ensure that the xarrow is unique
1729
stateToInquire?.includes("nc")
@@ -45,7 +57,7 @@ export const ToolsPlayground = (props: ToolsPlaygroundProps) => {
4557
onDragOver={(e) => e.preventDefault()}
4658
>
4759
{props.states.map((state) => (
48-
<Draggable onDrag={updateXarrow}>
60+
<Draggable bounds="parent" onDrag={updateXarrow}>
4961
<Box
5062
className="state"
5163
sx={{

src/features/components/tools/props/PlaygroundProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DraggableStateModel, TransitionModel } from "../../../../models";
33
export type ToolsPlaygroundProps = {
44
states: DraggableStateModel[];
55
transitions: TransitionModel[];
6+
setTransitions: React.Dispatch<React.SetStateAction<TransitionModel[]>>;
67
canvasWidth?: number | string;
78
currentStates?: string[];
89
stateSize?: number;

0 commit comments

Comments
 (0)