Skip to content

Commit

Permalink
Label slider unit (#1987)
Browse files Browse the repository at this point in the history
* New design for sliders with gradients

* Combine unit with label for sliders
  • Loading branch information
RunDevelopment authored Jul 25, 2023
1 parent 99aabc2 commit 8d683d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/renderer/components/inputs/SliderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,16 @@ export const SliderInput = memo(

const scale = useMemo(() => parseScale(input), [input]);
const sliderStyle = useMemo((): SliderStyle => {
let { label } = input;
if (input.unit) label += ` (${input.unit})`;

if (input.gradient) {
return { type: 'label', label: input.label, gradient: input.gradient };
return { type: 'label', label, gradient: input.gradient };
}
if (!filled) {
return { type: 'no-fill' };
}
return { type: 'label', label: input.label };
return { type: 'label', label };
}, [input, filled]);

const slider = (
Expand Down Expand Up @@ -222,7 +225,7 @@ export const SliderInput = memo(
precision={precision}
setInput={setValue}
setInputString={onNumberInputChange}
unit={unit}
unit={sliderStyle.type === 'label' ? undefined : unit}
onContextMenu={menu.onContextMenu}
/>
</HStack>
Expand Down

0 comments on commit 8d683d2

Please sign in to comment.