2019-12-16 14:59:16 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-02-01 16:54:38 +00:00
|
|
|
import { Icon, commentContent, external } from '@wordpress/icons';
|
2022-08-12 14:23:08 +00:00
|
|
|
import { useEffect, useState } from '@wordpress/element';
|
2019-12-16 14:59:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2023-06-21 16:02:19 +00:00
|
|
|
interface FeedbackPromptProps {
|
|
|
|
text: string;
|
|
|
|
title?: string;
|
2023-12-01 13:01:42 +00:00
|
|
|
url: string;
|
2023-06-21 16:02:19 +00:00
|
|
|
}
|
2019-12-16 14:59:16 +00:00
|
|
|
/**
|
|
|
|
* Component to render a Feedback prompt in the sidebar.
|
2020-09-20 23:54:08 +00:00
|
|
|
*
|
2022-12-05 12:46:50 +00:00
|
|
|
* @param {Object} props Incoming props for the component.
|
2020-09-20 23:54:08 +00:00
|
|
|
* @param {string} props.text
|
2022-12-05 12:46:50 +00:00
|
|
|
* @param {string} props.title
|
2020-09-20 23:54:08 +00:00
|
|
|
* @param {string} props.url
|
2019-12-16 14:59:16 +00:00
|
|
|
*/
|
2020-08-09 20:18:36 +00:00
|
|
|
const FeedbackPrompt = ( {
|
|
|
|
text,
|
2023-12-12 22:12:36 +00:00
|
|
|
title = __( 'Feedback?', 'woocommerce' ),
|
2023-12-01 13:01:42 +00:00
|
|
|
url,
|
2023-06-21 16:02:19 +00:00
|
|
|
}: FeedbackPromptProps ) => {
|
2022-08-12 14:23:08 +00:00
|
|
|
// By returning false we ensure that this component is not entered into the InspectorControls
|
|
|
|
// (which is a slot fill), children array on first render, on the second render when the state
|
|
|
|
// gets updated this component does get put into the InspectorControls children array but as the
|
|
|
|
// last item, ensuring it shows last in the sidebar.
|
|
|
|
const [ isVisible, setIsVisible ] = useState( false );
|
|
|
|
useEffect( () => {
|
|
|
|
setIsVisible( true );
|
|
|
|
}, [] );
|
|
|
|
|
2019-12-16 14:59:16 +00:00
|
|
|
return (
|
2023-06-21 16:02:19 +00:00
|
|
|
<>
|
|
|
|
{ isVisible && (
|
|
|
|
<div className="wc-block-feedback-prompt">
|
|
|
|
<Icon icon={ commentContent } />
|
|
|
|
<h2 className="wc-block-feedback-prompt__title">
|
|
|
|
{ title }
|
|
|
|
</h2>
|
|
|
|
<p className="wc-block-feedback-prompt__text">{ text }</p>
|
|
|
|
<a
|
|
|
|
href={ url }
|
|
|
|
className="wc-block-feedback-prompt__link"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
target="_blank"
|
|
|
|
>
|
2023-12-12 23:05:20 +00:00
|
|
|
{ __( 'Give us your feedback.', 'woocommerce' ) }
|
2023-06-21 16:02:19 +00:00
|
|
|
<Icon icon={ external } size={ 16 } />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
</>
|
2019-12-16 14:59:16 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default FeedbackPrompt;
|
2020-08-09 20:18:36 +00:00
|
|
|
|
|
|
|
export const CartCheckoutFeedbackPrompt = () => (
|
|
|
|
<FeedbackPrompt
|
|
|
|
text={ __(
|
|
|
|
'We are currently working on improving our cart and checkout blocks to provide merchants with the tools and customization options they need.',
|
2023-12-12 22:12:36 +00:00
|
|
|
'woocommerce'
|
2020-08-09 20:18:36 +00:00
|
|
|
) }
|
2023-12-01 10:16:57 +00:00
|
|
|
url="https://github.com/woocommerce/woocommerce/discussions/new?category=checkout-flow&labels=type%3A+product%20feedback"
|
2022-01-05 18:18:23 +00:00
|
|
|
/>
|
|
|
|
);
|
2022-12-05 12:46:50 +00:00
|
|
|
|
|
|
|
export const ProductQueryFeedbackPrompt = () => (
|
|
|
|
<FeedbackPrompt
|
|
|
|
text={ __(
|
|
|
|
'Thanks for trying out the Products block! Help us make it better by sharing your feedback.',
|
2023-12-12 22:12:36 +00:00
|
|
|
'woocommerce'
|
2022-12-05 12:46:50 +00:00
|
|
|
) }
|
2023-12-12 22:12:36 +00:00
|
|
|
title={ __( 'Share your feedback!', 'woocommerce' ) }
|
2022-12-05 12:46:50 +00:00
|
|
|
url={ 'https://airtable.com/shrFX5FAqmCY6hVYI' }
|
|
|
|
/>
|
|
|
|
);
|
2023-07-05 08:34:25 +00:00
|
|
|
|
|
|
|
export const ProductCollectionFeedbackPrompt = () => (
|
|
|
|
<FeedbackPrompt
|
|
|
|
text={ __(
|
|
|
|
'Thanks for trying out the Product Collection block! Help us make it better by sharing your feedback.',
|
2023-12-12 22:12:36 +00:00
|
|
|
'woocommerce'
|
2023-07-05 08:34:25 +00:00
|
|
|
) }
|
2023-12-12 22:12:36 +00:00
|
|
|
title={ __( 'Share your feedback!', 'woocommerce' ) }
|
2023-07-05 08:34:25 +00:00
|
|
|
url={ 'https://airtable.com/shrqsMSDPvAKoY99u' }
|
|
|
|
/>
|
|
|
|
);
|