@ -30,6 +30,10 @@ export default class Card extends React.PureComponent {
maxDescription : 50 ,
maxDescription : 50 ,
} ;
} ;
state = {
width : 0 ,
} ;
renderLink ( ) {
renderLink ( ) {
const { card , maxDescription } = this . props ;
const { card , maxDescription } = this . props ;
@ -75,14 +79,25 @@ export default class Card extends React.PureComponent {
) ;
) ;
}
}
setRef = c => {
if ( c ) {
this . setState ( { width : c . offsetWidth } ) ;
}
}
renderVideo ( ) {
renderVideo ( ) {
const { card } = this . props ;
const { card } = this . props ;
const content = { _ _html : card . get ( 'html' ) } ;
const content = { _ _html : card . get ( 'html' ) } ;
const { width } = this . state ;
const ratio = card . get ( 'width' ) / card . get ( 'height' ) ;
const height = card . get ( 'width' ) > card . get ( 'height' ) ? ( width / ratio ) : ( width * ratio ) ;
return (
return (
< div
< div
ref = { this . setRef }
className = 'status-card-video'
className = 'status-card-video'
dangerouslySetInnerHTML = { content }
dangerouslySetInnerHTML = { content }
style = { { height } }
/ >
/ >
) ;
) ;
}
}