From 22a75415438c64225cfcb89d4c538324ac2917b6 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Tue, 1 Jun 2021 22:04:05 +0800 Subject: Update slider style --- frontend/src/components/inputs/Slider.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/inputs/Slider.tsx b/frontend/src/components/inputs/Slider.tsx index 4901b1143..e8a8c3c35 100644 --- a/frontend/src/components/inputs/Slider.tsx +++ b/frontend/src/components/inputs/Slider.tsx @@ -1,6 +1,6 @@ import RcSlider from "rc-slider"; import "rc-slider/assets/index.css"; -import React, { FunctionComponent, useMemo } from "react"; +import React, { FunctionComponent, useMemo, useState } from "react"; import "./slider.scss"; type TooltipsOptions = boolean | "Always"; @@ -9,6 +9,7 @@ export interface SliderProps { tooltips?: TooltipsOptions; min?: number; max?: number; + step?: number; start?: number; defaultValue?: number; onAfterChange?: (value: number) => void; @@ -18,21 +19,31 @@ export interface SliderProps { export const Slider: FunctionComponent = ({ min, max, + step, tooltips, defaultValue, onChange, onAfterChange, }) => { + max = max ?? 100; + min = min ?? 0; + step = step ?? 1; + + const [curr, setValue] = useState(defaultValue); + return (
- {min ?? 0} + {`${min} / ${curr}`} { + setValue(v); + onChange && onChange(v); + }} onAfterChange={onAfterChange} handle={(props) => (
= ({
)} >
- {max ?? 100} + {max}
); }; -- cgit v1.2.3