mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
fix(slider): use and update react slider EE-4522 (#7987)
This commit is contained in:
parent
f94147b07b
commit
9f3d5185b0
10 changed files with 154 additions and 43 deletions
|
@ -9,13 +9,25 @@ export interface Props {
|
|||
step: number;
|
||||
value: number;
|
||||
onChange: (value: number) => void;
|
||||
// true if you want to always show the tooltip
|
||||
dataCy: string;
|
||||
visibleTooltip?: boolean;
|
||||
}
|
||||
|
||||
export function Slider({ min, max, step, value, onChange }: Props) {
|
||||
export function Slider({
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
value,
|
||||
onChange,
|
||||
dataCy,
|
||||
visibleTooltip: visible,
|
||||
}: Props) {
|
||||
const SliderWithTooltip = RcSlider.createSliderWithTooltip(RcSlider);
|
||||
// if the tooltip is always visible, hide the marks when tooltip value gets close to the edges
|
||||
const marks = {
|
||||
[min]: translateMinValue(min),
|
||||
[max]: max.toString(),
|
||||
[min]: visible && value / max < 0.1 ? '' : translateMinValue(min),
|
||||
[max]: visible && value / max > 0.9 ? '' : max.toString(),
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -29,6 +41,11 @@ export function Slider({ min, max, step, value, onChange }: Props) {
|
|||
defaultValue={value}
|
||||
onAfterChange={onChange}
|
||||
className={styles.slider}
|
||||
tipProps={{ visible }}
|
||||
railStyle={{ height: 8 }}
|
||||
trackStyle={{ height: 8 }}
|
||||
dotStyle={{ visibility: 'hidden' }}
|
||||
data-cy={dataCy}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue