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
Drop the button for a dismissible card instead.
  • Loading branch information
kwight committed Feb 21, 2020
commit a040c14c3c40b7280671380ed53ed2aedf91dfd7
28 changes: 15 additions & 13 deletions client/my-sites/customer-home/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,38 @@
}

&__welcome-banner {
.card {
@include breakpoint( '>1040px' ) {
@include display-grid;
@include grid-template-columns( 12, 24px, 1fr );
padding: 0;
}
@include breakpoint( '>1040px' ) {
@include display-grid;
@include grid-template-columns( 12, 24px, 1fr );
padding: 0;
}

.card img {
img {
margin: 0 33%;
@include breakpoint( '>1040px' ) {
@include grid-column( 2, 2 );
margin: 0;
padding: 24px 0;
position: relative;
top: 6px;
}

}

.card div {
div {
@include breakpoint( '>1040px' ) {
@include grid-column( 5, 8 );
padding: 24px 24px 24px 0;
}
display: flex;
flex-direction: column;
justify-content: center;

.card-heading {
margin-top: 0;
.card-heading {
margin-top: 0;
}
}

p {
margin-bottom: 0;
}
}
}

Expand Down
90 changes: 32 additions & 58 deletions client/my-sites/customer-home/welcome-banner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,46 @@
*/
import React from 'react';
import { connect } from 'react-redux';
import { Card, Button } from '@automattic/components';
import DismissibleCard from 'blocks/dismissible-card';
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';
import { bumpStat, composeAnalytics, recordTracksEvent } from 'state/analytics/actions';

export const WelcomeBanner = ( {
translate,
fetchingPreferences,
bannerDismissed,
dismissBanner,
} ) => {
export const WelcomeBanner = ( { translate, recordStats } ) => {
return (
<>
<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>
) }
</>
<DismissibleCard
kwight marked this conversation as resolved.
Show resolved Hide resolved
className="customer-home__welcome-banner"
preferenceName="home-welcome-banner-dismissed"
onClick={ recordStats }
>
<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>
</div>
</DismissibleCard>
);
};

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 ) );
export default connect( null, dispatch => ( {
recordStats: () =>
dispatch(
composeAnalytics(
recordTracksEvent( 'calypso_home_welcome_banner_dismiss' ),
bumpStat( 'calypso-home-welcome-banner', 'dismiss' )
)
),
} ) )( localize( WelcomeBanner ) );