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

Bug/incorrect transform #1093

Merged
merged 5 commits into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion demo/components/victory-label-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class App extends React.Component {

<circle cx="0" cy="0" r="2" fill="red"/>
<VictoryLabel
transform="translate(50)"
x={0} y={0}
text={"Victory is awesome.\nThis is default anchoring.\nCapisce?"}
/>
Expand Down Expand Up @@ -104,7 +105,7 @@ export default class App extends React.Component {
<VictoryLabel x={0} y={1800} textAnchor="start" verticalAnchor="start"
text={["Use", "dx", "attribute", "to", "shift", "labels", "relative to one another."]}
inline
dx={"10"}
dx={10}
/>

{/**
Expand Down
7 changes: 3 additions & 4 deletions packages/victory-core/src/victory-util/style.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Given an object with CSS/SVG transform definitions, return the string value
* for use with the `transform` CSS property or SVG attribute. Note that we
Expand All @@ -12,9 +11,9 @@ const toTransformString = function (obj, ...more) {
if (more.length > 0) {
return more.reduce((memo, currentObj) => {
return [memo, toTransformString(currentObj)].join(" ");
}, toTransformString(obj));
}, toTransformString(obj)).trim();
} else {
if (!obj || typeof obj === "string") {
if (obj === undefined || obj === null || typeof obj === "string") {
return obj;
}
const transforms = [];
Expand All @@ -24,7 +23,7 @@ const toTransformString = function (obj, ...more) {
transforms.push(`${key}(${value})`);
}
}
return transforms.join(" ");
return transforms.join(" ").trim();
}
};

Expand Down
4 changes: 2 additions & 2 deletions test/client/spec/victory-core/victory-util/style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("toTransformString", () => {

it("returns at least the subsequent transforms if the first is undefined", () => {
expect(Style.toTransformString(
null, { skewY: [65] }
)).to.contain("skewY(65)");
undefined, { skewY: [65] }
)).to.equal("skewY(65)");
});
});