mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
refactor(app): move react components to react codebase [EE-3179] (#6971)
This commit is contained in:
parent
212400c283
commit
18252ab854
346 changed files with 642 additions and 644 deletions
42
app/react/components/form-components/Slider/Slider.tsx
Normal file
42
app/react/components/form-components/Slider/Slider.tsx
Normal file
|
@ -0,0 +1,42 @@
|
|||
import RcSlider from 'rc-slider';
|
||||
|
||||
import styles from './Slider.module.css';
|
||||
import 'rc-slider/assets/index.css';
|
||||
|
||||
export interface Props {
|
||||
min: number;
|
||||
max: number;
|
||||
step: number;
|
||||
value: number;
|
||||
onChange: (value: number) => void;
|
||||
}
|
||||
|
||||
export function Slider({ min, max, step, value, onChange }: Props) {
|
||||
const SliderWithTooltip = RcSlider.createSliderWithTooltip(RcSlider);
|
||||
const marks = {
|
||||
[min]: translateMinValue(min),
|
||||
[max]: max.toString(),
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<SliderWithTooltip
|
||||
tipFormatter={translateMinValue}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
marks={marks}
|
||||
defaultValue={value}
|
||||
onAfterChange={onChange}
|
||||
className={styles.slider}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function translateMinValue(value: number) {
|
||||
if (value === 0) {
|
||||
return 'unlimited';
|
||||
}
|
||||
return value.toString();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue