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

View file

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