Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewards rebase #53

Merged
merged 79 commits into from May 10, 2018
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
72cb75f
Initial commit. Code works on staging with some temp workarounds
Apr 23, 2018
443f6c4
Removing temporary code.
Apr 23, 2018
64a945a
hot dog
trickpattyFH20 Mar 27, 2018
888c8b1
init circle
trickpattyFH20 Mar 29, 2018
7884800
react hot dog
trickpattyFH20 Mar 29, 2018
eac594c
rewards hot dog ui
trickpattyFH20 Mar 30, 2018
7358f88
close circle
trickpattyFH20 Mar 30, 2018
4c6004b
routing and offer card
trickpattyFH20 Apr 2, 2018
8b45dad
reward card layout
trickpattyFH20 Apr 2, 2018
06474ca
more offer card styles
trickpattyFH20 Apr 2, 2018
8feb2f6
card footer + copy feedback + styling
trickpattyFH20 Apr 3, 2018
c325bb9
more styles
trickpattyFH20 Apr 3, 2018
a6381f5
remove purple test style
trickpattyFH20 Apr 4, 2018
eeea57a
test rewards postmessage
trickpattyFH20 Apr 4, 2018
830aee8
one reward at a time for hot dog and offer card
trickpattyFH20 Apr 5, 2018
df4ea54
header + footer + styles
trickpattyFH20 Apr 9, 2018
d11ba1c
react shadow
trickpattyFH20 Apr 13, 2018
169fff4
define MainView first
trickpattyFH20 Apr 13, 2018
44ddfc6
lint
trickpattyFH20 Apr 16, 2018
4084715
add onmessage
trickpattyFH20 Apr 16, 2018
0521a73
fix selector and close button
trickpattyFH20 Apr 16, 2018
603e73f
iframe fallback
trickpattyFH20 Apr 17, 2018
2029ba2
fix ff beta logo
trickpattyFH20 Apr 17, 2018
2efba4c
data csp compatible images + class for index + text styles
trickpattyFH20 Apr 18, 2018
88b0621
disable rewards notification
trickpattyFH20 Apr 18, 2018
52ae822
fix shadow FOUC
trickpattyFH20 Apr 18, 2018
b55f20d
click outside settings
trickpattyFH20 Apr 18, 2018
ef81951
settings styles
trickpattyFH20 Apr 20, 2018
8049a56
settings actions
trickpattyFH20 Apr 23, 2018
27b8d4f
show ghostery pizza offer
trickpattyFH20 Apr 24, 2018
0613ab9
fix event listener reward reference
trickpattyFH20 Apr 26, 2018
52de54f
setConfiguration - for DEBUG only
Apr 27, 2018
632744e
Changing the way browser-core is loaded.
Apr 27, 2018
dff2831
handle signal
trickpattyFH20 Apr 30, 2018
99537a1
mark offer read + delete offer
trickpattyFH20 Apr 30, 2018
c23fe6f
new signals
trickpattyFH20 Apr 30, 2018
85002e5
refactor to sendSignal
trickpattyFH20 May 1, 2018
7ef9f23
Create ToggleSlider component. Use it in Setup flow.
IAmThePan Apr 11, 2018
c9c69ac
GH-409 Update Rewards view: rewards list, toggle on/off, reducers, fa…
IAmThePan Apr 16, 2018
2083be0
GH-409 Update Rewards view: reward details.
IAmThePan Apr 18, 2018
e2351b6
hot dog
trickpattyFH20 Mar 27, 2018
7301085
Integrate panel rewards with background I
IAmThePan Apr 26, 2018
dfb6317
Integrate panel rewards with background II. Fix linting errors
IAmThePan Apr 30, 2018
74b6611
Integrate panel rewards with Background III. Messages for read, remov…
IAmThePan Apr 30, 2018
574f679
Fix signal bug for content-script rewards
IAmThePan May 1, 2018
45094be
panel reward signals
trickpattyFH20 May 1, 2018
b771879
reward prompt flow
trickpattyFH20 May 1, 2018
456e54d
Finalize design for Rewards Panel
IAmThePan May 2, 2018
7d923da
clean rewards
trickpattyFH20 May 2, 2018
b4f87fe
rewards conf handling
trickpattyFH20 May 3, 2018
8272b01
update browser-core package and lock
trickpattyFH20 May 3, 2018
4bf063e
Add translations to Rewards Panel
IAmThePan May 3, 2018
f0aa355
Fix for Ghostery side enabling of offers
May 3, 2018
332f79f
styles. expiration. terms tt
trickpattyFH20 May 3, 2018
7dbd42f
enable offers by default
trickpattyFH20 May 3, 2018
455bc0e
start button styles
trickpattyFH20 May 3, 2018
3ed2459
Begin tests for the rewards panel
IAmThePan May 3, 2018
a3f202c
More and updated tests for Rewards Panel
IAmThePan May 3, 2018
a6f1441
Fix linting errors
IAmThePan May 3, 2018
a904612
signals
trickpattyFH20 May 4, 2018
9640606
Add more signals, fix linting errors, fix bug
IAmThePan May 4, 2018
417f461
Removing offers from ABTest
May 7, 2018
2815dca
style adjustments
trickpattyFH20 May 7, 2018
d87c7c9
GH-1051 fix null reward check
trickpattyFH20 May 8, 2018
48b38fd
GH-1055 fix - define onload evt first
trickpattyFH20 May 8, 2018
e294c78
button singleton + seen reward on offer card shown
trickpattyFH20 May 9, 2018
afb2dc4
typo
trickpattyFH20 May 9, 2018
7fb6652
Removing enable_offers_abtest.
May 9, 2018
83e7b78
Extra blanks
May 9, 2018
3976965
Removing checkbox for EDGE and CLIQZ unconditionally.
May 9, 2018
07983d0
Restore default manifest state.
May 9, 2018
bb2ee65
Update Rewards copy and add styling to non-happy-path Rewards panel
IAmThePan May 10, 2018
771c910
Update test snapshots
IAmThePan May 10, 2018
86111a3
Update package-lock file
IAmThePan May 10, 2018
86cc883
Minor copy change
IAmThePan May 10, 2018
63afa92
GH-1066 Fix text overflow on rewards panel
IAmThePan May 10, 2018
c25119b
Update snapshots for Reward Detail unit tests
IAmThePan May 10, 2018
afc04fc
documentation and svg cleanup
christophertino May 10, 2018
88229ed
Merge branch 'develop' into rewards-rebase
christophertino May 10, 2018
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

