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

My plan: Add checklist progress banner #12277

Merged
merged 21 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions _inc/client/components/data/query-checklist-progress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';

/**
* Internal dependencies
*/
import { isLoading } from 'state/checklist/selectors';
import { requestSiteChecklist } from 'state/checklist/actions';

class QuerySiteChecklist extends Component {
static propTypes = {
requestSiteChecklist: PropTypes.func,
isLoading: PropTypes.bool,
};

componentDidMount() {
if ( ! this.props.isLoading ) {
this.props.requestSiteChecklist();
}
}

render() {
return null;
}
}

export default connect(
state => ( {
isLoading: isLoading( state ),
} ),
{ requestSiteChecklist }
)( QuerySiteChecklist );
13 changes: 13 additions & 0 deletions _inc/client/components/screen-reader-text/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* External dependencies
*/
import React from 'react';

/**
* Relies on WordPress core styling via "screen-reader-text" class:
* https://make.wordpress.org/accessibility/handbook/markup/the-css-class-screen-reader-text/
*/

export default function ScreenReaderText( { children } ) {
return <span className="screen-reader-text">{ children }</span>;
}
53 changes: 53 additions & 0 deletions _inc/client/my-plan/checklist-progress-card/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* External dependencies
*/
import { translate as __ } from 'i18n-calypso';
import React from 'react';
import { connect } from 'react-redux';

/**
* Internal dependencies
*/
import Button from 'components/button';
import Card from 'components/card';
import ProgressBar from './progress-bar';
import QueryChecklistProgress from 'components/data/query-checklist-progress';
sirreal marked this conversation as resolved.
Show resolved Hide resolved
import { getSiteRawUrl } from 'state/initial-state';
import { getChecklistCompletion } from 'state/checklist/selectors';

function ChecklistProgressCard( { completed, total, siteSlug } ) {
return (
<>
<QueryChecklistProgress />
{ completed && total && (
<Card compact className="checklist__header">
<div className="checklist__header-main">
<div className="checklist__header-progress">
<span className="checklist__header-progress-text">
{ __( 'Your Jetpack setup progress', {
comment: 'Onboarding task list progress',
} ) }
</span>
<span className="checklist__header-progress-number">{ `${ completed }/${ total }` }</span>
</div>
<ProgressBar total={ total } value={ completed } />
</div>
<div className="checklist__header-secondary">
<Button compact primary href={ `https://wordpress.com/plans/my-plan/${ siteSlug }` }>
jeherve marked this conversation as resolved.
Show resolved Hide resolved
{ __( 'Complete Jetpack Setup', {
comment: 'Text on link to list of onboarding tasks',
} ) }
</Button>
</div>
</Card>
) }
</>
);
}

export default connect( state => {
return {
siteSlug: getSiteRawUrl( state ),
...getChecklistCompletion( state ), // add completed and total
};
} )( ChecklistProgressCard );
43 changes: 43 additions & 0 deletions _inc/client/my-plan/checklist-progress-card/progress-bar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import classnames from 'classnames';

/**
* Internal dependencies
*/
import ScreenReaderText from 'components/screen-reader-text';

