tweak: More informative error messages

This commit is contained in:
NunoSempere 2021-11-25 00:50:28 +00:00
parent 3d380e4dfa
commit f7f77b5723

View File

@ -77,11 +77,11 @@ function Track({ source, target, getTrackProps }) {
/* Body */ /* Body */
// Two functions, essentially identical. // Two functions, essentially identical.
export function SliderElement({ onChange, value, displayFunction, domain }) { export function SliderElement({ onChange, value, displayFunction, domain }) {
let toLogDomain = (arr) => [Math.log(arr[0])/Math.log(10), Math.log(arr[1])/Math.log(10)] let toLogDomain = (arr) => [Math.log(arr[0]) / Math.log(10), Math.log(arr[1]) / Math.log(10)]
return ( return (
<Slider <Slider
rootStyle={sliderStyle /* inline styles for the outer div. Can also use className prop. */} rootStyle={sliderStyle /* inline styles for the outer div. Can also use className prop. */}
domain={toLogDomain([1/domain,domain])} domain={toLogDomain([1 / domain, domain])}
values={[value]} values={[value]}
step={0.0001} step={0.0001}
onChange={onChange} onChange={onChange}
@ -125,22 +125,24 @@ export function SliderElement({ onChange, value, displayFunction, domain }) {
) )
} }
export function SubmitSliderButton({posList, binaryComparisons, sliderValue, toComparePair, nextStepSlider}){ export function SubmitSliderButton({ posList, binaryComparisons, sliderValue, toComparePair, nextStepSlider }) {
// This element didn't necessarily have to exist, but it made it easier for debugging purposes // This element didn't necessarily have to exist, but it made it easier for debugging purposes
let onClick = (event) => { let onClick = (event) => {
//event.preventDefault(); //event.preventDefault();
let obj = {posList, binaryComparisons, sliderValue, element1: toComparePair[1], element2: toComparePair[0]} let obj = { posList, binaryComparisons, sliderValue, element1: toComparePair[1], element2: toComparePair[0] }
// //
console.log("input@SubmitSliderButton") console.log("input@SubmitSliderButton")
console.log(obj) console.log(obj)
if(sliderValue >= 0 ){ if (!!Number(sliderValue) && sliderValue >= 0) {
nextStepSlider(obj) nextStepSlider(obj)
}else if(sliderValue < 0){ } else if (!!Number(sliderValue) && sliderValue < 0) {
alert("Negative numbers not yet allowed") alert("Negative numbers not yet allowed")
} else {
alert("Your input is not a number")
} }
} }
return( <button return (<button
className="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded mt-5" className="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded mt-5"
onClick={onClick}> onClick={onClick}>
Submit Submit