From f19156027a4efd9d48fb2fef32b63d04938b6582 Mon Sep 17 00:00:00 2001 From: Danilo Woznica Date: Tue, 27 Nov 2018 21:14:33 +0000 Subject: [PATCH] feat(Wrap): Destruct options in component (#113) That allows removing the viewBox and other things Related #107 --- src/Wrap.js | 65 +++++++++++++++++++++++++++++------------------- stories/index.js | 5 ++++ tests/index.js | 4 +-- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/Wrap.js b/src/Wrap.js index 81068d0..3753408 100644 --- a/src/Wrap.js +++ b/src/Wrap.js @@ -8,45 +8,62 @@ export type WrapProps = { children?: React.ChildrenArray<*> } & ContentLoaderProps -const Wrap = (props: WrapProps): React.Element<*> => { - const idClip = props.uniquekey ? `${props.uniquekey}-idClip` : uid() - const idGradient = props.uniquekey ? `${props.uniquekey}-idGradient` : uid() +export default ({ + animate, + children, + className, + height, + preserveAspectRatio, + primaryColor, + primaryOpacity, + rtl, + secondaryColor, + secondaryOpacity, + speed, + style, + uniquekey, + width, + ...props +}: WrapProps): React.Element<*> => { + const idClip = uniquekey ? `${uniquekey}-idClip` : uid() + const idGradient = uniquekey ? `${uniquekey}-idGradient` : uid() const defautlAnimation = ["-3; 1", "-2; 2", "-1; 3"] const rtlAnimation = ["1; -3", "2; -2", "3; -1"] - const animationValues = props.rtl ? rtlAnimation : defautlAnimation + const animationValues = rtl ? rtlAnimation : defautlAnimation return ( - {props.children} + {children} - {props.animate && ( + {animate && ( )} @@ -54,14 +71,14 @@ const Wrap = (props: WrapProps): React.Element<*> => { - {props.animate && ( + {animate && ( )} @@ -69,14 +86,14 @@ const Wrap = (props: WrapProps): React.Element<*> => { - {props.animate && ( + {animate && ( )} @@ -86,5 +103,3 @@ const Wrap = (props: WrapProps): React.Element<*> => { ) } - -export default Wrap diff --git a/stories/index.js b/stories/index.js index e6d09b3..9fe81c7 100644 --- a/stories/index.js +++ b/stories/index.js @@ -111,3 +111,8 @@ storiesOf("ContentLoader", module) )) + .add("remove viewBox", () => ( + + + + )) diff --git a/tests/index.js b/tests/index.js index 74794d0..2e8bc63 100755 --- a/tests/index.js +++ b/tests/index.js @@ -122,11 +122,11 @@ describe(":", () => { describe("inside ", () => { it("exists", () => { - expect(wrapper.find("Wrap")).to.have.length(1) + expect(wrapper.find("svg")).to.have.length(1) }) it("has no `animate` element", () => { - expect(wrapper.find("animate")).to.be.empty + expect(wrapper.find("animate")).to.have.length(0) }) }) })