-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Desktop Splash, Mobile Inset template
- Loading branch information
1 parent
14cc588
commit 199bc1f
Showing
10 changed files
with
175 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.insetContainer { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, | ||
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
|
||
*, *:after, *:before { | ||
box-sizing: border-box; | ||
} | ||
} | ||
|
||
.img { | ||
max-height: 240px; | ||
} | ||
|
||
.heightConstraints { | ||
max-height: 240px; | ||
} | ||
|
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,47 @@ | ||
import {h, render, Component} from 'preact'; | ||
import styles from './InsetWithImage.scss'; | ||
import CloseButton from '../CloseButton'; | ||
import Cookies from 'js-cookie'; | ||
|
||
class InsetWithImage extends Component { | ||
_dismissSplash = () => { | ||
this.setState({showSplash: false}); | ||
Cookies.set('hasSeenSplash', 'true', {expires: 1, path: '/'}); | ||
document.removeEventListener('keydown', this._handleKeyDown); | ||
}; | ||
|
||
_shouldShowSplash = () => { | ||
if (!Cookies.get('hasSeenSplash')) { | ||
document.addEventListener('keydown', this._handleKeyDown); | ||
return true; | ||
} | ||
}; | ||
|
||
state = { | ||
showSplash: this._shouldShowSplash(), | ||
}; | ||
|
||
render() { | ||
return this.state.showSplash ? ( | ||
<div | ||
class={[styles.insetContainer, styles.heightConstraints].join(' ')} | ||
style={`background-color: ${this.props.backgroundColor}`} | ||
onClick={this._dismissSplash} | ||
data-cy="inset"> | ||
<CloseButton buttonColor="#000" clickAction={this._dismissSplash} /> | ||
<a | ||
href={this.props.clickthroughUrl} | ||
target="_blank" | ||
data-cy="inset-link"> | ||
<img | ||
src={this.props.imageUrl} | ||
class={[styles.img, styles.heightConstraints].join(' ')} | ||
data-cy="inset-img" | ||
/> | ||
</a> | ||
</div> | ||
) : null; | ||
} | ||
} | ||
|
||
export default InsetWithImage; |
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,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<title></title> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
window.DFP = window.DFP || {}; | ||
window.DFP.imageUrlDesktop = window.DFP.imageUrlDesktop || "https://picsum.photos/800/600"; | ||
window.DFP.imageUrlMobile = window.DFP.imageUrlMobile || "https://picsum.photos/240/400"; | ||
window.DFP.clickthroughUrl = window.DFP.clickthroughUrl || "http://www.wnyc.org"; | ||
window.DFP.templateName = window.DFP.templateName || "desktop-and-mobile-splash"; | ||
window.DFP.backgroundColor = window.DFP.backgroundColor || "#0000FF"; | ||
</script> | ||
<div id="dfp_splash_app"></div> | ||
</body> | ||
</html> |
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,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<title></title> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
window.DFP = window.DFP || {}; | ||
window.DFP.imageUrlDesktop = window.DFP.imageUrlDesktop || "https://picsum.photos/800/600"; | ||
window.DFP.imageUrlMobile = window.DFP.imageUrlMobile || "https://picsum.photos/400/240"; | ||
window.DFP.clickthroughUrl = window.DFP.clickthroughUrl || "http://www.wnyc.org"; | ||
window.DFP.templateName = window.DFP.templateName || "desktop-splash-mobile-inset"; | ||
window.DFP.backgroundColor = window.DFP.backgroundColor || "#0000FF"; | ||
</script> | ||
<div id="dfp_splash_app"></div> | ||
</body> | ||
</html> |
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,4 @@ | ||
import {h, render, Component} from 'preact'; | ||
import SplashOverlay from '../../components/SplashOverlay'; | ||
|
||
export default () => <SplashOverlay />; |
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,25 @@ | ||
import {h, render, Component} from 'preact'; | ||
import SplashOverlay from '../../components/SplashOverlay'; | ||
import InsetWithImage from '../../components/InsetWithImage'; | ||
|
||
class DesktopSplashMobileInset extends Component { | ||
state = { | ||
windowSize: window.innerWidth, | ||
}; | ||
|
||
render() { | ||
if (this.state.windowSize > 840) { | ||
return <SplashOverlay />; | ||
} else { | ||
return ( | ||
<InsetWithImage | ||
imageUrl={window.DFP.imageUrlMobile} | ||
backgroundColor={window.DFP.backgroundColor} | ||
clickthroughUrl={window.DFP.clickthroughUrl} | ||
/> | ||
); | ||
} | ||
} | ||
} | ||
|
||
export default DesktopSplashMobileInset; |
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