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

[Jetpack App Migration] Update App Banner Branding #67013

Merged
merged 26 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5a9f107
Create separate banners for the WP and JP apps
Aug 25, 2022
b628afe
Clean up: readability spacing, delete stray return
Aug 25, 2022
342472b
Add lottie-web as a dependency, for animations
Aug 25, 2022
ad5b7f2
Update wording in banner's buttons for clarity
Aug 25, 2022
4de9246
Remove circles in background from Jetpack banner
Aug 25, 2022
5feb2d3
Add animated icon to Jetpack app banner
Aug 25, 2022
4972b9b
Replace 'react-lottie-player' for performance
Aug 27, 2022
8e94544
Use stripped back version of lottie dependency
Aug 27, 2022
faddc8f
Style Jerpack banner
Aug 27, 2022
889a31a
Rename component for clarity
Aug 27, 2022
02511ed
Update Android intents for Jetpack app
Aug 27, 2022
f11dbaf
Remove additional, unwanted padding
Aug 27, 2022
3110f6e
Add RTL versions of animated icons
Aug 27, 2022
0eb4baf
Merge branch 'trunk' into update/app-banner-branding
Aug 29, 2022
a0aac12
Styling tweaks to Jetpack app banner
Aug 30, 2022
9f44d20
Android deep links: Update intent URI for Jetpack
Aug 30, 2022
0242520
Merge branch 'trunk' into update/app-banner-branding
Aug 30, 2022
6c7a31f
Fix broken unit tests by installing canvas
Aug 30, 2022
0f6ba29
Make code more concise
Aug 31, 2022
28730f1
Replace hook with HOC, for easier usage in class
Aug 31, 2022
e385f51
Separate the Jetpack and WordPress banners
Aug 31, 2022
b86c13e
List dependency for useEffect hook
Sep 1, 2022
51b4302
Avoid possible memory leak by destroying animation
Sep 1, 2022
4b4f68a
Use 'compose' to group component wrappers
Sep 1, 2022
606c625
Update text width/styling for smaller screens
Sep 1, 2022
d9ac75e
Replace 'canvas' with 'jest-canvas-mock'
Sep 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 85 additions & 12 deletions client/blocks/app-banner/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import config from '@automattic/calypso-config';
import { Button, Card } from '@automattic/components';
import classNames from 'classnames';
import { localize } from 'i18n-calypso';
import { localize, withRtl } from 'i18n-calypso';
import { get } from 'lodash';
import lottie from 'lottie-web/build/player/lottie_light';
noahtallen marked this conversation as resolved.
Show resolved Hide resolved
import PropTypes from 'prop-types';
import { Component } from 'react';
import { Component, useEffect } from 'react';
import ReactDom from 'react-dom';
import { connect } from 'react-redux';
import TrackComponentView from 'calypso/lib/analytics/track-component-view';
Expand Down Expand Up @@ -121,16 +123,22 @@ export class AppBanner extends Component {
const { currentRoute, currentSection } = this.props;

if ( this.isAndroid() ) {
const displayJetpackAppBranding = config.isEnabled( 'jetpack/app-branding' );
const scheme = displayJetpackAppBranding ? 'jetpack' : 'wordpress';
const packageName = displayJetpackAppBranding
? 'com.jetpack.android'
: 'org.wordpress.android';

//TODO: update when section deep links are available.
switch ( currentSection ) {
case GUTENBERG:
return 'intent://post/#Intent;scheme=wordpress;package=org.wordpress.android;end';
return `intent://post/#Intent;scheme=${ scheme };package=${ packageName };end`;
case NOTES:
return 'intent://notifications/#Intent;scheme=wordpress;package=org.wordpress.android;end';
return `intent://notifications/#Intent;scheme=${ scheme };package=${ packageName };end`;
case READER:
return 'intent://read/#Intent;scheme=wordpress;package=org.wordpress.android;end';
return `intent://read/#Intent;scheme=${ scheme };package=${ packageName };end`;
case STATS:
return 'intent://stats/#Intent;scheme=wordpress;package=org.wordpress.android;end';
return `intent://stats/#Intent;scheme=${ scheme };package=${ packageName };end`;
}
}

Expand All @@ -141,12 +149,51 @@ export class AppBanner extends Component {
return null;
}

render() {
const { translate, currentSection } = this.props;
if ( ! this.props.shouldDisplayAppBanner || this.state.isDraftPostModalShown ) {
return null;
}
getJetpackAppBanner = ( { translate, currentSection, isRtl } ) => {
const { title, copy, icon } = getAppBannerData( translate, currentSection, isRtl );

return (
<div className={ classNames( 'app-banner-overlay' ) } ref={ this.preventNotificationsClose }>
<Card
className={ classNames( 'app-banner', 'is-compact', currentSection, 'jetpack' ) }
ref={ this.preventNotificationsClose }
>
<TrackComponentView
eventName="calypso_mobile_app_banner_impression"
eventProperties={ {
page: currentSection,
} }
statGroup="calypso_mobile_app_banner"
statName="impression"
/>
<BannerIcon icon={ icon } />
<div className="app-banner__text-content jetpack">
<div className="app-banner__title jetpack">
<span> { title } </span>
</div>
<div className="app-banner__copy jetpack">
<span> { copy } </span>
</div>
</div>
<div className="app-banner__buttons jetpack">
<Button
primary
className="app-banner__open-button jetpack"
onClick={ this.openApp }
href={ this.getDeepLink() }
>
{ translate( 'Open in the Jetpack app' ) }
</Button>
<Button className="app-banner__no-thanks-button jetpack" onClick={ this.dismiss }>
{ translate( 'Continue in browser' ) }
</Button>
</div>
</Card>
</div>
);
};

getWordpressAppBanner = ( { translate, currentSection } ) => {
const { title, copy } = getAppBannerData( translate, currentSection );

return (
Expand Down Expand Up @@ -190,9 +237,35 @@ export class AppBanner extends Component {
</Card>
</div>
);
};

render() {
if ( ! this.props.shouldDisplayAppBanner || this.state.isDraftPostModalShown ) {
return null;
}

const displayJetpackAppBranding = config.isEnabled( 'jetpack/app-branding' );

return displayJetpackAppBranding
? this.getJetpackAppBanner( this.props )
: this.getWordpressAppBanner( this.props );
}
}

function BannerIcon( { icon } ) {
useEffect( () => {
lottie.loadAnimation( {
container: document.querySelector( '.app-banner__icon' ),
renderer: 'svg',
loop: false,
autoplay: true,
path: icon,
} );
SiobhyB marked this conversation as resolved.
Show resolved Hide resolved
}, [] );
SiobhyB marked this conversation as resolved.
Show resolved Hide resolved

return <div className="app-banner__icon"></div>;
}

export function getiOSDeepLink( currentRoute, currentSection ) {
const baseURI = 'https://apps.wordpress.com/get?campaign=calypso-open-in-app';
const fragment = buildDeepLinkFragment( currentRoute, currentSection );
Expand Down Expand Up @@ -274,4 +347,4 @@ const mapDispatchToProps = {
dismissAppBanner,
};

export default connect( mapStateToProps, mapDispatchToProps )( localize( AppBanner ) );
export default connect( mapStateToProps, mapDispatchToProps )( withRtl( localize( AppBanner ) ) );
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 46 additions & 0 deletions client/blocks/app-banner/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ body.app-banner-is-visible {
margin-bottom: 0;
box-shadow: 3px -2px 24px 4px rgba( 0, 0, 0, 0.29 );
overflow: hidden;

&.jetpack {
color: var( --color-neutral-100 );
padding: 30px 24px;
text-align: center;
}
}

.app-banner__circle {
Expand Down Expand Up @@ -63,21 +69,46 @@ body.app-banner-is-visible {
}
}

.app-banner__icon {
height: 50px;
width: 93px;
margin: auto;
}

.app-banner__text-content {
width: 100%;

&.jetpack {
letter-spacing: -0.4px;
margin: 30px auto 0;
}
}

.app-banner__title {
/* stylelint-disable-next-line */
font-size: rem( 22px ); //typography-exception
font-family: $brand-serif;
line-height: 30px;

&.jetpack {
/* stylelint-disable-next-line */
font-size: rem( 28px ); //typography-exception
font-weight: bold;
padding: 0 30px;
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
}
}

.app-banner__copy {
margin-top: 12px;
/* stylelint-disable-next-line */
font-size: rem( 15px ); //typography-exception

&.jetpack {
/* stylelint-disable-next-line */
font-size: rem( 16px ); //typography-exception
line-height: 21px;
padding: 0 30px;
}
}

.app-banner__buttons {
Expand All @@ -90,10 +121,25 @@ body.app-banner-is-visible {
border: 0;
border-radius: 4px; /* stylelint-disable-line */
margin-right: 10px;

&.jetpack {
background-color: var( --color-jetpack );
}
}

.button.app-banner__no-thanks-button {
background: none;
border: 0;
color: var( --color-text-subtle );

&.jetpack {
color: var( --color-text );
}
}

.button.jetpack {
width: 100%;
max-width: 366px;
margin: auto;
display: block;
}
7 changes: 6 additions & 1 deletion client/blocks/app-banner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,41 @@ export const ONE_MONTH_IN_MILLISECONDS = 2419200000; // 28 days
export const TWO_WEEKS_IN_MILLISECONDS = 1209600000;
export const ONE_DAY_IN_MILLISECONDS = 86400000;

export function getAppBannerData( translate, sectionName ) {
export function getAppBannerData( translate, sectionName, isRTL ) {
switch ( sectionName ) {
case GUTENBERG:
return {
title: translate( 'Rich mobile publishing.' ),
copy: translate(
'A streamlined editor with faster, simpler image uploading? Check and mate.'
),
icon: `/calypso/animations/app-promo/wp-to-jp${ isRTL ? '-rtl' : '' }.json`,
};
case NOTES:
return {
title: translate( 'Watch engagement happening.' ),
copy: translate(
'Is your new post a hit? With push notifications, see reactions as they roll in.'
),
icon: `/calypso/animations/app-promo/jp-notifications${ isRTL ? '-rtl' : '' }.json`,
};
case READER:
return {
title: translate( 'Read posts, even offline.' ),
copy: translate( 'Catch up with new posts on the go or save them to read offline.' ),
icon: `/calypso/animations/app-promo/jp-reader${ isRTL ? '-rtl' : '' }.json`,
};
case STATS:
return {
title: translate( 'Stats at your fingertips.' ),
copy: translate( 'See your real-time stats anytime, anywhere.' ),
icon: `/calypso/animations/app-promo/jp-stats${ isRTL ? '-rtl' : '' }.json`,
};
default:
return {
title: '',
copy: '',
icon: '',
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"i18n-calypso": "workspace:^",
"i18n-calypso-cli": "workspace:^",
"lodash": "^4.17.21",
"lottie-web": "^5.9.6",
"photon": "workspace:^",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down Expand Up @@ -219,6 +220,7 @@
"@wordpress/eslint-plugin": "^12.3.0",
"babel-loader": "^8.2.3",
"bunyan": "^1.8.15",
"canvas": "^2.9.3",
noahtallen marked this conversation as resolved.
Show resolved Hide resolved
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
"capture-website": "^1.0.0",
"chalk": "^4.1.2",
"check-node-version": "^4.0.2",
Expand Down
Loading