var formatItemStyle = {
fontSize: '0.95em',
marginTop: '10px',
maxHeight: '220px'
}, formatItemImgStyle = {
maxWidth: '100%',
maxHeight: '100%',
display: 'block',
marginLeft: 'auto',
marginRight: 'auto',
marginTop: '5px',
}, formatHeaderStyle = {
fontWeight: 'bold',
marginBottom: '5px'
}, formatSubheaderStyle = {
marginBottom: '10px',
fontSize: '0.9em'
}, formatItemDescriptionStyle = {
color: '#444',
marginBottom: '5px',
fontSize: '1.2em',
}, formatItemMetadataStyle = {
color: '#444',
marginBottom: '5px',
fontSize: '0.9em',
}, formatItemCostStyle = {
float: 'right'
};
var FormatItem = React.createClass({
propTypes: {
claimInfo: React.PropTypes.object,
amount: React.PropTypes.number,
name: React.PropTypes.string,
},
render: function() {
var name = this.props.name;
var claimInfo = this.props.claimInfo;
var thumbnail = claimInfo.thumbnail;
var title = claimInfo.title;
var description = claimInfo.description;
var author = claimInfo.author;
var language = claimInfo.language;
var license = claimInfo.license;
var fileContentType = claimInfo['content-type'];
var amount = this.props.amount || 0.0;
return (
Address: {name}
Content-Type: {fileContentType}
{description}
Author: {author}
Language: {language}
License: {license}
);
}
});
var FormatsSection = React.createClass({
propTypes: {
claimInfo: React.PropTypes.object,
amount: React.PropTypes.number,
name: React.PropTypes.string,
},
render: function() {
var name = this.props.name;
var format = this.props.claimInfo;
var title = format.title;
if(format == null)
{
return (
Sorry, no results found for "{name}".
);
}
return (
{title}
{/* In future, anticipate multiple formats, just a guess at what it could look like
// var formats = this.props.claimInfo.formats
// return ({formats.map(function(format,i){ */}
{/* })}); */}
);
}
});
var DetailPage = React.createClass({
propTypes: {
name: React.PropTypes.string,
},
getInitialState: function() {
return {
claimInfo: null,
amount: null,
searching: true,
};
},
componentWillMount: function() {
lbry.getClaimInfo(this.props.name, (claimInfo) => {
this.setState({
claimInfo: claimInfo.value,
searching: false,
});
});
lbry.getCostEstimate(this.props.name, (amount) => {
this.setState({
amount: amount,
});
});
},
render: function() {
if (this.state.claimInfo == null && this.state.searching) {
// Still waiting for metadata
return null;
}
var name = this.props.name;
var claimInfo = this.state.claimInfo;
var amount = this.state.amount;
return (
);
}
});