Automatically create variable for setAngle and setLength (#108)

This commit is contained in:
Kurt Hutten
2023-04-07 01:21:33 +10:00
committed by GitHub
parent 52b2e26ac5
commit 0fa56c3f15
2 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ export const SetAngleLengthModal = ({
onReject, onReject,
value: initialValue, value: initialValue,
valueName, valueName,
shouldCreateVariable: initialShouldCreateVariable = false,
}: { }: {
isOpen: boolean isOpen: boolean
onResolve: (a: { onResolve: (a: {
@ -27,10 +28,13 @@ export const SetAngleLengthModal = ({
onReject: (a: any) => void onReject: (a: any) => void
value: number value: number
valueName: string valueName: string
shouldCreateVariable: boolean
}) => { }) => {
const [sign, setSign] = useState(Math.sign(Number(initialValue))) const [sign, setSign] = useState(Math.sign(Number(initialValue)))
const [value, setValue] = useState(String(initialValue * sign)) const [value, setValue] = useState(String(initialValue * sign))
const [shouldCreateVariable, setShouldCreateVariable] = useState(false) const [shouldCreateVariable, setShouldCreateVariable] = useState(
initialShouldCreateVariable
)
const { const {
prevVariables, prevVariables,

View File

@ -103,6 +103,7 @@ export const SetAngleLength = ({
await getModalInfo({ await getModalInfo({
value: forceVal, value: forceVal,
valueName: angleOrLength === 'setAngle' ? 'angle' : 'length', valueName: angleOrLength === 'setAngle' ? 'angle' : 'length',
shouldCreateVariable: true,
} as any) } as any)
let finalValue = removeDoubleNegatives(valueNode, sign, variableName) let finalValue = removeDoubleNegatives(valueNode, sign, variableName)
if ( if (