[Refactor] Improve clarity of slider logic by inverting label filtering.
This commit is contained in:
@@ -212,16 +212,13 @@ export const useSliderLogic = ({
|
||||
min,
|
||||
max,
|
||||
step = 1,
|
||||
hidden_label_values
|
||||
show_label_values
|
||||
}) => {
|
||||
const [ui_value, setUiValue] = useState(current_value.data);
|
||||
|
||||
const labelFormatter = useCallback((value) => {
|
||||
if (hidden_label_values && hidden_label_values.includes(value)) {
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
}, [hidden_label_values]);
|
||||
return (show_label_values && show_label_values.includes(value)) ? value : "";
|
||||
}, [show_label_values]);
|
||||
|
||||
const marks = useMemo(() => {
|
||||
return createMarks(min, max, step, labelFormatter);
|
||||
|
||||
@@ -70,7 +70,7 @@ const UiScalingContainer = () => {
|
||||
min: 40,
|
||||
max: 200,
|
||||
step: 10,
|
||||
hidden_label_values: [50, 70, 90, 110, 130, 150, 170, 190],
|
||||
show_label_values: [40, 60, 80, 100, 120, 140, 160, 180, 200],
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -104,7 +104,7 @@ export const MessageLogUiScalingContainer = () => {
|
||||
min: 40,
|
||||
max: 200,
|
||||
step: 10,
|
||||
hidden_label_values: [50, 70, 90, 110, 130, 150, 170, 190],
|
||||
show_label_values: [40, 60, 80, 100, 120, 140, 160, 180, 200],
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user