Implement prop extraction for side and alignmentBaseline. Cleanup extractText, fix linting.

This commit is contained in:
Mikael Sand
2017-07-25 07:45:08 +03:00
parent 7cafe835df
commit c05c215496
6 changed files with 57 additions and 45 deletions
+1
View File
@@ -110,6 +110,7 @@ const PathAttributes = {
const TextSpecificAttributes = {
...RenderableAttributes,
alignmentBaseline: true,
lengthAdjust: true,
textLength: true,
};
+3 -8
View File
@@ -51,6 +51,7 @@ export function extractFont(props) {
fontStretch,
textAnchor,
textDecoration,
alignmentBaseline,
letterSpacing,
wordSpacing,
kerning,
@@ -73,6 +74,7 @@ export function extractFont(props) {
fontFamily,
textAnchor,
textDecoration,
alignmentBaseline,
letterSpacing,
wordSpacing,
kerning,
@@ -103,13 +105,10 @@ export default function(props, container) {
y,
dx,
dy,
method,
spacing,
} = props;
let {
rotate,
children,
startOffset
children
} = props;
const positionX = parseSVGLengthList(x);
@@ -138,7 +137,6 @@ export default function(props, container) {
}
const font = extractFont(props);
startOffset = (startOffset || 0).toString();
return {
font,
@@ -149,8 +147,5 @@ export default function(props, container) {
rotate,
deltaX,
deltaY,
method,
spacing,
startOffset,
};
}
+40 -22
View File
@@ -48,6 +48,26 @@ const strokeProps = {
strokeMiterlimit: numberProp
};
const transformProps = {
scale: numberProp,
scaleX: numberProp,
scaleY: numberProp,
rotate: numberProp,
rotation: numberProp,
translate: numberProp,
translateX: numberProp,
translateY: numberProp,
x: numberProp,
y: numberProp,
origin: numberProp,
originX: numberProp,
originY: numberProp,
skew: numberProp,
skewX: numberProp,
skewY: numberProp,
transform: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
};
const pathProps = {
...fillProps,
...strokeProps,
@@ -153,19 +173,37 @@ const lengthAdjust = PropTypes.oneOf(['spacing', 'spacingAndGlyphs']);
*/
const textLength = PropTypes.string;
/*
Name: alignment-baseline
Value: baseline | text-bottom | alphabetic | ideographic | middle | central | mathematical | text-top | bottom | center | top
Initial: baseline
Applies to: inline-level boxes, flex items, grid items, table cells
Inherited: no
Percentages: N/A
Media: visual
Computed value: as specified
Canonical order: per grammar
Animation type: discrete
https://drafts.csswg.org/css-inline/#propdef-alignment-baseline
https://svgwg.org/svg2-draft/text.html#AlignmentBaselineProperty
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/alignment-baseline
*/
const alignmentBaseline = PropTypes.oneOf(['baseline', 'text-bottom', 'alphabetic', 'ideographic', 'middle', 'central', 'mathematical', 'text-top', 'bottom', 'center', 'top']);
const textSpecificProps = {
...pathProps,
...fontProps,
alignmentBaseline,
lengthAdjust,
textLength,
}
};
// https://svgwg.org/svg2-draft/text.html#TSpanAttributes
const textProps = {
...textSpecificProps,
dx: PropTypes.string,
dy: PropTypes.string,
}
};
/*
Name
@@ -231,26 +269,6 @@ const textPathProps = {
method,
spacing,
side,
}
const transformProps = {
scale: numberProp,
scaleX: numberProp,
scaleY: numberProp,
rotate: numberProp,
rotation: numberProp,
translate: numberProp,
translateX: numberProp,
translateY: numberProp,
x: numberProp,
y: numberProp,
origin: numberProp,
originX: numberProp,
originY: numberProp,
skew: numberProp,
skewX: numberProp,
skewY: numberProp,
transform: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
};
export {