-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSliderTracks.tsx
42 lines (38 loc) · 1.1 KB
/
SliderTracks.tsx
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
import { RangeColor } from '../types'
/** Component props. */
interface SliderTracksProps {
/** Labels component. */
children: JSX.Element | undefined;
/** Left offset. */
left?: string;
/** Track width. */
width: string;
/** Track color. */
color: RangeColor;
/** Disabled prop. */
disabled: boolean;
/** Inverted prop. */
inverted: boolean;
}
/**
* Render Slider track with custom color, left offset and width.
*
* @param props - Component props.
* @returns Component.
*/
const SliderTracks = (props: SliderTracksProps) => {
const disabledClass = props.disabled ? 'disabled' : ''
const invertedClass = props.inverted ? 'inverted' : ''
const colorClass = props.inverted ? `${invertedClass}-${props.color}` : props.color
return (
<div className={`slider ${invertedClass}`}>
<div className={`slider__track ${disabledClass} ${invertedClass}`} />
{props.children}
<div
style={{ left: props.left, width: props.width }}
className={`color_track slider__range ${disabledClass} ${colorClass}`}
/>
</div>
)
}
export { SliderTracks }