-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ebd048
commit 73711a4
Showing
9 changed files
with
239 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint react/jsx-no-target-blank: ["error", { allowReferrer: true }] */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import clsx from 'clsx'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { adShape } from 'docs/src/modules/components/AdManager'; | ||
import { adStylesObject } from 'docs/src/modules/components/ad.styles'; | ||
|
||
const hookFactory = (shape) => | ||
makeStyles((theme) => { | ||
const styles = adStylesObject[`body-${shape}`](theme); | ||
return { | ||
root: { | ||
...styles.root, | ||
'& img': styles.img, | ||
'& a, & a:hover': styles.a, | ||
}, | ||
imageWrapper: styles.imgWrapper, | ||
description: styles.description, | ||
poweredby: styles.poweredby, | ||
}; | ||
}); | ||
|
||
const autoShapeStyles = hookFactory(adShape); | ||
const inlineShapeStyles = hookFactory('inline'); | ||
|
||
export default function AdDisplay(props) { | ||
const { ad, className, shape = 'auto' } = props; | ||
let classes; | ||
|
||
if (shape === 'inline') { | ||
classes = inlineShapeStyles(); | ||
} else { | ||
classes = autoShapeStyles(); | ||
} | ||
|
||
/* eslint-disable material-ui/no-hardcoded-labels, react/no-danger */ | ||
return ( | ||
<span className={clsx(classes.root, 'ad-display', className)}> | ||
<a href={ad.link} target="_blank" rel="noopener sponsored"> | ||
<span className={classes.imageWrapper}> | ||
<img height="100" width="130" className={classes.image} src={ad.img} alt={ad.name} /> | ||
</span> | ||
<span | ||
className={classes.description} | ||
dangerouslySetInnerHTML={{ __html: ad.description }} | ||
/> | ||
</a> | ||
<span className={classes.poweredby}>ad by {ad.poweredby}</span> | ||
</span> | ||
); | ||
/* eslint-enable material-ui/no-hardcoded-labels, react/no-danger */ | ||
} | ||
|
||
AdDisplay.propTypes = { | ||
ad: PropTypes.object.isRequired, | ||
className: PropTypes.string, | ||
shape: PropTypes.oneOf(['inline', 'auto']), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import loadScript from 'docs/src/modules/utils/loadScript'; | ||
import adStyles from 'docs/src/modules/components/ad.styles'; | ||
import { adShape } from 'docs/src/modules/components/AdManager'; | ||
|
||
const useStyles = makeStyles((theme) => { | ||
const styles = adStyles(theme); | ||
|
||
return { | ||
'@global': { | ||
'[data-ea-publisher][data-ea-publisher][data-ea-publisher][data-ea-publisher]': { | ||
'&&': { | ||
display: 'block', | ||
}, | ||
'& .ea-placement': { | ||
...styles.root, | ||
}, | ||
'& .ea-content': { | ||
margin: 0, | ||
padding: 0, | ||
overflow: 'visible', | ||
boxShadow: 'none', | ||
background: 'transparent', | ||
maxWidth: '100%', | ||
color: 'inherit', | ||
}, | ||
'& .ea-content > a': { | ||
...styles.imgWrapper, | ||
marginLeft: -125, | ||
width: 120, | ||
height: 90, | ||
}, | ||
'& .ea-content > a img': styles.img, | ||
'& a, & a:hover': styles.a, | ||
'& .ea-text': { | ||
marginTop: 0, | ||
color: 'inherit', | ||
textAlign: 'left', | ||
}, | ||
'& .ea-text strong': { | ||
color: 'inherit', | ||
}, | ||
'& .ea-text a': { | ||
...styles.description, | ||
color: 'inherit', | ||
}, | ||
'& .ea-callout': { | ||
margin: 0, | ||
padding: 0, | ||
fontStyle: 'normal', | ||
textAlign: 'left', | ||
...styles.poweredby, | ||
}, | ||
'& .ea-callout a': { | ||
fontSize: 'inherit', | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
export default function AdReadthedocs() { | ||
useStyles(); | ||
|
||
React.useEffect(() => { | ||
const script = loadScript( | ||
'https://media.ethicalads.io/media/client/ethicalads.min.js', | ||
document.querySelector('head'), | ||
); | ||
|
||
return () => { | ||
script.parentElement.removeChild(script); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div data-ea-publisher="material-ui" data-ea-type={adShape === 'image' ? 'image' : 'text'} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters