Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add Feedback Prompt in Cart & Checkout blocks sidebar #1356

Merged
merged 16 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 24 additions & 13 deletions assets/js/blocks/cart-checkout/cart/block.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
/**
* External dependencies
*/
import { BlockControls } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
import { Toolbar } from '@wordpress/components';
import { Fragment, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import TextToolbarButton from '@woocommerce/block-components/text-toolbar-button';

/**
* Internal dependencies
*/
import FullCart from './components/full-cart';
import EmptyCart from './components/empty-cart';
import FeedbackPrompt from '../feedback-prompt';

const getInspectorControls = () => {
return (
<InspectorControls>
<FeedbackPrompt
text={ __(
'We are currently working on improving our cart and providing merchants with tools and options to customize their cart to their stores needs.',
'woo-gutenberg-products-block'
) }
/>
</InspectorControls>
);
};

/**
* Component to handle edit mode of "Cart Block".
Expand All @@ -25,23 +39,19 @@ const Cart = () => {

const getBlockControls = () => {
return (
<BlockControls className='wc-block-cart-toolbar'>
<BlockControls className="wc-block-cart-toolbar">
<Toolbar>
<TextToolbarButton
onClick={ toggleFullCartMode }
isToggled={ isFullCartMode }>
{ __(
'Full Cart',
'woo-gutenberg-products-block'
) }
isToggled={ isFullCartMode }
>
{ __( 'Full Cart', 'woo-gutenberg-products-block' ) }
</TextToolbarButton>
<TextToolbarButton
onClick={ toggleFullCartMode }
isToggled={ ! isFullCartMode }>
{ __(
'Empty Cart',
'woo-gutenberg-products-block'
) }
isToggled={ ! isFullCartMode }
>
{ __( 'Empty Cart', 'woo-gutenberg-products-block' ) }
</TextToolbarButton>
</Toolbar>
</BlockControls>
Expand All @@ -53,6 +63,7 @@ const Cart = () => {
return (
<Fragment>
{ getBlockControls() }
{ getInspectorControls() }
{ cart }
</Fragment>
);
Expand Down
21 changes: 21 additions & 0 deletions assets/js/blocks/cart-checkout/checkout/edit.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import { Disabled } from '@wordpress/components';

/**
* Internal dependencies
*/
import FeedbackPrompt from '../feedback-prompt';

/**
* Internal dependencies
*/
import Block from './block.js';
import './editor.scss';

const getInspectorControls = () => {
return (
<InspectorControls>
<FeedbackPrompt
text={ __(
'We are currently working on improving our checkout and providing merchants with tools and options to customize their checkout to their stores needs.',
'woo-gutenberg-products-block'
) }
/>
</InspectorControls>
);
};

const Edit = ( { attributes } ) => {
const { className } = attributes;

return (
<div className={ className }>
{ getInspectorControls() }
<Disabled>
<Block attributes={ attributes } />
</Disabled>
Expand Down
44 changes: 44 additions & 0 deletions assets/js/blocks/cart-checkout/feedback-prompt/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import PropTypes from 'prop-types';
import Gridicon from 'gridicons';

/**
* Internal dependencies
*/
import './style.scss';

/**
* Component to render a Feedback prompt in the sidebar.
*/
const FeedbackPrompt = ( { text } ) => {
return (
<div className="wc-block-feedback-prompt">
<Gridicon icon="comment" />
<h2 className="wc-block-feedback-prompt__title">
{ __( 'Feedback?', 'woo-gutenberg-products-block' ) }
</h2>
<p className="wc-block-feedback-prompt__text">{ text }</p>
<a
href="https://wordpress.org/support/plugin/woo-gutenberg-products-block/reviews/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we verified this is where we want feedback to go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK it's not decided yet, so I added this link as a placeholder. I was planning to ask @garymurray when he comes back from AFK. For now, I added a @todo comment so we don't forget about it (b88391a).

className="wc-block-feedback-prompt__link"
rel="noreferrer noopener"
target="_blank"
>
{ __(
'Give us your feedback.',
'woo-gutenberg-products-block'
) }
<Gridicon icon="external" size={ 16 } />
</a>
</div>
);
};

FeedbackPrompt.propTypes = {
text: PropTypes.string,
};

export default FeedbackPrompt;
19 changes: 19 additions & 0 deletions assets/js/blocks/cart-checkout/feedback-prompt/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.wc-block-feedback-prompt {
background-color: #f7f7f7;
border-top: 1px solid #e2e4e7;
margin: $gap -16px -16px;
padding: $gap-large;
text-align: center;

.wc-block-feedback-prompt__title {
margin: 0 0 $gap-small;
}

.wc-block-feedback-prompt__link {
color: inherit;

> .gridicon {
vertical-align: text-bottom;
}
}
}