refactor Components props extracting

This commit is contained in:
Horcrux
2017-02-03 19:43:25 +08:00
parent 9b62d500ce
commit 5bd9b40c17
35 changed files with 208 additions and 276 deletions

View File

@@ -1,4 +1,3 @@
const merge = Object.assign;
function arrayDiffer(a, b) {
/*eslint eqeqeq:0*/
@@ -70,25 +69,31 @@ const FillAndStrokeAttributes = {
strokeMiterlimit: true
};
const RenderableAttributes = merge({}, NodeAttributes, FillAndStrokeAttributes);
const RenderableAttributes = {
...NodeAttributes,
...FillAndStrokeAttributes
};
const GroupAttributes = RenderableAttributes;
const UseAttributes = merge({
const UseAttributes = {
href: true,
width: true,
height: true
}, RenderableAttributes);
height: true,
...RenderableAttributes
};
const SymbolAttributes = merge({
name: true
}, ViewBoxAttributes);
const SymbolAttributes = {
name: true,
...ViewBoxAttributes
};
const PathAttributes = merge({
d: true
}, RenderableAttributes);
const PathAttributes = {
d: true,
...RenderableAttributes
};
const TextAttributes = merge({
const TextAttributes = {
font: {
diff: fontDiffer
},
@@ -96,88 +101,99 @@ const TextAttributes = merge({
deltaX: arrayDiffer,
deltaY: arrayDiffer,
positionX: true,
positionY: true
}, RenderableAttributes);
positionY: true,
...RenderableAttributes
};
const TextPathAttributes = merge({
const TextPathAttributes = {
href: true,
startOffset: true
}, RenderableAttributes);
startOffset: true,
...RenderableAttributes
};
const TSpanAttibutes = merge({
content: true
}, TextAttributes);
const TSpanAttibutes = {
content: true,
...TextAttributes
};
const ClipPathAttributes = {
name: true
};
const GradientAttributes = merge({
const GradientAttributes = {
gradient: {
diff: arrayDiffer
},
gradientUnits: true,
gradientTransform: {
diff: arrayDiffer
}
}, ClipPathAttributes);
},
...ClipPathAttributes
};
const LinearGradientAttributes = merge({
const LinearGradientAttributes = {
x1: true,
y1: true,
x2: true,
y2: true
}, GradientAttributes);
y2: true,
...GradientAttributes
};
const RadialGradientAttributes = merge({
const RadialGradientAttributes = {
fx: true,
fy: true,
rx: true,
ry: true,
cx: true,
cy: true,
r: true
}, GradientAttributes);
r: true,
...GradientAttributes
};
const CircleAttributes = merge({
const CircleAttributes = {
cx: true,
cy: true,
r: true
}, RenderableAttributes);
r: true,
...RenderableAttributes
};
const EllipseAttributes = merge({
const EllipseAttributes = {
cx: true,
cy: true,
rx: true,
ry: true
}, RenderableAttributes);
ry: true,
...RenderableAttributes
};
const ImageAttributes = merge({
const ImageAttributes = {
x: true,
y: true,
width: true,
height: true,
src: true,
align: true,
meetOrSlice: true
}, RenderableAttributes);
meetOrSlice: true,
...RenderableAttributes
};
const LineAttributes = merge({
const LineAttributes = {
x1: true,
y1: true,
x2: true,
y2: true
}, RenderableAttributes);
y2: true,
...RenderableAttributes
};
const RectAttributes = merge({
const RectAttributes = {
x: true,
y: true,
width: true,
height: true,
rx: true,
ry: true
}, RenderableAttributes);
ry: true,
...RenderableAttributes
};
export {
PathAttributes,