diff --git a/src-ui/logics/configs/config_page_setter/useSettingsLogics.js b/src-ui/logics/configs/config_page_setter/useSettingsLogics.js
index 97245dee..3e0daabf 100644
--- a/src-ui/logics/configs/config_page_setter/useSettingsLogics.js
+++ b/src-ui/logics/configs/config_page_setter/useSettingsLogics.js
@@ -212,17 +212,26 @@ export const useSliderLogic = ({
min,
max,
step = 1,
- show_label_values
+ show_label_values = [],
+ marks_step,
}) => {
+ if (marks_step === undefined) {
+ marks_step = step;
+ }
+
const [ui_value, setUiValue] = useState(current_value.data);
+ const decimalPlaces = marks_step.toString().includes('.')
+ ? marks_step.toString().split('.')[1].length
+ : 0;
const labelFormatter = useCallback((value) => {
- return (show_label_values && show_label_values.includes(value)) ? value : "";
- }, [show_label_values]);
+ if (show_label_values && show_label_values.length > 0) {
+ return show_label_values.includes(value) ? value : "";
+ }
+ return value.toFixed(decimalPlaces);
+ }, [show_label_values, decimalPlaces]);
- const marks = useMemo(() => {
- return createMarks(min, max, step, labelFormatter);
- }, [min, max, step, labelFormatter]);
+ const marks = createMarks(min, max, marks_step, labelFormatter);
const onchangeFunction = useCallback((value) => {
setUiValue(value);
@@ -239,7 +248,7 @@ export const useSliderLogic = ({
if (postUpdateAction) {
postUpdateAction();
}
- }, [current_value.data]);
+ }, [current_value.data, postUpdateAction]);
return {
ui_value,
@@ -249,14 +258,11 @@ export const useSliderLogic = ({
};
};
-const createMarks = (min, max, step = 1, labelFormatter = (value) => value) => {
+const createMarks = (min, max, marks_step = 1, labelFormatter = (value) => value) => {
const marks = [];
- let current_value = min;
- while (current_value <= max) {
- const fixedValue = parseFloat(current_value.toFixed(1));
- const label = labelFormatter(fixedValue);
- marks.push({ value: fixedValue, label: `${label}` });
- current_value += step;
+ for (let value = min; value <= max; value += marks_step) {
+ value = parseFloat(value.toFixed(1));
+ marks.push({ value, label: `${labelFormatter(value)}` });
}
return marks;
};
\ No newline at end of file
diff --git a/src-ui/views/app/config_page/setting_section/setting_box/_components/slider/Slider.jsx b/src-ui/views/app/config_page/setting_section/setting_box/_components/slider/Slider.jsx
index 827c0253..d5e81fcf 100644
--- a/src-ui/views/app/config_page/setting_section/setting_box/_components/slider/Slider.jsx
+++ b/src-ui/views/app/config_page/setting_section/setting_box/_components/slider/Slider.jsx
@@ -3,9 +3,27 @@ import styles from "./Slider.module.scss";
import MUI_Slider from "@mui/material/Slider";
import clsx from "clsx";
+import { useSliderLogic } from "@logics_configs";
+
export const Slider = (props) => {
const location = props.valueLabelDisplayLocation || "top";
+ const {
+ ui_value,
+ onchangeFunction,
+ onchangeCommittedFunction,
+ marks
+ } = useSliderLogic({
+ current_value: props.current_value,
+ setterFunction: props.setterFunction,
+ min: props.min,
+ max: props.max,
+ step: props.step,
+ show_label_values: props.show_label_values,
+ marks_step: props.marks_step,
+ });
+
+
const sliderSx = {
color: "var(--dark_700_color)",
"& .MuiSlider-thumb": {
@@ -86,13 +104,13 @@ export const Slider = (props) => {
aria-label="Default"
// valueLabelDisplay="on"
valueLabelDisplay={props.valueLabelDisplay ? props.valueLabelDisplay : "auto"}
- value={props.variable}
- step={props.step}
+ value={ui_value}
+ step={props.step == null ? null : Number(props.step)}
min={Number(props.min)}
max={Number(props.max)}
- onChange={(_e, value) => props.onchangeFunction(value)}
+ onChange={(_e, value) => onchangeFunction(value)}
onChangeCommitted={(_e, value) =>
- props.onchangeCommittedFunction ? props.onchangeCommittedFunction(value) : null
+ onchangeCommittedFunction ? onchangeCommittedFunction(value) : null
}
onMouseEnter={(event) =>
props.onMouseEnterFunction ? props.onMouseEnterFunction(event) : null
@@ -100,10 +118,10 @@ export const Slider = (props) => {
onMouseLeave={(event) =>
props.onMouseLeaveFunction ? props.onMouseLeaveFunction(event) : null
}
- marks={props.marks}
- track={props.track}
+ marks={marks}
+ track={props.track === undefined ? false : props.track}
orientation={props.orientation}
- valueLabelFormat={`${props.valueLabelFormat ? props.valueLabelFormat : props.variable}`}
+ valueLabelFormat={`${props.valueLabelFormat ? props.valueLabelFormat : ui_value}`}
sx={sliderSx}
/>
diff --git a/src-ui/views/app/config_page/setting_section/setting_box/appearance/Appearance.jsx b/src-ui/views/app/config_page/setting_section/setting_box/appearance/Appearance.jsx
index 71ba7c0d..065da736 100644
--- a/src-ui/views/app/config_page/setting_section/setting_box/appearance/Appearance.jsx
+++ b/src-ui/views/app/config_page/setting_section/setting_box/appearance/Appearance.jsx
@@ -58,32 +58,16 @@ const UiScalingContainer = () => {
const { currentUiScaling, setUiScaling } = useAppearance();
const { asyncUpdateBreakPoint } = useWindow();
- const {
- ui_value,
- onchangeFunction,
- onchangeCommittedFunction,
- marks
- } = useSliderLogic({
- current_value: currentUiScaling,
- setterFunction: setUiScaling,
- postUpdateAction: asyncUpdateBreakPoint,
- min: 40,
- max: 200,
- step: 10,
- show_label_values: [40, 60, 80, 100, 120, 140, 160, 180, 200],
- });
-
return (