Skip to content

Commit

Permalink
Fixes mozilla-services#4790 - NonFxA Shot takers should be briefly on…
Browse files Browse the repository at this point in the history
…boarded
  • Loading branch information
punamdahiya committed Nov 2, 2018
1 parent 9659805 commit 1afc2bd
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 18 deletions.
2 changes: 2 additions & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ These are events that an add-on user can encounter on a shot they own
37. [x] Remove shot from favorites `web-unset-favorite/navbar`
38. [x] Signin to Firefox Accounts `web/fxa-signin`
39. [x] Signin to Firefox Accounts from banner `web/fxa-signin-ad-banner`
40. [x] Signin to Firefox Accounts from onboarding promo `web/fxa-signin-onboarding-promo`
41. [x] Click on dismiss of Firefox Accounts onboarding promo `web/onboarding-promo-closed`

#### Shot Index (My Shots)

Expand Down
9 changes: 9 additions & 0 deletions locales/en-US/server.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ screenshotsLogo =
bannerSignIn = <a>Sign in or sign up</a> to access your shots across devices and save your favorites forever.
bannerUpsell = {gScreenshotsDescription} <a>Get Firefox now</a>
# Text used in Firefox Account onboarding promo shown below
# Sign in button in header
onboardingPromoTitle = What’s new with Firefox Screenshots?
onboardingPromoMessage = Now, sign in to Screenshots with a Firefox Account and do more:
onboardingPromoMessageListItem1 = Access your library on all of your devices
onboardingPromoMessageListItem2 = Store your favorite shots forever
onboardingPromoDismissButton = Dismiss
onboardingPromoSigninButton = Sign in
## Footer

