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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import {
Text,
Box,
Slider,
SliderFilledTrack,
SliderThumb,
SliderTrack,
Tooltip,
} from '@chakra-ui/react'
import React, { useContext } from 'react'
import { ThemeContext } from '../../util/themecontext'
import { InfoTooltip } from './InfoTooltip'
export interface SliderWithInfoProps {
min?: number
max?: number
step?: number
value: number
onChange: (arg0: number) => void
label: string
infoText?: string
}
export const SliderWithInfo = ({
min = 0,
max = 10,
step = 0.1,
value = 1,
...rest
}: SliderWithInfoProps) => {
const { onChange, label, infoText } = rest
const { highlightColor } = useContext(ThemeContext)
return (
<Box key={label} pt={1} pb={2}>
<Box display="flex" alignItems="flex-end" mb={2}>
<Text>{label}</Text>
{infoText && <InfoTooltip infoText={infoText} />}
</Box>
<Slider value={value} onChange={onChange} min={min} max={max} step={step}>
<SliderTrack>
<SliderFilledTrack />
</SliderTrack>
<Tooltip bg={highlightColor} label={value.toFixed(1)}>
<SliderThumb bg="white" />
</Tooltip>
</Slider>
</Box>
)
}
|