data csp compatible images + class for index + text styles
  • Loading branch information
trickpattyFH20 authored and IAmThePan committed May 10, 2018
commit 2efba4ce46f07ec1c85c185cc13e0f5521591739
@@ -21,6 +21,9 @@ class HotDog extends Component {
this.iframeEl.classList.add('hot-dog');
}

this.ghostyStar = `url(${chrome.extension.getURL('app/images/rewards/ghosty-star.svg')})`;
this.closeIcon = `url(${chrome.extension.getURL('app/images/rewards/light-x.svg')})`;

this.close = this.close.bind(this);
this.navigate = this.navigate.bind(this);
}
@@ -42,16 +45,17 @@ class HotDog extends Component {
}

render() {
console.log('render props', this.props);
return (
<div className="ghostery-rewards-component">
{ this.state.closed !== true &&
<div>
<div onClick={this.navigate} className="hot-dog-container">
<div onClick={this.navigate} className="hot-dog-container" style={{backgroundImage: this.ghostyStar}} >
<div className="ghostery-reward-text">
1 {t('rewards_new_text')}!
</div>
</div>
<div className="ghostery-reward-close" onClick={this.close} />
<div className="hot-dog-close" onClick={this.close} style={{backgroundImage: this.closeIcon}} />
</div>
}
</div>
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Link } from 'react-router-dom';
import msgModule from '../utils/msg';
import { log } from '../../../src/utils/common';
@@ -22,17 +23,17 @@ class OfferCard extends Component {
this.iframeEl.classList.add('offer-card');
}

this.betaLogo = `url(${chrome.extension.getURL('app/images/rewards/ghostery-rewards-beta.png')})`;
this.closeIcon = `url(${chrome.extension.getURL('app/images/drawer/x.svg')})`;
this.ghostyGrey = `url(${chrome.extension.getURL('app/images/rewards/ghosty-grey.svg')})`;
this.kebabIcon = `url(${chrome.extension.getURL('app/images/rewards/settings-kebab.svg')})`;

this.close = this.close.bind(this);
this.copyCode = this.copyCode.bind(this);
}