# Note: link text for a link to mozilla.org
Expand Down
19 changes: 19 additions & 0 deletions server/src/ad-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const sendEvent = require("./browser-send-event.js");
exports.AdBanner = class AdBanner extends React.Component {
constructor(props) {
super(props);
this.state = {
hideBanner: false,
};
}

clickedInstallFirefox() {
Expand All @@ -16,7 +19,23 @@ exports.AdBanner = class AdBanner extends React.Component {
sendEvent("fxa-signin-ad-banner", {useBeacon: true});
}

shouldHideBanner() {
// If user is being shown fxa-onboarding promo
// we should hide banner
return !localStorage.hasSeenOnboardingPromo ||
localStorage.hasSeenOnboardingPromo < 3;
}

componentDidMount() {
const hideBanner = this.shouldHideBanner();
this.setState({hideBanner});
}

render() {
if (this.state.hideBanner) {
return null;
}

let bannerContent = null;

if (this.props.shouldGetFirefox && !this.props.isOwner) {
Expand Down
87 changes: 87 additions & 0 deletions server/src/fxa-onboarding-promo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const React = require("react");
const PropTypes = require("prop-types");
const { Localized } = require("fluent-react/compat");
const sendEvent = require("./browser-send-event.js");

exports.FxAOnboardingPromo = class FxAOnboardingPromo extends React.Component {
constructor(props) {
super(props);
this.state = {
showPromo: false,
};
}

shouldShowOnboardingPromo() {
let show = false;
const count = localStorage.hasSeenOnboardingPromo;
if (!count) {
localStorage.hasSeenOnboardingPromo = 1;
show = true;
} else if (count < 3) {
localStorage.hasSeenOnboardingPromo = parseInt(count, 10) + 1;
show = true;
}
return show;
}

componentDidMount() {
const showPromo = this.shouldShowOnboardingPromo();
this.setState({showPromo});
}

render() {
if (this.state.showPromo) {
return <div className="onboarding-promo-panel right-align">
<div className="triangle"><div className="triangle-inner"></div></div>
<div className="promo-header">
<span className="promo-logo" />
<Localized id="onboardingPromoTitle">
<span className="promo-title">What’s new with Firefox Screenshots?</span>
</Localized>
</div>
<div className="promo-message">
<Localized id="onboardingPromoMessage">
<p>
Now, sign in to Screenshots with a Firefox Account and
do more:
</p>
</Localized>
<ul>
<Localized id="onboardingPromoMessageListItem1">
<li>Access your library on all of your devices</li>
</Localized>
<Localized id="onboardingPromoMessageListItem2">
<li>Store your favorite shots forever</li>
</Localized>
</ul>
</div>
<div className="promo-footer">
<Localized id="onboardingPromoDismissButton" attrs={{title: true}}>
<a href="#" title="Dismiss" onClick={ this.onClosePanel.bind(this) }>Dismiss</a>
</Localized>
<Localized id="onboardingPromoSigninButton" attrs={{title: true}}>
<button className="button primary" title="Sign in" onClick={ this.onConfirm.bind(this) }>Sign in</button>
</Localized>
</div>
</div>;
}
return null;
}

onClosePanel(event) {
const showPromo = !this.state.showPromo;
this.setState({showPromo});
sendEvent("onboarding-promo-closed");
}

onConfirm(event) {
const showPromo = !this.state.showPromo;
this.setState({showPromo});
sendEvent("fxa-signin-onboarding-promo");
location.href = this.props.logInURI;
}
};

exports.FxAOnboardingPromo.propTypes = {
logInURI: PropTypes.string,
};
6 changes: 5 additions & 1 deletion server/src/pages/shot/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function shouldHighlightEditIcon(model) {
}

function shouldShowPromo(model) {
if (!model.isOwner || !model.enableAnnotations) {
// If user is being shown fxa-onboarding promo we should
// hide edit tool promotion
if (!model.isOwner || !model.enableAnnotations ||
!localStorage.hasSeenOnboardingPromo ||
localStorage.hasSeenOnboardingPromo < 3 ) {
return false;
}
let show = false;
Expand Down
6 changes: 2 additions & 4 deletions server/src/pages/shot/shotpage-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ exports.ShotPageHeader = class ShotPageHeader extends React.Component {
renderFxASignIn() {
if (this.props.isOwner) {
return (
<div className="shot-fxa-signin">
<SignInButton isFxaAuthenticated={this.props.hasFxa} initialPage={this.props.shot.id}
staticLink={this.props.staticLink} />
</div>
<SignInButton isFxaAuthenticated={this.props.hasFxa} initialPage={this.props.shot.id}
staticLink={this.props.staticLink} />
);
}
return null;
Expand Down
28 changes: 17 additions & 11 deletions server/src/signin-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const React = require("react");
const PropTypes = require("prop-types");
const { Localized } = require("fluent-react/compat");
const sendEvent = require("./browser-send-event.js");
const { FxAOnboardingPromo } = require("./fxa-onboarding-promo");

exports.SignInButton = class SignInButton extends React.Component {
constructor(props) {
Expand All @@ -17,20 +18,25 @@ exports.SignInButton = class SignInButton extends React.Component {

render() {
if (this.state.displaySettings) {
return <Localized id="buttonSettings" attrs={{title: true}}>
<a className="transparent nav-button icon-settings" tabIndex="0" href="/settings" title="Settings">
<img src={this.props.staticLink("/static/img/icon-settings.svg")} />
</a>
</Localized>;
return <div className="fxa-signin">
<Localized id="buttonSettings" attrs={{title: true}}>
<a className="transparent nav-button icon-settings" tabIndex="0" href="/settings" title="Settings">
<img src={this.props.staticLink("/static/img/icon-settings.svg")} />
</a>
</Localized>
</div>;
}

const logInURI = "/api/fxa-oauth/login/" + this.props.initialPage;
return <Localized id="buttonSignIn" attrs={{title: true}}>
<a className="transparent nav-button icon-settings" tabIndex="0" href={logInURI} title="SignIn"
onClick={this.clickHandler.bind(this)}>
<img src={this.props.staticLink("/static/img/icon-settings.svg")} />
</a>
</Localized>;
return <div className="fxa-signin">
<Localized id="buttonSignIn" attrs={{title: true}}>
<a className="transparent nav-button icon-settings" tabIndex="0" href={logInURI} title="SignIn"
onClick={this.clickHandler.bind(this)}>
<img src={this.props.staticLink("/static/img/icon-settings.svg")} />
</a>
</Localized>
<FxAOnboardingPromo logInURI={logInURI} />
</div>;
}

clickHandler(event) {
Expand Down
3 changes: 1 addition & 2 deletions static/css/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ body {
background-size: 400px auto;
flex: 0 0 420px;
height: 440px;
z-index: 999;
}

.banner-image-back {
Expand Down Expand Up @@ -141,7 +140,7 @@ h2 {
width: 260px;
}

.button.primary {
.button.primary.download-firefox {
background: #30e60b;
color: #fff;
text-align: start;
Expand Down
110 changes: 110 additions & 0 deletions static/css/partials/_fxa-onboarding-promo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
.onboarding-promo-panel {
background: #f7f7f7;
border: 1px solid $light-border;
border-radius: 3px;
box-shadow: $medium-box-shadow;
color: #0c0c0d;
min-height: 200px;
position: absolute;
inset-inline-start: 3px;
top: 47px;
z-index: 2;

.triangle {
position: absolute;
width: 0;
height: 0;
border-inline-start: 9px solid transparent;
border-inline-end: 9px solid transparent;
border-bottom: 15px solid $light-border;
top: -15px;
inset-inline-start: 8px;

.triangle-inner {
position: absolute;
width: 0;
height: 0;
border-inline-start: 8px solid transparent;
border-inline-end: 8px solid transparent;
border-bottom: 13px solid $white;
inset-inline-start: -8px;
top: 2px;
}
}

&.right-align {
top: 70px;
width: 360px;
inset-inline-start: -300px;

@include respond-to("large") {
top: 85px;
width: 400px;
inset-inline-start: -310px;
}

.triangle {
inset-inline-start: 325px;
@include respond-to("large") {
inset-inline-start: 347px;
}
}
}

.promo-header {
display: flex;
align-items: center;
height: 60px;
background: $white;

.promo-logo {
background-position: center;
background-image: url("../img/icon-promo.svg");
background-repeat: no-repeat;
background-size: 30px auto;
background-color: #0684ff;
width: 60px;
height: 100%;
display: block;
}

.promo-title {
display: block;
font-size: 16px;
font-weight: bold;
padding: 0 16px;
}

}

.promo-message {
padding: 0 16px;
font-size: 14px;

ul {
padding-left: 16px;
}
}

.promo-footer {
height: 70px;
display: flex;
justify-content: flex-end;
align-items: center;

a {
font-weight: bold;
cursor: pointer;

&:hover {
text-decoration: underline;
}
}

button {
margin: 0 16px;
width: 120px;
height: 40px;
}
}
}
4 changes: 4 additions & 0 deletions static/css/partials/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
margin-inline-end: 0;
}

.fxa-signin {
position: relative;
}

a.nav-button {
&:focus {
outline: 1px dotted $black;
Expand Down
1 change: 1 addition & 0 deletions static/css/partials/_partials.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import "share-panel";
@import "theme";
@import "header";
@import "fxa-onboarding-promo";
1 change: 1 addition & 0 deletions static/img/icon-promo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1afc2bd

Please sign in to comment.