mirror of
https://github.com/status-im/react-native.git
synced 2025-02-13 18:06:37 +00:00
[Website] Platform-specific props
We are annotating platform-specific props with a special @platform tag in the docblocks. This pull request adds a little [ios] tag before the name and sorts the props such as generic ones are before platform-specific ones.
This commit is contained in:
parent
3309f6da80
commit
6e9ceaa348
@ -71,6 +71,9 @@ var ComponentDoc = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div className="prop" key={name}>
|
<div className="prop" key={name}>
|
||||||
<Header level={4} className="propTitle" toSlug={name}>
|
<Header level={4} className="propTitle" toSlug={name}>
|
||||||
|
{prop.platforms && prop.platforms.map(platform =>
|
||||||
|
<span className="platform">{platform}</span>
|
||||||
|
)}
|
||||||
{name}
|
{name}
|
||||||
{' '}
|
{' '}
|
||||||
{prop.type && <span className="propType">
|
{prop.type && <span className="propType">
|
||||||
@ -119,7 +122,7 @@ var ComponentDoc = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{Object.keys(style.props).sort().map((name) =>
|
{Object.keys(style.props).map((name) =>
|
||||||
<div className="prop" key={name}>
|
<div className="prop" key={name}>
|
||||||
<h6 className="propTitle">
|
<h6 className="propTitle">
|
||||||
{name}
|
{name}
|
||||||
@ -140,15 +143,42 @@ var ComponentDoc = React.createClass({
|
|||||||
{(composes || []).map((name) =>
|
{(composes || []).map((name) =>
|
||||||
this.renderCompose(name)
|
this.renderCompose(name)
|
||||||
)}
|
)}
|
||||||
{Object.keys(props).sort().map((name) =>
|
{Object.keys(props)
|
||||||
|
.sort((a, b) => {
|
||||||
|
a = props[a];
|
||||||
|
b = props[b];
|
||||||
|
|
||||||
|
if (a.platforms && !b.platforms) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (b.platforms && !a.platforms) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return a.name < b.name;
|
||||||
|
})
|
||||||
|
.map((name) =>
|
||||||
this.renderProp(name, props[name])
|
this.renderProp(name, props[name])
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
extractPlatformFromProps: function(props) {
|
||||||
|
for (var key in props) {
|
||||||
|
var prop = props[key];
|
||||||
|
var description = prop.description || '';
|
||||||
|
var platforms = description.match(/\@platform (.+)/);
|
||||||
|
platforms = platforms && platforms[1].replace(/ /g, '').split(',');
|
||||||
|
description = description.replace(/\@platform (.+)/, '');
|
||||||
|
|
||||||
|
prop.description = description;
|
||||||
|
prop.platforms = platforms;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var content = this.props.content;
|
var content = this.props.content;
|
||||||
|
this.extractPlatformFromProps(content.props);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Marked>
|
<Marked>
|
||||||
|
@ -967,6 +967,15 @@ div[data-twttr-id] iframe {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.platform {
|
||||||
|
background-color: hsl(198, 100%, 87%);
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
padding: 0 5px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
.edit-github {
|
.edit-github {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user