disableLogX flag in local settings
This commit is contained in:
parent
eefdfbb2fe
commit
d2fb973e1d
|
@ -87,6 +87,7 @@ const ItemSettingsModal: React.FC<Props & { close: () => void }> = ({
|
||||||
register={register}
|
register={register}
|
||||||
withShowEditorSetting={false}
|
withShowEditorSetting={false}
|
||||||
withFunctionSettings={withFunctionSettings}
|
withFunctionSettings={withFunctionSettings}
|
||||||
|
disableLogXSetting={disableLogX}
|
||||||
/>
|
/>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
@ -33,10 +33,12 @@ type FormFields = yup.InferType<typeof viewSettingsSchema>;
|
||||||
export const ViewSettings: React.FC<{
|
export const ViewSettings: React.FC<{
|
||||||
withShowEditorSetting?: boolean;
|
withShowEditorSetting?: boolean;
|
||||||
withFunctionSettings?: boolean;
|
withFunctionSettings?: boolean;
|
||||||
|
disableLogXSetting?: boolean;
|
||||||
register: UseFormRegister<FormFields>;
|
register: UseFormRegister<FormFields>;
|
||||||
}> = ({
|
}> = ({
|
||||||
withShowEditorSetting = true,
|
withShowEditorSetting = true,
|
||||||
withFunctionSettings = true,
|
withFunctionSettings = true,
|
||||||
|
disableLogXSetting,
|
||||||
register,
|
register,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
|
@ -66,6 +68,12 @@ export const ViewSettings: React.FC<{
|
||||||
register={register}
|
register={register}
|
||||||
name="logX"
|
name="logX"
|
||||||
label="Show x scale logarithmically"
|
label="Show x scale logarithmically"
|
||||||
|
disabled={disableLogXSetting}
|
||||||
|
tooltip={
|
||||||
|
disableLogXSetting
|
||||||
|
? "Your distribution has mass lower than or equal to 0. Log only works on strictly positive values."
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
register={register}
|
register={register}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import clsx from "clsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Path, UseFormRegister } from "react-hook-form";
|
import { Path, UseFormRegister } from "react-hook-form";
|
||||||
|
|
||||||
|
@ -5,20 +6,32 @@ export function Checkbox<T>({
|
||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
register,
|
register,
|
||||||
|
disabled,
|
||||||
|
tooltip,
|
||||||
}: {
|
}: {
|
||||||
name: Path<T>;
|
name: Path<T>;
|
||||||
label: string;
|
label: string;
|
||||||
register: UseFormRegister<T>;
|
register: UseFormRegister<T>;
|
||||||
|
disabled?: boolean;
|
||||||
|
tooltip?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<label className="flex items-center">
|
<label className="flex items-center" title={tooltip}>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
disabled={disabled}
|
||||||
{...register(name)}
|
{...register(name)}
|
||||||
className="form-checkbox focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded"
|
className="form-checkbox focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded"
|
||||||
/>
|
/>
|
||||||
{/* Clicking on the div makes the checkbox lose focus while mouse button is pressed, leading to annoying blinking; I couldn't figure out how to fix this. */}
|
{/* Clicking on the div makes the checkbox lose focus while mouse button is pressed, leading to annoying blinking; I couldn't figure out how to fix this. */}
|
||||||
<div className="ml-3 text-sm font-medium text-gray-700">{label}</div>
|
<div
|
||||||
|
className={clsx(
|
||||||
|
"ml-3 text-sm font-medium",
|
||||||
|
disabled ? "text-gray-400" : "text-gray-700"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user