-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Ad): always include empty div
BREAKING CHANGE: The `adUrl` prop has been removed
- Loading branch information
1 parent
6da5a0e
commit 34db084
Showing
5 changed files
with
15 additions
and
58 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 |
---|---|---|
@@ -1,50 +1,13 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import withRouter from '../../../../hocs/withRouter'; | ||
import React from 'react'; | ||
import styles from './Ad.module.scss'; | ||
|
||
function randomString() { | ||
return Math.random() | ||
.toString(36) | ||
.replace(/[^a-z]+/g, ''); | ||
} | ||
|
||
class Ad extends Component { | ||
shouldComponentUpdate(nextProps) { | ||
const { previousMediaId } = this.props; | ||
const nextMediaId = nextProps.params.assemblyId; | ||
|
||
return nextMediaId !== previousMediaId; | ||
} | ||
|
||
render() { | ||
const { adUrl } = this.props; | ||
|
||
return ( | ||
<div className={styles.Ad}> | ||
<iframe | ||
src={`${adUrl}?${randomString()}`} | ||
title="advertisement" | ||
height="100%" | ||
width="100%" | ||
scrolling="no" | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
const Ad = ({ assemblyId }) => ( | ||
<div className={styles.Ad} id="media-overlay-ad" data-assembly-id={assemblyId} /> | ||
); | ||
|
||
Ad.propTypes = { | ||
adUrl: PropTypes.string.isRequired, | ||
previousMediaId: PropTypes.string, | ||
|
||
// withRouter props | ||
|
||
params: PropTypes.shape().isRequired, | ||
}; | ||
|
||
Ad.defaultProps = { | ||
previousMediaId: null, | ||
assemblyId: PropTypes.number.isRequired, | ||
}; | ||
|
||
export default withRouter(Ad); | ||
export default Ad; |
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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
.Ad { | ||
margin-bottom: $overlay-gap; | ||
height: 250px; | ||
max-height: 250px; | ||
width: 300px; | ||
} |
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