From 87722e5ae176cf9eee122b628916496b478823b7 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Mon, 31 Jan 2022 16:19:22 -0500 Subject: [PATCH] chore: Refactor to refer to an input box rather than to a slider which no longer exists --- lib/.utils.js.swp | Bin 0 -> 20480 bytes lib/comparisonView.js | 47 ++++------- lib/inputBox.js | 50 ++++++++++++ lib/slider.js | 179 ------------------------------------------ 4 files changed, 67 insertions(+), 209 deletions(-) create mode 100644 lib/.utils.js.swp create mode 100644 lib/inputBox.js delete mode 100644 lib/slider.js diff --git a/lib/.utils.js.swp b/lib/.utils.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..991b1f0ffe208788688fac28eeff6d26d9afb670 GIT binary patch literal 20480 zcmeHOZHy#E8EypxLFD^W!MfQ!u4i{=W@q;M_V&(`0Y~g zcK0~;_+d4F=C2#y=(qB%(2*Bpw*?hkrDn5iww*NCHOjBcRdesqUKXsp+}B zJ4_JmPM+=Qx2xWI>#4WiuD7~(e)yI>`^03iY~Z-iFn<2vUoHP?^X#$F3yp?%$f0*1Nall{1$i?_%ZM>@F}1U)PNg+>wymdR|4k(e}~;a1ik^x1ABmf zonsiU0#5-?0#5+PfX@K;0yc0NaQtk;SOIPY_5-uP5b*jt&Qcm{Y1_yO<;Fb^CAZUqhi`+@fX*8(qL zv*i!KkAR1PgTOej8OQ;ffS0jha}0O@xEi<$cp95FU%?rNy}IQ2p{ROp5DLew`nDA~ z?&4ktmovh2^I~SZ*y;P$;o^etHBI>w;^HCuaA4;1(}qzhi4HA`w%6QeTQ2KczArW4 zT=eZ)t7@C3H6-REp%@VJL!z9Y7SM6KFw3GOSh8Wei(x$y*PNQWB@`>3e@FzLSg{)o zvEccl;jIX_)ttBeplGZaLil#r@?Ejd3hTwH?KDgiR@v3iuHDpvJ^rFSi=NJg_ENxZ z4T`3<+9l4zf(kkncSwCwBKfiXWh-=+?NoI~3}bD2-3ol7(rSbhH0%(j@d|uM zr?lO%XuQ)#3LWVfO`4e)$k;gYlv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?oh-o~~>IaRk!gi5&8#sHbrm7W?^9J3zV5pNb#rIb#Mr!a+0 zn|9}WG8J!dY)F*K4$U6vsoM1DMM|1K>*;G+$KoACZ1$*46h?&ZFKw`~s&dE;4RtvoTls1!lX>)!3M}oCEarfN2)UZ%Ir z2(EWph?Tn2u(3nW@sGCR(#xTpbhQH81HNP=mm89SUN;=u=yELhcTnJ!1+CC6Av3y6 zzGP5u3gl}7Z`t;-;#$#O6O4{cOiqlBP2s<>U6csbi-OQASdFE+h1X7aHNah$!kyN# z6;yp^DJ(^`CMUXc#UPb z;V1$--0w7PuN5lskZ1Q1CEj_B_at;u`2^ggSulfZWtHj$^Z&;&KkMu= zrV|Jg$Hcc-mZX5Eg97l{W{3hQ(mooh9F~>#r25Fw#q5xxX#h_ZB40b{4ee)b0Mfm zQW*sKXH^NH^Ql$A=>2btb$Gf`K$3g?|( zH=ecTDAOQA|3y4+0s4lpaM|a<~;i zBuy{3DIrtklB6lw>3wua0`(S?)++7%$7NMc$#Re>@|A3Jifk}NmOkx}*hL$yNY8{k zl5bny*awj8sqTEpu-Y=^eB3M2d&RU+m$9e%yQduqeaanoC1k3NJt_Lw-3?y5^!`AT lL#7*;P}uvU%?&E{{*d!zDn{>i@DXYIE17N^- { if (!dontPushSubmitButtonAnyMore) { - if (sliderValue < 1 && sliderValue > 0) { - sliderValue = 1 / sliderValue; + if (inputValue < 1 && inputValue > 0) { + inputValue = 1 / inputValue; [element1, element2] = [element2, element1]; } - console.log(`posList@nextStepSlider:`); + console.log(`posList@nextStepInput:`); console.log(posList); let [successStatus, result] = nextStepSimple( posList, @@ -321,7 +321,7 @@ export default function ComparisonView({ listOfElementsForView }) { let newQuantitativeComparison = [ element1, element2, - sliderValue, + inputValue, reasoning, ]; let newQuantitativeComparisons = [ @@ -330,7 +330,7 @@ export default function ComparisonView({ listOfElementsForView }) { ]; setQuantitativeComparisons(newQuantitativeComparisons); - setSliderValue(DEFAULT_COMPARE()); + setInputValue(DEFAULT_COMPARE()); setReasoning(""); changeNumSteps(numSteps + 1); if (successStatus) { @@ -396,7 +396,7 @@ export default function ComparisonView({ listOfElementsForView }) { - {/* Comparison actuator (text, previously slider) */} + {/* Comparison actuator (text, previously input) */}

@@ -406,11 +406,11 @@ export default function ComparisonView({ listOfElementsForView }) { { //console.log(event) //console.log(event.target.value) - setSliderValue(event.target.value); + setInputValue(event.target.value); }} />
@@ -418,13 +418,13 @@ export default function ComparisonView({ listOfElementsForView }) {
-
@@ -450,19 +450,6 @@ export default function ComparisonView({ listOfElementsForView }) { />
-
- {/* Old slider element (previous actuator) - -
- (setSliderValue(event[0]))} - value={sliderValue} - displayFunction={displayFunctionSlider} - domain={domain} - /> -
- */}
{/* Results section */} diff --git a/lib/inputBox.js b/lib/inputBox.js new file mode 100644 index 0000000..9a4b287 --- /dev/null +++ b/lib/inputBox.js @@ -0,0 +1,50 @@ +/* Imports */ +import React, { useState } from "react"; + +export function InputBox({ + posList, + binaryComparisons, + inputValue, + reasoning, + toComparePair, + nextStepInput, + dontPushSubmitButtonAnyMore, +}) { + // This element didn't necessarily have to exist, but it made it easier for debugging purposes + let onClick = (event) => { + if (!dontPushSubmitButtonAnyMore) { + //event.preventDefault(); + let obj = { + posList, + binaryComparisons, + inputValue, + reasoning, + element1: toComparePair[1], + element2: toComparePair[0], + }; + // + console.log("input@SubmitInputButton"); + console.log(obj); + if (!!Number(inputValue) && inputValue >= 0) { + nextStepInput(obj); + } else if (!!Number(inputValue) && inputValue < 0) { + alert("Negative numbers not yet allowed"); + } else { + alert("Your input is not a number"); + } + } + }; + + return ( + + ); +} diff --git a/lib/slider.js b/lib/slider.js deleted file mode 100644 index 9baadf8..0000000 --- a/lib/slider.js +++ /dev/null @@ -1,179 +0,0 @@ -/* Imports */ -import { Slider, Rail, Handles, Tracks, Ticks } from "react-compound-slider"; -import React, { useState } from "react"; -// https://sghall.github.io/react-compound-slider/#/getting-started/tutorial - -/* Definitions */ - -const sliderStyle = { - // Give the slider some width - position: "relative", - width: "40em", - height: 40, - border: "5em", -}; - -const railStyle = { - position: "absolute", - width: "100%", - height: 15, - marginTop: 32.5, - borderRadius: 5, - backgroundColor: "lightgrey", -}; - -/* Support functions */ -function Handle({ - handle: { id, value, percent }, - getHandleProps, - displayFunction, - handleWidth, -}) { - return ( - <> -
- {displayFunction(value)} -
-
- - ); -} - -function Track({ source, target, getTrackProps }) { - return ( -
- ); -} - -/* Body */ -// Two functions, essentially identical. -export function SliderElement({ onChange, value, displayFunction, domain }) { - let toLogDomain = (arr) => [ - Math.log(arr[0]) / Math.log(10), - Math.log(arr[1]) / Math.log(10), - ]; - return ( - - - {({ getRailProps }) =>
} - - - {({ handles, getHandleProps }) => ( -
- {handles.map((handle) => ( - - ))} -
- )} -
- - {({ tracks, getTrackProps }) => ( -
- {tracks.map(({ id, source, target }) => ( - - ))} -
- )} -
- - ); -} - -export function SubmitSliderButton({ - posList, - binaryComparisons, - sliderValue, - reasoning, - toComparePair, - nextStepSlider, - dontPushSubmitButtonAnyMore, -}) { - // This element didn't necessarily have to exist, but it made it easier for debugging purposes - let onClick = (event) => { - if (!dontPushSubmitButtonAnyMore) { - //event.preventDefault(); - let obj = { - posList, - binaryComparisons, - sliderValue, - reasoning, - element1: toComparePair[1], - element2: toComparePair[0], - }; - // - console.log("input@SubmitSliderButton"); - console.log(obj); - if (!!Number(sliderValue) && sliderValue >= 0) { - nextStepSlider(obj); - } else if (!!Number(sliderValue) && sliderValue < 0) { - alert("Negative numbers not yet allowed"); - } else { - alert("Your input is not a number"); - } - } - }; - - return ( - - ); -} -