From ed080d850bd66cc1d27a6c1f345cd6017939d014 Mon Sep 17 00:00:00 2001 From: blazh Date: Thu, 12 Sep 2024 14:15:43 +0200 Subject: [PATCH] enhancement: improve voting slider on mobile --- .../components/UI/Slider/index.tsx | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/packages/react-app-revamp/components/UI/Slider/index.tsx b/packages/react-app-revamp/components/UI/Slider/index.tsx index 5e1e311cf..50bf8943f 100644 --- a/packages/react-app-revamp/components/UI/Slider/index.tsx +++ b/packages/react-app-revamp/components/UI/Slider/index.tsx @@ -1,6 +1,7 @@ import Slider from "rc-slider"; import "rc-slider/assets/index.css"; import { FC, useEffect, useState } from "react"; +import { useMediaQuery } from "react-responsive"; import { Tooltip } from "react-tooltip"; interface StepSliderProps { @@ -23,6 +24,7 @@ const StepSlider: FC = ({ onKeyDown, }) => { const [value, setValue] = useState(defaultValue); + const isMobile = useMediaQuery({ query: "(max-width: 768px)" }); useEffect(() => { setValue(val); @@ -33,44 +35,44 @@ const StepSlider: FC = ({ onChange?.(value); }; - const trackStyle = { - backgroundColor: "#BB65FF", - height: 8, - }; - - const handleStyle = { - borderColor: "#D9D9D9", - height: 16, - width: 16, - backgroundColor: "#D9D9D9", - opacity: "1", - }; - - const railStyle = { - backgroundColor: "#6A6A6A", - height: 8, - }; - - const dotStyle = { - borderColor: "#D9D9D9", - height: 10, - width: 10, - backgroundColor: "#D9D9D9", + const styles = { + track: { + backgroundColor: "#BB65FF", + height: 8, + }, + handle: { + borderColor: "#D9D9D9", + height: isMobile ? 32 : 16, + width: isMobile ? 32 : 16, + backgroundColor: "#D9D9D9", + opacity: 1, + cursor: "pointer", + marginTop: isMobile ? -12 : -4, + }, + rail: { + backgroundColor: "#6A6A6A", + height: 8, + }, + dot: { + borderColor: "#D9D9D9", + height: 10, + width: 10, + backgroundColor: "#D9D9D9", + }, }; return ( -
+
{ return (