victory-core
Version:
46 lines • 1.3 kB
JavaScript
import React from "react";
import defaults from "lodash/defaults";
import * as Helpers from "../victory-util/helpers";
import { Rect } from "./rect";
import { Circle } from "./circle";
const evaluateProps = props => {
/**
* Potential evaluated prop is:
* `id`
*/
const id = Helpers.evaluateProp(props.id, props);
return Object.assign({}, props, {
id
});
};
const defaultProps = {
circleComponent: /*#__PURE__*/React.createElement(Circle, null),
rectComponent: /*#__PURE__*/React.createElement(Rect, null),
role: "presentation",
shapeRendering: "auto"
};
export const Background = initialProps => {
const props = evaluateProps(defaults({}, initialProps, defaultProps));
return props.polar ? /*#__PURE__*/React.cloneElement(props.circleComponent, {
...props.events,
style: props.style,
role: props.role,
shapeRendering: props.shapeRendering,
cx: props.x,
cy: props.y,
r: props.height,
className: props.className
}) : /*#__PURE__*/React.cloneElement(props.rectComponent, {
...props.events,
style: props.style,
role: props.role,
shapeRendering: props.shapeRendering,
x: props.x,
y: props.y,
rx: props.rx,
ry: props.ry,
width: props.width,
height: props.height,
className: props.className
});
};