mirror of
https://github.com/ascribe/onion.git
synced 2024-06-30 21:52:08 +02:00
77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
import React from 'react';
|
||
|
import Router from 'react-router';
|
||
|
|
||
|
import AccordionListItem from './accordion_list_item';
|
||
|
|
||
|
import { getLangText } from '../../utils/lang_utils';
|
||
|
|
||
|
let Link = Router.Link;
|
||
|
|
||
|
|
||
|
let AccordionListItemPiece = React.createClass({
|
||
|
propTypes: {
|
||
|
className: React.PropTypes.string,
|
||
|
piece: React.PropTypes.object,
|
||
|
children: React.PropTypes.oneOfType([
|
||
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||
|
React.PropTypes.element
|
||
|
]),
|
||
|
subsubheading: React.PropTypes.object,
|
||
|
buttons: React.PropTypes.object,
|
||
|
badge: React.PropTypes.object
|
||
|
},
|
||
|
|
||
|
mixins: [Router.Navigation],
|
||
|
|
||
|
getLinkData(){
|
||
|
let linkData;
|
||
|
|
||
|
if (this.props.piece.num_editions < 1 || !this.props.piece.first_edition) {
|
||
|
linkData = {
|
||
|
to: 'piece',
|
||
|
params: {
|
||
|
pieceId: this.props.piece.id
|
||
|
}
|
||
|
};
|
||
|
} else {
|
||
|
linkData = {
|
||
|
to: 'edition',
|
||
|
params: {
|
||
|
editionId: this.props.piece.first_edition.bitcoin_id
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return linkData;
|
||
|
},
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<AccordionListItem
|
||
|
className={this.props.className}
|
||
|
thumbnail={
|
||
|
<Link {...this.getLinkData()}>
|
||
|
<img src={this.props.piece.thumbnail.url_safe}/>
|
||
|
</Link>}
|
||
|
heading={
|
||
|
<Link {...this.getLinkData()}>
|
||
|
<h1>{this.props.piece.title}</h1>
|
||
|
</Link>}
|
||
|
subheading={
|
||
|
<h3>
|
||
|
{getLangText('by %s', this.props.piece.artist_name)}
|
||
|
</h3>
|
||
|
}
|
||
|
subsubheading={this.props.subsubheading}
|
||
|
buttons={this.props.buttons}
|
||
|
badge={this.props.badge}
|
||
|
>
|
||
|
{this.props.children}
|
||
|
</AccordionListItem>
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
export default AccordionListItemPiece;
|