Clean up logo code

This commit is contained in:
Alex Gleason 2020-04-10 17:17:02 -05:00
parent f351823129
commit 7bbe293537
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 9 additions and 11 deletions

View File

@ -9,21 +9,19 @@ const mapStateToProps = (state, props) => ({
}); });
class LandingPage extends ImmutablePureComponent { class LandingPage extends ImmutablePureComponent {
shouldComponentUpdate(nextProps, nextState) { getSiteLogo = () => {
const { instance, soapbox } = nextProps; const { instance, soapbox } = this.props;
return !instance.isEmpty() && !soapbox.isEmpty(); const logos = {
imgLogo: (<img alt={instance.get('title')} src={soapbox.get('logo')} />),
textLogo: (<h1>{instance.get('title')}</h1>),
}
return soapbox.get('logo') ? logos['imgLogo'] : logos['textLogo'];
} }
render() { render() {
const { instance, soapbox } = this.props; const { instance, soapbox } = this.props;
if (instance.isEmpty()) return null;
if (instance.isEmpty() || soapbox.isEmpty()) return null; const siteLogo = this.getSiteLogo();
const siteLogo = soapbox.get('logo') ? (
<img alt={instance.get('title')} src={soapbox.get('logo')} />
) : (
<h1>{instance.get('title')}</h1>
);
return ( return (
<div className='public-layout'> <div className='public-layout'>