export default class ProgressBar extends PureComponent {
static defaultProps = {
total: 100,
};

static propTypes = {
value: PropTypes.number.isRequired,
total: PropTypes.number,
title: PropTypes.string,
className: PropTypes.string,
};

render() {
const classes = classnames( this.props.className, 'checklist-header-progress-bar' );
const percentage = Math.min( Math.ceil( ( this.props.value / this.props.total ) * 100 ), 100 );
const title = this.props.title ? (
<ScreenReaderText>{ this.props.title }</ScreenReaderText>
) : null;

return (
<div className={ classes }>
<div
className="checklist-header-progress-bar__progress"
style={ { width: percentage + '%' } }
>
{ title }
</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.progress-bar {
sirreal marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
display: inline-block;
position: relative;
height: 9px;
background-color: $muriel-gray-100;
border-radius: 4.5px;

&.is-compact {
height: 4px;
}
}

.progress-bar__progress {
display: inline-block;
position: absolute;
top: 0;
left: 0;
height: 100%;
background-color: $muriel-blue-500;
border-radius: 4.5px;
transition: width 200ms;
}

.progress-bar.is-pulsing .progress-bar__progress {
animation: jetpack_progress-bar-animation 3300ms infinite linear;

background-size: 50px 100%;
background-image: linear-gradient(
-45deg,
$muriel-blue-500 28%,
$muriel-blue-300 28%,
$muriel-blue-300 72%,
$muriel-blue-500 72%
);
}

@keyframes jetpack_progress-bar-animation {
0% {
background-position: 100px 0;
}
}

/* Percentage bar */
.percentage-bar {
border-radius: 0;
height: 8px;
width: 150px;
.progress-bar__progress {
border-radius: 0;
}
}
122 changes: 122 additions & 0 deletions _inc/client/my-plan/checklist-progress-card/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.checklist__header {
display: flex;
flex-direction: row;

&-main {
display: flex;
flex: 1 1;
flex-direction: column;
align-items: stretch;
}

&-secondary {
display: flex;
flex: 2 1;
flex-direction: row;
align-items: center;
justify-content: flex-end;
}

&-progress {
display: flex;
flex-direction: row;
font-size: 14px;
white-space: nowrap;
margin-bottom: 5px;
}

&-progress-text {
display: flex;
flex: 1 1;
margin: 0;
color: $muriel-gray-500;
}

&-progress-number {
display: flex;
color: $muriel-gray-500;
padding-left: 1em;
}

&-summary {
font-size: 12px;
line-height: 24px;
color: $muriel-gray-500;
cursor: pointer;
}

&-action {
position: absolute;
top: 0;
right: 0;
width: 48px;
height: 100%;
border-left: 1px solid $muriel-gray-0;
cursor: pointer;

.gridicon {
fill: $muriel-gray-300;
vertical-align: middle;
align-items: center;
transition: transform 0.15s cubic-bezier( 0.175, 0.885, 0.32, 1.275 ), color 0.2s ease-in;
}

.checklist.is-expanded & {
.gridicon {
transform: rotate( 180deg );
}
}

.accessible-focus &:focus {
box-shadow: inset 0 0 0 2px $muriel-blue-300;
}
}

.checklist.is-expanded &-action {
.gridicon {
transform: rotate( 180deg );
}
}

.dops-button.is-primary {
margin-right: 0;
background: $green-primary;
border-color: $green-secondary;
sirreal marked this conversation as resolved.
Show resolved Hide resolved

&:focus {
box-shadow: 0 0 0 2px lighten( $green-secondary, 20% );
}
}
}

@media ( max-width: 600px ) {
.checklist__header {
display: block;

&-secondary {
display: block;
text-align: left;
padding-top: 15px;
}
}
}

.checklist-header-progress-bar {
width: 100%;
display: inline-block;
position: relative;
background-color: $muriel-gray-100;
border-radius: 4.5px;
height: 4px;
}

.checklist-header-progress-bar__progress {
display: inline-block;
position: absolute;
top: 0;
left: 0;
height: 100%;
background-color: $muriel-hot-green-400;
border-radius: 4.5px;
transition: width 200ms;
}
8 changes: 7 additions & 1 deletion _inc/client/my-plan/my-plan-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { connect } from 'react-redux';
*/
import { imagePath } from 'constants/urls';
import { getUpgradeUrl, showBackups } from 'state/initial-state';
import ChecklistProgress from './checklist-progress-card';

class MyPlanHeader extends React.Component {
trackLearnMore = () => {
Expand Down Expand Up @@ -135,7 +136,12 @@ class MyPlanHeader extends React.Component {
);
break;
}
return <div>{ planCard }</div>;
return (
<>
sirreal marked this conversation as resolved.
Show resolved Hide resolved
<div>{ planCard }</div>
<ChecklistProgress />
</>
);
}
}
export default connect( state => {
Expand Down
2 changes: 2 additions & 0 deletions _inc/client/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@import 'functions/rem';

// Variables
@import '../../../node_modules/@automattic/calypso-color-schemes/src/__color-studio/color-variables.scss';
sirreal marked this conversation as resolved.
Show resolved Hide resolved
@import 'variables/colors';
@import 'variables/layout';

Expand Down Expand Up @@ -46,6 +47,7 @@
@import '../components/apps-card/style';
@import '../components/jetpack-dialogue/style';
@import '../components/about-page/style';
@import '../my-plan/checklist-progress-card/style.scss';

// Page Templates
@import '../at-a-glance/style';
Expand Down
Loading