Automatically create variable for setAngle and setLength (#108)
This commit is contained in:
@ -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,
|
||||||
|
@ -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 (
|
||||||
|
Reference in New Issue
Block a user