Skip to content

Commit

Permalink
Follow up after discussion with Matt
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 3, 2019
1 parent 4bed824 commit d9d4620
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions docs/src/modules/components/Ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const styles = theme => ({
},
paper: {
padding: theme.spacing(1.5),
border: `2px solid ${theme.palette.primary.main}`,
backgroundColor: theme.palette.background.level2,
display: 'block',
},
Expand Down Expand Up @@ -106,19 +107,22 @@ function Ad(props) {
};
}, [checkAdblock]);

let children;
let minHeight;

// Hide the content to google bot.
if (/Googlebot/.test(navigator.userAgent)) {
return null;
if (/Googlebot/.test(navigator.userAgent) || disable) {
children = <span />;
}

let children;

if (adblock) {
children = <AdInHouse ad={inHouses[Math.round((inHouses.length - 1) * random)]} />;
}
minHeight = 'auto';

if (disable) {
children = getAdblock(classes, t);
if (random >= 0.8) {
children = getAdblock(classes, t);
} else {
children = <AdInHouse ad={inHouses[Math.round((inHouses.length - 1) * random)]} />;
}
}

if (!children) {
Expand All @@ -128,14 +132,12 @@ function Ad(props) {
children = <AdCarbon />;
} else {
children = <AdInHouse ad={inHouses[Math.round((inHouses.length - 1) * random)]} />;
minHeight = 'auto';
}
}

return (
<span
className={classes.root}
style={{ minHeight: children.type === 'AdInHouse' ? 'auto' : null }}
>
<span className={classes.root} style={{ minHeight }}>
{children}
</span>
);
Expand Down

0 comments on commit d9d4620

Please sign in to comment.