import React from 'react'; export default class ListItem extends React.Component { state = { } componentDidMount() { const randomColor = [ '#96cdcd', '#cd6889', '#eec5b7', '#7ccd7c', '#cdb7b5', '#eeeed1', '#8db6cd', '#8b8b83', ]; this.setState({ randomColor: randomColor[Math.floor(Math.random() * randomColor.length)] }); } buildIcons() { const links = this.props.server.links || []; return links.map((l, i) => { if (l.type === 'youtube') { return (); } else if (l.type === 'twitter') { return (); } else if (l.type === 'twitch') { return (); } else if (l.type === 'reddit') { return (); } return false; }); } render() { let style = {}; if (this.props.server.featured && this.props.featured && this.props.server.backgroundImageVertical) { style = { backgroundImage: `url(${this.props.server.backgroundImageVertical})` }; } else if ((this.props.server.premium || this.props.server.featured) && this.props.server.backgroundImage) { style = { backgroundImage: `url(${this.props.server.backgroundImage})` }; } // else { // style = { // backgroundImage: 'url(https://s.dyno.gg/server-listing/squares.png)', // backgroundSize: 'auto', // backgroundRepeat: 'repeat', // backgroundColor: '#2f2f2f', // }; // } style.backgroundColor = style.backgroundColor || '#3B3D43'; if (this.props.server.borderColor) { style.borderColor = this.props.server.borderColor; } let iconStyle = { backgroundColor: '#666', backgroundImage: `url(${this.props.server.icon || '/images/v3/dyno-44.svg'})`, }; let inviteUrl = `/server/${this.props.server.id}/invite`; const links = this.props.server.links || []; const hasIcons = links && links.length > 0; const extraDescriptionClasses = (!hasIcons) ? 'no-icons' : ''; return ( // linear-gradient(1deg, rgba(26,39,55,1) 15%, rgba(26,39,55,0.68) 95%, rgba(26,39,55,0.65) 100%);
{hasIcons && (this.props.premium || this.props.featured) &&
{this.buildIcons()}
} { !this.props.premium && !this.props.featured &&
Join
}
{this.props.server.name}
{this.props.server.memberCount} members
{ !this.props.premium &&

{this.props.server.description}

} { this.props.featured && this.props.server.categories && this.props.server.categories.length > 0 &&
{ this.props.server.categories.slice(0, 2).map((cat, i) => { return (#{cat.toLowerCase()}); }) }
} { (this.props.premium || this.props.featured) && Join }
); } }