Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Styled Components and other css-in-js #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Sparklines.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Sparklines extends PureComponent {
style: PropTypes.object,
min: PropTypes.number,
max: PropTypes.number,
onMouseMove: PropTypes.func
onMouseMove: PropTypes.func,
className: PropTypes.string
};

static defaultProps = {
Expand All @@ -32,15 +33,16 @@ class Sparklines extends PureComponent {
height: 60,
//Scale the graphic content of the given element non-uniformly if necessary such that the element's bounding box exactly matches the viewport rectangle.
preserveAspectRatio: 'none', //https://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
margin: 2
margin: 2,
className: ''
};

constructor (props) {
super(props);
}

render() {
const { data, limit, width, height, svgWidth, svgHeight, preserveAspectRatio, margin, style, max, min} = this.props;
const { data, limit, width, height, svgWidth, svgHeight, preserveAspectRatio, margin, style, max, min, className} = this.props;

if (data.length === 0) return null;

Expand All @@ -51,7 +53,7 @@ class Sparklines extends PureComponent {
if (svgHeight > 0) svgOpts.height = svgHeight;

return (
<svg {...svgOpts}>
<svg className={className} {...svgOpts}>
{
React.Children.map(this.props.children, function(child) {
return React.cloneElement(child, { data, points, width, height, margin });
Expand Down