// @flow import React from 'react'; import classnames from 'classnames'; type Props = { thumbnail: ?string, // externally sourced image nsfw: ?boolean, }; const autoThumbColors = [ 'purple', 'red', 'pink', 'indigo', 'blue', 'light-blue', 'cyan', 'teal', 'green', 'yellow', 'orange', ]; class CardMedia extends React.PureComponent { getAutoThumbClass = () => { return autoThumbColors[Math.floor(Math.random() * autoThumbColors.length)]; }; render() { const { thumbnail, nsfw } = this.props; const generateAutothumb = !thumbnail && !nsfw; let autoThumbClass; if (generateAutothumb) { autoThumbClass = `card__media--autothumb.${this.getAutoThumbClass()}`; } return (
{(!thumbnail || nsfw) && ( {nsfw ? __('NSFW') : 'LBRY'} )}
); } } export default CardMedia;