-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
38 lines (32 loc) · 969 Bytes
/
Copy pathindex.jsx
File metadata and controls
38 lines (32 loc) · 969 Bytes
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
import React from 'react'
import PropTypes from 'prop-types'
// eslint-disable-next-line
function getColorByRule(colorMap, rule) {
}
const ColorGradient = ({
colorMap,
deg,
rule, // ['max', 'min'], ['max', 'mid', 'min']
children
}) => {
const isEmptyChildren = children => React.Children.count(children) === 0;
const renderChildren = ({
children,
render,
props = {}
}) => {
if (render) return render(props);
if (typeof children === "function") return children(props);
if (children && !isEmptyChildren(children)) return React.Children.only(children);
return null;
}
// const backgroundColor = getColorByRule(colorMap, rule)
return (
<div>{renderChildren(children)}</div>
)
}
ColorGradient.propTypes = {
colorMap: PropTypes.arrayOf(PropTypes.object.isRequired).isRequired,
rule: PropTypes.array.isRequired, // ['max', 'min', deg?: number], ['max', 'mid', 'min', deg?: number]
}
export default ColorGradient