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

Customer Home: Add a welcome banner. #39557

Merged
merged 8 commits into from
Feb 21, 2020
Prev Previous commit
Next Next commit
Wire up button and add stats.
  • Loading branch information
kwight committed Feb 21, 2020
commit e9e0038d4db0db4cb09ab9bd308f19aeebb67577
2 changes: 1 addition & 1 deletion client/my-sites/customer-home/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Home extends Component {
</div>
</Card>
) }
{ <WelcomeBanner /> }
<WelcomeBanner />
</>
);
}
Expand Down
77 changes: 57 additions & 20 deletions client/my-sites/customer-home/welcome-banner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,73 @@
* External dependencies
*/
import React from 'react';
import { connect } from 'react-redux';
import { Card, Button } from '@automattic/components';
import { localize } from 'i18n-calypso';

/**
* Internal dependencies
*/
import CardHeading from 'components/card-heading';
import {
bumpStat,
composeAnalytics,
recordTracksEvent,
withAnalytics,
} from 'state/analytics/actions';
import { savePreference } from 'state/preferences/actions';
import QueryPreferences from 'components/data/query-preferences';
import { isFetchingPreferences, getPreference } from 'state/preferences/selectors';

export const WelcomeBanner = ( { translate } ) => {
export const WelcomeBanner = ( {
translate,
fetchingPreferences,
bannerDismissed,
dismissBanner,
} ) => {
return (
<div className="customer-home__welcome-banner">
<Card>
<img
src="/calypso/images/extensions/woocommerce/woocommerce-setup.svg"
aria-hidden="true"
alt=""
/>
<div>
<CardHeading>{ translate( 'Learn and grow with My Home' ) }</CardHeading>
<p>
{ translate(
'This is your new home for quick links to common tasks, easy access to support, and guidance ' +
'tailored to you. We’ll keep improving what you see here to help you learn and grow with us.'
) }
</p>
<Button>{ translate( 'Got it!' ) }</Button>
<>
<QueryPreferences />
{ ! fetchingPreferences && ! bannerDismissed && (
<div className="customer-home__welcome-banner">
<Card>
<img
src="/calypso/images/extensions/woocommerce/woocommerce-setup.svg"
aria-hidden="true"
alt=""
/>
<div>
<CardHeading>{ translate( 'Learn and grow with My Home' ) }</CardHeading>
<p>
{ translate(
'This is your new home for quick links to common tasks, easy access to support, and guidance ' +
'tailored to you. We’ll keep improving what you see here to help you learn and grow with us.'
) }
</p>
<Button onClick={ dismissBanner }>{ translate( 'Got it!' ) }</Button>
</div>
</Card>
</div>
</Card>
</div>
) }
</>
);
};

export default localize( WelcomeBanner );
export default connect(
state => ( {
bannerDismissed: getPreference( state, 'home-welcome-banner-dismissed' ),
fetchingPreferences: isFetchingPreferences( state ),
} ),
dispatch => ( {
dismissBanner: () =>
dispatch(
withAnalytics(
composeAnalytics(
recordTracksEvent( 'calypso_home_welcome_banner_dismiss' ),
bumpStat( 'calypso-home-welcome-banner', 'dismiss' )
),
savePreference( 'home-welcome-banner-dismissed', true )
)
),
} )
)( localize( WelcomeBanner ) );