copyCode() {
// copy code to clipboard
if (document.getElementById('ghostery-shadow-root')) {
document.getElementById('ghostery-shadow-root').shadowRoot.querySelector('.reward-code-input').select();
} else {
document.getElementById('ghostery-iframe-container').contentWindow.document.querySelector('.reward-code-input').select();
}
ReactDOM.findDOMNode(this).querySelector('.reward-code-input').select();
document.execCommand('copy');

// 'copied' feedback for user
@@ -65,29 +66,32 @@ class OfferCard extends Component {
{ this.state.closed !== true &&
<div className="ghostery-reward-card">
<div className="reward-card-header">
<div className="rewards-logo-beta" />
<div className="reward-card-close" onClick={this.close} />
<div className="rewards-logo-beta" style={{backgroundImage: this.betaLogo}} />
<div className="reward-card-close" onClick={this.close} style={{backgroundImage: this.closeIcon}} />
</div>
<div className="reward-content">
<div className="reward-content-header">
<div className="flex-grow" />
<div className="reward-company-logo">
<img src={this.props.reward.companyLogo} />
</div>
<div className="reward-settings-kebab" />
<div className="reward-settings-kebab" style={{backgroundImage: this.kebabIcon}} />
</div>
<div className="reward-content-img">
<img src={this.imgSrc} />
<div className="flex-grow" />
<img src={this.props.reward.contentImg} />
<div className="flex-grow" />
</div>
<div className="reward-content-detail">
<span className="reward-benefit">
{/* { this.state.benefit } */}
{ this.props.reward.benefit }
</span>
<span className="reward-headline">
{/* {this.state.headline} */}
{this.props.reward.headline}
</span>
<span className="reward-description">
{ this.props.reward.description }
</span>
<p className="reward-description">
{/* { this.state.description } */}
</p>
</div>
<div className="reward-code">
<div>
@@ -110,7 +114,7 @@ class OfferCard extends Component {
<a>{t('rewards_disable')}</a>
<div className="reward-arrow" />
</div>
<div className="reward-ghosty" />
<div className="reward-ghosty" style={{backgroundImage: this.ghostyGrey}} />
</div>
</div>}
</div>
@@ -29,94 +29,129 @@ import ShadowDOM from 'react-shadow';
const { BROWSER_INFO, onMessage } = globals;
const viewport = document.getElementById('viewport');
const channelsSupported = (typeof chrome.runtime.connect === 'function');
let rewardsContainer = document.createElement('div');
let rewardsApp = document.createElement('div');
let rewardsIframe;
let iframeStyle;
let port;
let MainView;

/* TODO massage offerz object into front end and remove mock data */
const reward = {
rewardCode: 'SDF75DSUI90',
expireTime: '14 days',
termsLink: 'https://www.ghostery.com/about-ghostery/browser-extension-privacy-policy/',
redeemLink: 'https://www.ghostery.com/',
benefit: '2 Free',
headline: 'Audio Books',
description: 'Description of the offer. There is a lot of exciting stuff going on.'
};
class RewardsApp {
constructor() {
this.reward = {
rewardCode: 'SDF75DSUI90',
expireTime: '14 days',
termsLink: 'https://www.ghostery.com/about-ghostery/browser-extension-privacy-policy/',
redeemLink: 'https://www.ghostery.com/',
benefit: '2 Free',
headline: 'Audio Books',
description: 'Description of the offer. There is a lot of exciting stuff going on.',
companyLogo: 'https://cdn.cliqz.com/extension/offers/test/resources/flaconi20-week/flaconi20-week-logo-long-1523970905.png',
contentImg: 'https://cdn.cliqz.com/extension/offers/test/resources/flaconi20-week/flaconi20-week-logo-long-1523970905.png'
};

rewardsApp.id = 'ghostery-rewards-app';
rewardsApp.className = 'show';
this.rewardsContainer = document.createElement('div');
this.rewardsApp = document.createElement('div');
this.rewardsIframe = null;;
this.iframeStyle = null;;
this.port = null;
this.mainView = null;
this.imgBlob = null;
this.rewardsApp.id = 'ghostery-rewards-app';
this.rewardsApp.className = 'show';
this.handleMessages = this.handleMessages.bind(this);

document.addEventListener('DOMContentLoaded', (event) => {
if (BROWSER_INFO.name === 'chrome') {
this.init();
}

init() {
document.addEventListener('DOMContentLoaded', (event) => {
console.log('DOMContentLoaded');
if (BROWSER_INFO.name === 'chrome') {
this.renderShadow();
} else {
// use iframe to encapsulate CSS - fallback for everything else besides chrome
this.renderIframe();
};
});
}

renderShadow() {
// use shadowDOM to encapsulate CSS - fully supported in Chrome
rewardsContainer.appendChild(rewardsApp);
document.body.appendChild(rewardsContainer);
MainView = (props) => {
this.rewardsContainer.appendChild(this.rewardsApp);
document.body.appendChild(this.rewardsContainer);
this.mainView = (props) => {
return (
<Router history={history}>
<ShadowDOM include={[chrome.extension.getURL('dist/css/rewards_styles.css')]}>
<div id="ghostery-shadow-root">
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} imgBlob={props.imgBlob} /> } />
</div>
</ShadowDOM>
</Router>
);
}
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
} else {
// use iframe to encapsulate CSS - fallback for everything else besides chrome
rewardsIframe = document.createElement('iframe');
rewardsIframe.id = 'ghostery-iframe-container';
rewardsIframe.classList.add('hot-dog')
document.body.appendChild(rewardsIframe);
rewardsIframe.onload = () => {
iframeStyle = document.createElement('link');
iframeStyle.rel = 'stylesheet';
iframeStyle.type = 'text/css';
iframeStyle.href = chrome.extension.getURL('dist/css/rewards_styles.css');
this.renderReact();
this.initListener();
}

renderIframe() {
this.rewardsIframe = document.createElement('iframe');
this.rewardsIframe.id = 'ghostery-iframe-container';
this.rewardsIframe.classList.add('hot-dog')
document.body.appendChild(this.rewardsIframe);
this.rewardsIframe.onload = () => {
this.iframeStyle = document.createElement('link');
this.iframeStyle.rel = 'stylesheet';
this.iframeStyle.type = 'text/css';
this.iframeStyle.href = chrome.extension.getURL('dist/css/rewards_styles.css');

rewardsIframe.contentWindow.document.head.appendChild(iframeStyle);
rewardsContainer = rewardsIframe.contentWindow.document.body;
this.rewardsIframe.contentWindow.document.head.appendChild(this.iframeStyle);
this.rewardsContainer = this.rewardsIframe.contentWindow.document.body;

rewardsApp.classList.add('iframe-child');
rewardsContainer.appendChild(rewardsApp);
MainView = (props) => {
this.rewardsApp.classList.add('iframe-child');
this.rewardsContainer.appendChild(this.rewardsApp);
this.mainView = (props) => {
return (
<Router history={history}>
<div>
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} imgBlob={props.imgBlob} /> } />
</div>
</Router>
);
}
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
this.renderReact();
this.initListener();
}
}

initListener() {
if (channelsSupported) {
this.port = chrome.runtime.connect({ name: 'rewardsPort' });
if (this.port) {
this.port.onMessage.addListener(this.handleMessages);
this.port.postMessage({ name: 'rewardsLoaded' });
}
} else {
onMessage.addListener(this.handleMessages);
}
};
});
}

function handleMessages(request, sender, response) {
console.log(request);
/* TODO get new reward from request, and set it as new reward */
if (document.readyState === 'complete') {
console.log('re render root react');
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
handleMessages(request, sender, response) {
console.log('postMessage request', request);
if (request.name === 'showHotDog') {
console.log('showHotDog postMessage');
}
console.log(document.readyState);
if (document.readyState === 'complete' || document.readyState === 'interactive') {
console.log('re render root react');
this.renderReact();
}
}
}

if (channelsSupported) {
port = chrome.runtime.connect({ name: 'rewardsPort' });
if (port) {
port.onMessage.addListener(handleMessages);
port.postMessage({ name: 'rewardsLoaded' });
renderReact() {
let MainView = this.mainView;
ReactDOM.render(<MainView reward={this.reward} imgBlob={this.imgBlob} />, this.rewardsApp);
}
} else {
onMessage.addListener(handleMessages);

}

new RewardsApp();
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="15px" height="16px" viewBox="0 0 15 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 48.2 (47327) - http://www.bohemiancoding.com/sketch -->
<title>Fill 3</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="strong-rewards-notification-Main-Copy-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-2775.000000, -3410.000000)">
<g id="Group-25" transform="translate(2176.000000, 2563.000000)" fill="#C8C7C2">
<path d="M613.575874,860.286737 C612.864956,858.760949 612.742619,857.468198 612.723444,856.960238 L612.723444,852.780808 C612.723444,849.588045 609.936532,847 606.498912,847 C603.060908,847 600.2739,849.588045 600.2739,852.780808 L600.2739,857.020655 C600.247247,857.567046 600.107556,858.820367 599.42425,860.286737 C598.505474,862.257162 599.265672,862.022397 599.946772,861.860224 C600.627681,861.698778 602.148364,861.065985 602.623524,861.845597 C603.0983,862.624754 603.494458,863.30161 604.603067,862.860246 C605.711773,862.419335 606.234199,862.272244 606.39249,862.272244 L606.60773,862.272244 C606.765925,862.272244 607.288543,862.419335 608.397057,862.860246 C609.505763,863.30161 609.901825,862.624754 610.376888,861.845597 C610.85176,861.065985 612.372347,861.698778 613.053448,861.860224 C613.734452,862.022397 614.494362,862.257162 613.575874,860.286737 M604.577564,850.152152 C605.248023,850.152152 605.791637,850.950843 605.791637,851.936328 C605.791637,852.921903 605.248023,853.720776 604.577564,853.720776 C603.907106,853.720776 603.363396,852.921903 603.363396,851.936328 C603.363396,850.950843 603.907106,850.152152 604.577564,850.152152 M606.498912,857.283948 C605.021469,857.283948 603.77777,855.933597 603.402992,854.430975 C604.126757,855.355225 605.244092,855.949042 606.498912,855.949042 C607.75354,855.949042 608.870874,855.355225 609.594735,854.430975 C609.219957,855.933597 607.976067,857.283948 606.498912,857.283948 M608.420355,853.720776 C607.749321,853.720776 607.205994,852.921903 607.205994,851.936328 C607.205994,850.950843 607.749321,850.152152 608.420355,850.152152 C609.091101,850.152152 609.634236,850.950843 609.634236,851.936328 C609.634236,852.921903 609.091101,853.720776 608.420355,853.720776" id="Fill-3"></path>
</g>
</g>
</svg>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="10px" height="10px" viewBox="0 0 10 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 48.2 (47327) - http://www.bohemiancoding.com/sketch -->
<title>Fill 2</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="strong-rewards-notification-Main-Copy-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-2782.000000, -2929.000000)">
<g id="Group-25" transform="translate(2176.000000, 2563.000000)" fill="#9B9B9B">
<path d="M612.718565,371 L615.642492,368.075748 C616.11744,367.601125 616.11744,366.831159 615.642492,366.356211 C615.167545,365.881263 614.397578,365.881263 613.924252,366.356211 L611,369.281435 L608.075748,366.356211 C607.601125,365.881263 606.831159,365.881263 606.356211,366.356211 C605.881263,366.831159 605.881263,367.601125 606.356211,368.075748 L609.280138,371 L606.356211,373.924252 C605.881263,374.398875 605.881263,375.168841 606.356211,375.643789 C606.831159,376.118737 607.601125,376.118737 608.074776,375.643789 L611,372.718565 L613.924252,375.642492 C614.398875,376.11744 615.168841,376.11744 615.643789,375.642492 C616.118737,375.167545 616.118737,374.397578 615.643789,373.922955 L612.718565,371 Z" id="Fill-2"></path>
</g>
</g>
</svg>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="4px" height="15px" viewBox="0 0 4 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 48.2 (47327) - http://www.bohemiancoding.com/sketch -->
<title>noun_880268</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="strong-rewards-notification-Main-Copy-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-2993.000000, -2985.000000)">
<g id="Group-25" transform="translate(2176.000000, 2563.000000)" fill="#9B9B9B" fill-rule="nonzero">
<g id="noun_880268" transform="translate(817.000000, 422.000000)">
<rect id="Rectangle-path" x="0.0857142857" y="0.166666667" width="3.85714286" height="3.75"></rect>
<rect id="Rectangle-path" x="0.0857142857" y="5.63888889" width="3.85714286" height="3.75"></rect>
<rect id="Rectangle-path" x="0.0857142857" y="11.0833333" width="3.85714286" height="3.75"></rect>
</g>
</g>
</g>
</svg>
ProTip! Use n and p to navigate between commits in a pull request.