Clarify transform for ViewStyleProps, generate union docs properly

This commit is contained in:
Brent Vatne 2015-05-06 11:05:47 -07:00
parent e5b9eb5900
commit f878be84e6
2 changed files with 22 additions and 0 deletions

View File

@ -36,6 +36,23 @@ var ViewStylePropTypes = {
),
shadowOpacity: ReactPropTypes.number,
shadowRadius: ReactPropTypes.number,
transform: ReactPropTypes.arrayOf(
ReactPropTypes.oneOfType([
ReactPropTypes.shape({rotation: ReactPropTypes.number}),
ReactPropTypes.shape({scaleX: ReactPropTypes.number}),
ReactPropTypes.shape({scaleY: ReactPropTypes.number}),
ReactPropTypes.shape({translateX: ReactPropTypes.number}),
ReactPropTypes.shape({translateY: ReactPropTypes.number})
])
),
transformMatrix: ReactPropTypes.arrayOf(ReactPropTypes.number),
// DEPRECATED
rotation: ReactPropTypes.number,
scaleX: ReactPropTypes.number,
scaleY: ReactPropTypes.number,
translateX: ReactPropTypes.number,
translateY: ReactPropTypes.number,
};
module.exports = ViewStylePropTypes;

View File

@ -20,6 +20,7 @@ var slugify = require('slugify');
var styleReferencePattern = /^[^.]+\.propTypes\.style$/;
var ComponentDoc = React.createClass({
renderType: function(type) {
if (type.name === 'enum') {
@ -33,6 +34,10 @@ var ComponentDoc = React.createClass({
return '{' + Object.keys(type.value).map((key => key + ': ' + this.renderType(type.value[key]))).join(', ') + '}';
}
if (type.name == 'union') {
return type.value.map(this.renderType).join(', ');
}
if (type.name === 'arrayOf') {
return '[' + this.renderType(type.value) + ']';
}