-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormRange.jsx
31 lines (30 loc) · 1009 Bytes
/
FormRange.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { formatPrice } from '../utils';
import { useState } from 'react';
const FormRange = ({ label, name, size, price }) => {
const step = 1000;
const maxPrice = 100000;
const [selectedPrice, setSelectedPrice] = useState(price || maxPrice);
return (
<div className='form-control'>
<label htmlFor={name} className='label cursor-pointer'>
<span className='label-text capitalize'>{label}</span>
<span>{formatPrice(selectedPrice)}</span>
</label>
<input
type='range'
name={name}
min={0}
max={maxPrice}
value={selectedPrice}
onChange={(e) => setSelectedPrice(e.target.value)}
className={`range range-primary ${size}`}
step={step}
/>
<div className='w-full flex justify-between text-xs px-2 mt-2'>
<span className='font-bold text-md'>0</span>
<span className='font-bold text-md'>Max : {formatPrice(maxPrice)}</span>
</div>
</div>
);
};
export default FormRange;