mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-25 03:53:31 +00:00
Improve numberProp and numberArrayProp PropTypes usage.
Implement "normal" relative unit in java.
This commit is contained in:
@@ -95,7 +95,7 @@ class PropHelper {
|
||||
length = length.trim();
|
||||
int stringLength = length.length();
|
||||
int percentIndex = stringLength - 1;
|
||||
if (stringLength == 0) {
|
||||
if (stringLength == 0 || length.equals("normal")) {
|
||||
return offset;
|
||||
} else if (length.codePointAt(percentIndex) == '%') {
|
||||
return Double.valueOf(length.substring(0, percentIndex)) / 100 * relative + offset;
|
||||
|
||||
+12
-11
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
||||
import {PanResponder} from 'react-native';
|
||||
|
||||
const numberProp = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
const numberArrayProp = PropTypes.oneOfType([PropTypes.arrayOf(numberProp), numberProp]);
|
||||
|
||||
const touchableProps = {
|
||||
disabled: PropTypes.bool,
|
||||
@@ -41,7 +42,7 @@ const strokeProps = {
|
||||
stroke: PropTypes.string,
|
||||
strokeWidth: numberProp,
|
||||
strokeOpacity: numberProp,
|
||||
strokeDasharray: PropTypes.oneOfType([PropTypes.arrayOf(numberProp), PropTypes.string]),
|
||||
strokeDasharray: numberArrayProp,
|
||||
strokeDashoffset: numberProp,
|
||||
strokeLinecap: PropTypes.oneOf(['butt', 'square', 'round']),
|
||||
strokeLinejoin: PropTypes.oneOf(['miter', 'bevel', 'round']),
|
||||
@@ -96,7 +97,7 @@ const fontStretch = PropTypes.oneOf(['normal', 'wider', 'narrower', 'ultra-conde
|
||||
|
||||
// <absolute-size> | <relative-size> | <length> | <percentage> | inherit
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-size
|
||||
const fontSize = PropTypes.string;
|
||||
const fontSize = numberProp;
|
||||
|
||||
// [[<family-name> | <generic-family>],]* [<family-name> | <generic-family>] | inherit
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-family
|
||||
@@ -132,15 +133,15 @@ const textDecoration = PropTypes.oneOf(['none', 'underline', 'overline', 'line-t
|
||||
|
||||
// normal | <length> | inherit
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/letter-spacing
|
||||
const letterSpacing = PropTypes.string;
|
||||
const letterSpacing = numberProp;
|
||||
|
||||
// normal | <length> | inherit
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/word-spacing
|
||||
const wordSpacing = PropTypes.string;
|
||||
const wordSpacing = numberProp;
|
||||
|
||||
// auto | <length> | inherit
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/kerning
|
||||
const kerning = PropTypes.string;
|
||||
const kerning = numberProp;
|
||||
|
||||
/*
|
||||
Name: font-variant-ligatures
|
||||
@@ -195,7 +196,7 @@ const lengthAdjust = PropTypes.oneOf(['spacing', 'spacingAndGlyphs']);
|
||||
https://svgwg.org/svg2-draft/text.html#TextElementTextLengthAttribute
|
||||
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/textLength
|
||||
*/
|
||||
const textLength = PropTypes.string;
|
||||
const textLength = numberProp;
|
||||
|
||||
/*
|
||||
2.2. Transverse Box Alignment: the vertical-align property
|
||||
@@ -218,7 +219,7 @@ const textLength = PropTypes.string;
|
||||
https://www.w3.org/TR/css-inline-3/#transverse-alignment
|
||||
https://drafts.csswg.org/css-inline/#propdef-vertical-align
|
||||
*/
|
||||
const verticalAlign = PropTypes.string;
|
||||
const verticalAlign = numberProp;
|
||||
|
||||
/*
|
||||
Name: alignment-baseline
|
||||
@@ -258,7 +259,7 @@ const alignmentBaseline = PropTypes.oneOf(['baseline', 'text-bottom', 'alphabeti
|
||||
|
||||
https://www.w3.org/TR/css-inline-3/#propdef-baseline-shift
|
||||
*/
|
||||
const baselineShift = PropTypes.oneOfType([PropTypes.oneOf(['sub', 'super', 'baseline']), PropTypes.arrayOf(numberProp), PropTypes.string]);
|
||||
const baselineShift = PropTypes.oneOfType([PropTypes.oneOf(['sub', 'super', 'baseline']), PropTypes.arrayOf(numberProp), numberProp]);
|
||||
|
||||
/*
|
||||
6.12. Low-level font feature settings control: the font-feature-settings property
|
||||
@@ -375,8 +376,8 @@ const textSpecificProps = {
|
||||
// https://svgwg.org/svg2-draft/text.html#TSpanAttributes
|
||||
const textProps = {
|
||||
...textSpecificProps,
|
||||
dx: PropTypes.string,
|
||||
dy: PropTypes.string,
|
||||
dx: numberArrayProp,
|
||||
dy: numberArrayProp,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -404,7 +405,7 @@ const side = PropTypes.oneOf(['left', 'right']);
|
||||
https://svgwg.org/svg2-draft/text.html#TextPathElementStartOffsetAttribute
|
||||
https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath
|
||||
*/
|
||||
const startOffset = PropTypes.string;
|
||||
const startOffset = numberProp;
|
||||
|
||||
/*
|
||||
Name
|
||||
|
||||
Reference in New Issue
Block a user