-
-
Notifications
You must be signed in to change notification settings - Fork 779
/
Copy pathHandle.jsx
47 lines (44 loc) · 1.05 KB
/
Handle.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from 'react';
import PropTypes from 'prop-types';
export default class Handle extends React.Component {
render() {
const {
className, vertical, offset, style, disabled, min, max, value, ...restProps,
} = this.props;
const postionStyle = vertical ? { bottom: `${offset}%` } : { left: `${offset}%` };
const elStyle = {
...style,
...postionStyle,
};
let ariaProps = {};
if (value !== undefined) {
ariaProps = {
...ariaProps,
'aria-valuemin': min,
'aria-valuemax': max,
'aria-valuenow': value,
'aria-disabled': !!disabled,
};
}
return (
<div
role="slider"
tabIndex="0"
{...ariaProps}
{...restProps}
className={className}
style={elStyle}
/>
);
}
}
Handle.propTypes = {
className: PropTypes.string,
vertical: PropTypes.bool,
offset: PropTypes.number,
style: PropTypes.object,
disabled: PropTypes.bool,
min: PropTypes.number,
max: PropTypes.number,
value: PropTypes.number,
};