2021-02-22 18:40:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { Guide } from '@wordpress/components';
|
|
|
|
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
import { Text } from '@woocommerce/experimental';
|
2024-06-13 02:39:21 +00:00
|
|
|
import { useState } from '@wordpress/element';
|
2021-02-22 18:40:44 +00:00
|
|
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2021-03-02 23:24:02 +00:00
|
|
|
import NavInto1 from './images/nav-intro-1.png';
|
|
|
|
import NavInto2 from './images/nav-intro-2.png';
|
|
|
|
import NavInto3 from './images/nav-intro-3.png';
|
2021-02-22 18:40:44 +00:00
|
|
|
|
2021-03-09 22:53:24 +00:00
|
|
|
export const INTRO_MODAL_DISMISSED_OPTION_NAME =
|
2021-02-22 18:40:44 +00:00
|
|
|
'woocommerce_navigation_intro_modal_dismissed';
|
|
|
|
|
|
|
|
export const IntroModal = () => {
|
|
|
|
const [ isOpen, setOpen ] = useState( true );
|
|
|
|
|
|
|
|
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
|
|
|
|
|
2024-06-13 02:39:21 +00:00
|
|
|
const { isDismissed, isResolving } = useSelect( ( select ) => {
|
|
|
|
const { getOption, isResolving: isOptionResolving } =
|
|
|
|
select( OPTIONS_STORE_NAME );
|
|
|
|
const dismissedOption = getOption( INTRO_MODAL_DISMISSED_OPTION_NAME );
|
2021-02-22 18:40:44 +00:00
|
|
|
|
2024-06-13 02:39:21 +00:00
|
|
|
return {
|
|
|
|
isDismissed: dismissedOption === 'yes',
|
|
|
|
isResolving:
|
|
|
|
typeof dismissedOption === 'undefined' ||
|
|
|
|
isOptionResolving( 'getOption', [
|
|
|
|
INTRO_MODAL_DISMISSED_OPTION_NAME,
|
|
|
|
] ),
|
|
|
|
};
|
|
|
|
} );
|
2021-02-22 18:40:44 +00:00
|
|
|
|
|
|
|
const dismissModal = () => {
|
|
|
|
updateOptions( {
|
|
|
|
[ INTRO_MODAL_DISMISSED_OPTION_NAME ]: 'yes',
|
|
|
|
} );
|
|
|
|
recordEvent( 'navigation_intro_modal_close', {} );
|
|
|
|
setOpen( false );
|
|
|
|
};
|
|
|
|
|
2024-06-13 02:39:21 +00:00
|
|
|
if ( ! isOpen || isDismissed || isResolving ) {
|
2021-02-22 18:40:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const getPage = ( title, description, imageUrl ) => {
|
|
|
|
return {
|
|
|
|
content: (
|
|
|
|
<div className="woocommerce-navigation-intro-modal__page-wrapper">
|
|
|
|
<div className="woocommerce-navigation-intro-modal__page-text">
|
2021-06-28 01:14:59 +00:00
|
|
|
<Text
|
|
|
|
variant="title.large"
|
|
|
|
as="h2"
|
|
|
|
size="32"
|
|
|
|
lineHeight="40px"
|
|
|
|
>
|
2021-02-22 18:40:44 +00:00
|
|
|
{ title }
|
|
|
|
</Text>
|
2021-06-28 01:14:59 +00:00
|
|
|
<Text
|
|
|
|
as="p"
|
|
|
|
variant="body.large"
|
|
|
|
size="16"
|
|
|
|
lineHeight="24px"
|
|
|
|
>
|
|
|
|
{ description }
|
|
|
|
</Text>
|
2021-02-22 18:40:44 +00:00
|
|
|
</div>
|
|
|
|
<div className="woocommerce-navigation-intro-modal__image-wrapper">
|
|
|
|
<img alt={ title } src={ imageUrl } />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Guide
|
|
|
|
className="woocommerce-navigation-intro-modal"
|
|
|
|
onFinish={ dismissModal }
|
|
|
|
pages={ [
|
|
|
|
getPage(
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'A new navigation for WooCommerce', 'woocommerce' ),
|
2021-02-22 18:40:44 +00:00
|
|
|
__(
|
|
|
|
'All of your store management features in one place',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
2021-03-02 23:24:02 +00:00
|
|
|
NavInto1
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
|
|
|
getPage(
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'Focus on managing your store', 'woocommerce' ),
|
2021-02-22 18:40:44 +00:00
|
|
|
__(
|
|
|
|
'Give your attention to key areas of WooCommerce with little distraction',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
2021-03-02 23:24:02 +00:00
|
|
|
NavInto2
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
|
|
|
getPage(
|
|
|
|
__(
|
|
|
|
'Easily find and favorite your extensions',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
|
|
|
__(
|
|
|
|
"They'll appear in the top level of the navigation for quick access",
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
2021-03-02 23:24:02 +00:00
|
|
|
NavInto3
|
2021-02-22 18:40:44 +00:00
|
|
|
),
|
|
|
|
] }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|