Skip to content

Commit

Permalink
Fixes mozilla-services#4724 - Add image editor new feature promotion …
Browse files Browse the repository at this point in the history
…dialog
  • Loading branch information
punamdahiya committed Aug 6, 2018
1 parent e164e42 commit 8ba41ae
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
4 changes: 4 additions & 0 deletions locales/en-US/server.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ timeDiffFutureDays = { $number ->
errorThirdPartyCookiesEnabled = If you took this shot and cannot delete it, you may need to temporarily enable third party cookies from your browser’s preferences.
## Shot Page New Feature Promotion Dialog
promoMessage = We have improved the Image Editor!
promoLink = Give it a try
## Annotations

annotationPenButton =
Expand Down
12 changes: 12 additions & 0 deletions server/src/pages/shot/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ function shouldHighlightEditIcon(model) {
return !hasSeen;
}

function shouldShowPromo(model) {
if (!model.isOwner) {
return false;
}
const hasSeen = localStorage.hasSeenPromoDialog;
if (!hasSeen && model.enableAnnotations) {
localStorage.hasSeenPromoDialog = "1";
}
return !hasSeen;
}

exports.launch = function(data) {
const firstSet = !model;
model = data;
Expand Down Expand Up @@ -57,6 +68,7 @@ exports.launch = function(data) {
}
}
model.highlightEditButton = shouldHighlightEditIcon(model);
model.promoDialog = shouldShowPromo(model);
if (firstSet) {
refreshHash();
}
Expand Down
23 changes: 23 additions & 0 deletions server/src/pages/shot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { Localized } = require("fluent-react/compat");
const { Footer } = require("../../footer-view");
const sendEvent = require("../../browser-send-event.js");
const { ShareButton } = require("../../share-buttons");
const { PromoDialog } = require("../../promo-dialog");
const { DeleteShotButton } = require("../../delete-shot-button");
const { TimeDiff } = require("./time-diff");
const reactruntime = require("../../reactruntime");
Expand Down Expand Up @@ -182,6 +183,7 @@ class Body extends React.Component {

componentDidMount() {
this.setState({highlightEditButton: this.props.highlightEditButton});
this.setState({promoDialog: this.props.promoDialog});
}

doCloseBanner() {
Expand Down Expand Up @@ -408,6 +410,7 @@ class Body extends React.Component {

const noText = this.props.abTests && this.props.abTests.downloadText
&& this.props.abTests.downloadText.value === "no-download-text";

return (
<reactruntime.BodyTemplate {...this.props}>
{ renderGetFirefox ? this.renderFirefoxRequired() : null }
Expand All @@ -430,6 +433,7 @@ class Body extends React.Component {
{ this.props.enableAnnotations ? editButton : null }
{ highlight }
<ShareButton abTests={this.props.abTests} clipUrl={clipUrl} shot={shot} isOwner={this.props.isOwner} staticLink={this.props.staticLink} renderExtensionNotification={renderExtensionNotification} isExtInstalled={this.props.isExtInstalled} />
<PromoDialog promoClose={this.promoClose.bind(this)} promoOpen={this.promoOpen.bind(this)} display={this.state.promoDialog} promoType="edit" />
<Localized id="shotPageDownloadShot">
<a className="button primary" href={ this.props.downloadUrl } onClick={ this.onClickDownload.bind(this) }
title="Download the shot image">
Expand All @@ -452,6 +456,24 @@ class Body extends React.Component {
</reactruntime.BodyTemplate>);
}

promoOpen(promoType) {
if (promoType === "edit") {
document.querySelector(".button.transparent.edit").style.backgroundColor = "#ededf0";
}
}

promoClose(shouldDisplay, islink, promoType) {
if (!shouldDisplay) {
this.setState({promoDialog: false});
}
if (promoType === "edit") {
if (islink) {
this.onClickEdit();
}
document.querySelector(".button.transparent.edit").style.backgroundColor = "";
}
}

onMouseOverHighlight() {
this.editButton.style.backgroundColor = "#ededf0";
}
Expand Down Expand Up @@ -555,6 +577,7 @@ Body.propTypes = {
enableAnnotations: PropTypes.bool,
expireTime: PropTypes.number,
highlightEditButton: PropTypes.bool,
promoDialog: PropTypes.bool,
id: PropTypes.string,
isExtInstalled: PropTypes.bool,
isMobile: PropTypes.bool,
Expand Down
49 changes: 49 additions & 0 deletions server/src/promo-dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const React = require("react");
const PropTypes = require("prop-types");
const { Localized } = require("fluent-react/compat");
const sendEvent = require("./browser-send-event.js");

exports.PromoDialog = class PromoDialog extends React.Component {
constructor(props) {
super(props);
}

render() {
if (this.props.display) {
this.props.promoOpen(this.props.promoType);
return <div id="promo-dialog-panel" className="promo-panel" >
<div className={`${this.props.promoType} promo-box default-color-scheme`}>
<a className="box-close" onClick={this.closePanel.bind(this)}></a>
<span className="title"></span>
<Localized id="promoMessage">
<p className="message">
We have improved the Image Editor!
</p>
</Localized>
<span className="promo-star"></span>
<Localized id="promoLink">
<span id="promo-link" className="message link" onClick={this.closePanel.bind(this)}>
Give it a try
</span>
</Localized>
<span className="promo-star"></span>
</div>
</div>;
}
return null;
}

closePanel(event) {
const shouldDisplay = false;
const isLink = event.target.id === "promo-link";
this.props.promoClose(shouldDisplay, isLink, this.props.promoType);
sendEvent("promo-closed");
}
};

exports.PromoDialog.propTypes = {
display: PropTypes.bool,
promoClose: PropTypes.func,
promoOpen: PropTypes.func,
promoType: PropTypes.string
};
65 changes: 65 additions & 0 deletions static/css/frame.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,71 @@
}
}

.promo-panel {
.edit {
right: 85px;
top: 75px;
}
.promo-box {
border-radius: 3px;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 0, 0, 0.2);
position: absolute;
width: 120px;
z-index: 999;
padding: 10px 5px;
text-align:center;
}

.title {
font-size: 24px;
line-height: 20px;
font-weight: bold;
}

.title:before {
content: "\01F44B";
}

.message {
display: inline-block;
font-size: 12px;
margin: 5px 2px;
}

.promo-star:before {
content: "\02728";
}

.link {
cursor: pointer;
color: #009ec0;
}

.promo-type-highlight {
background-color: #ededf0;
}

a.box-close{
float:right;
cursor:pointer;
color: #000000;
border: 1px solid #AEAEAE;
border-radius: 50%;
width:15px;
height: 15px;
line-height: 10px;
margin: -8px -3px 0 0;
}

.box-close:before {
content: "×";
}

.box-close:hover {
background-color: $light-hover;
}
}

.shot-alt-actions {
#downloadIcon {
margin-right: 4px;
Expand Down

0 comments on commit 8ba41ae

Please sign in to comment.