mars-v2-frontend/components/Slider.tsx
Gustavo Mauricio 55d0910d10
MP-1566: Deposit funds modal (#33)
* feat: deposit account modal

* style: button default colors to match wireframes

* react-query-devtools package added

* slider moved to separate component
2022-10-25 11:31:36 +01:00

40 lines
1.3 KiB
TypeScript

import React from 'react'
import * as RadixSlider from '@radix-ui/react-slider'
type Props = {
className?: string
value: number
onChange: (value: number[]) => void
onMaxClick: () => void
}
const Slider = ({ className, value, onChange, onMaxClick }: Props) => {
return (
<div className={`relative flex flex-1 items-center ${className || ''}`}>
<RadixSlider.Root
className="relative flex h-[20px] w-full cursor-pointer touch-none select-none items-center"
value={[value]}
min={0}
max={100}
step={1}
onValueChange={(value) => onChange(value)}
>
<RadixSlider.Track className="relative h-[6px] grow rounded-full bg-gray-400">
<RadixSlider.Range className="absolute h-[100%] rounded-full bg-blue-600" />
</RadixSlider.Track>
<RadixSlider.Thumb className="flex h-[20px] w-[20px] items-center justify-center rounded-full bg-white !outline-none">
<div className="relative top-5 text-xs">{value.toFixed(0)}%</div>
</RadixSlider.Thumb>
</RadixSlider.Root>
<button
className="ml-4 rounded-md bg-blue-600 py-1 px-2 text-xs font-semibold text-white"
onClick={onMaxClick}
>
MAX
</button>
</div>
)
}
export default Slider