Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Support for a wickStrokeWidth style prop #330

Merged
merged 16 commits into from
Jan 29, 2018
Prev Previous commit
Next Next commit
lint success!
  • Loading branch information
Kylie Stewart committed Jan 23, 2018
commit 923398f5501c691614cf1949ad1e75806a5ca7bc
14 changes: 7 additions & 7 deletions src/victory-primitives/candle.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export default class Candle extends React.Component {
const role = props.role || "presentation";
const wickStyle = assign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be refactored to use defaults rather than assign with a conditional

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better written as:

const wickStyle = defaults({}, this.style, { strokeWidth: widthStrokeWidth })

the defaults method doesn't overwrite values with undefined

{}, this.style, { strokeWidth: props.style.wickStrokeWidth || props.style.strokeWidth });
return assign({
x1: x, x2: x, y1: wickType === "low" ? lowWick : y1, y2: wickType === "high" ? highWick : y2,
style: wickStyle, role, shapeRendering, className
return assign({
x1: x, x2: x, y1: wickType === "low" ? lowWick : y1, y2: wickType === "high" ? highWick : y2,
style: wickStyle, role, shapeRendering, className
}, events);
}

Expand All @@ -100,10 +100,10 @@ export default class Candle extends React.Component {
const highWickProps = this.getWickProps(this.props, "high");
const lowWickProps = this.getWickProps(this.props, "low");
return React.cloneElement(
this.props.groupComponent,
{},
this.renderWick(highWickProps),
this.renderWick(lowWickProps),
this.props.groupComponent,
{},
this.renderWick(highWickProps),
this.renderWick(lowWickProps),
this.renderCandle(candleProps)
);
}
Expand Down