add slider

This commit is contained in:
SethBurkart123
2023-09-25 14:58:08 +10:00
parent 3745653c0d
commit d0d7fd1b11
9 changed files with 39 additions and 137 deletions
+15 -17
View File
@@ -1,21 +1,19 @@
.range-slider{
margin: 20px;
appearance: none;
outline: none;
width: 150px;
height: 3px;
border-radius: 5px;
background-color: #ccc;
/* Slider Thumb */
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 24px;
height: 24px;
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.3);
background: white;
cursor: pointer;
border-radius: 50%;
}
.range-slide::-webkit-slider-runnable-track{
background-color: #4BD663 !important;
}
.range-slider::-webkit-slider-thumb {
background: #fafafa;
appearance: none;
box-shadow: 1px 2px 26px 1px #bdbdbd;
width: 15px;
height: 15px;
.slider::-moz-range-thumb {
width: 24px;
height: 24px;
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.3);
background: white;
cursor: pointer;
border-radius: 50%;
}
+12 -17
View File
@@ -1,29 +1,24 @@
import React, { useState } from 'react';
import { useSettingsContext } from "../SettingsContext";
import "./Slider.css";
import type { Slider } from '../types/SliderProps';
const Slider: React.FC<Slider> = ({ onValueChange }) => {
const [sliderValue, setSliderValue] = useState(0);
interface SliderProps {
state: number;
onChange: (value: number) => void;
}
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(event.target.value, 10);
setSliderValue(value);
};
const handleMouseUp = () => {
onValueChange(sliderValue);
};
const Slider: React.FC<SliderProps> = ({ state, onChange }) => {
const { settingsState } = useSettingsContext();
return (
<div className="relative">
<div className="relative w-full max-w-lg py-8 mx-auto">
<input
type="range"
min="0"
max="100"
value={sliderValue}
onChange={handleInputChange}
onMouseUp={handleMouseUp}
className="absolute w-full h-1 rounded-full cursor-pointer range-slider focus:outline-none"
value={state}
onChange={(e) => onChange(Number(e.target.value))}
className="w-full h-1 rounded-full appearance-none cursor-pointer slider"
style={{ background: `${settingsState.customThemeColor}` }}
/>
</div>
);