2023-09-06 06:21:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Button } from '@wordpress/components';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { ProgressBar } from '@woocommerce/components';
|
|
|
|
import { useState } from '@wordpress/element';
|
2023-11-10 06:51:00 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2023-09-06 06:21:09 +00:00
|
|
|
|
2023-08-29 06:00:54 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-09-07 09:05:47 +00:00
|
|
|
import { Look, designWithAiStateMachineContext } from '../types';
|
2023-09-06 06:21:09 +00:00
|
|
|
import { Choice } from '../components/choice/choice';
|
|
|
|
import { CloseButton } from '../components/close-button/close-button';
|
|
|
|
import { aiWizardClosedBeforeCompletionEvent } from '../events';
|
|
|
|
|
|
|
|
export type lookAndFeelCompleteEvent = {
|
|
|
|
type: 'LOOK_AND_FEEL_COMPLETE';
|
2023-09-07 09:05:47 +00:00
|
|
|
payload: Look;
|
2023-09-06 06:21:09 +00:00
|
|
|
};
|
2023-08-29 06:00:54 +00:00
|
|
|
|
|
|
|
export const LookAndFeel = ( {
|
|
|
|
sendEvent,
|
|
|
|
context,
|
|
|
|
}: {
|
2023-09-06 06:21:09 +00:00
|
|
|
sendEvent: (
|
|
|
|
event: lookAndFeelCompleteEvent | aiWizardClosedBeforeCompletionEvent
|
|
|
|
) => void;
|
2023-08-29 06:00:54 +00:00
|
|
|
context: designWithAiStateMachineContext;
|
|
|
|
} ) => {
|
2023-09-06 06:21:09 +00:00
|
|
|
const choices = [
|
|
|
|
{
|
|
|
|
title: __( 'Contemporary', 'woocommerce' ),
|
2023-09-07 09:05:47 +00:00
|
|
|
key: 'Contemporary' as const,
|
2023-09-06 06:21:09 +00:00
|
|
|
subtitle: __(
|
2023-12-14 11:32:37 +00:00
|
|
|
'Clean lines, neutral colors, sleek and modern look.',
|
2023-09-06 06:21:09 +00:00
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Classic', 'woocommerce' ),
|
2023-09-07 09:05:47 +00:00
|
|
|
key: 'Classic' as const,
|
2023-09-06 06:21:09 +00:00
|
|
|
subtitle: __(
|
2023-11-07 01:28:56 +00:00
|
|
|
'Elegant and timeless with a nostalgic touch.',
|
2023-09-06 06:21:09 +00:00
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: __( 'Bold', 'woocommerce' ),
|
2023-09-07 09:05:47 +00:00
|
|
|
key: 'Bold' as const,
|
2023-09-06 06:21:09 +00:00
|
|
|
subtitle: __(
|
2023-11-07 01:28:56 +00:00
|
|
|
'Vibrant with eye-catching colors and visuals.',
|
2023-09-06 06:21:09 +00:00
|
|
|
'woocommerce'
|
|
|
|
),
|
|
|
|
},
|
|
|
|
];
|
2023-09-07 09:05:47 +00:00
|
|
|
const [ look, setLook ] = useState< Look >(
|
2023-09-06 06:21:09 +00:00
|
|
|
context.lookAndFeel.choice === ''
|
2023-09-07 09:05:47 +00:00
|
|
|
? choices[ 0 ].key
|
2023-09-06 06:21:09 +00:00
|
|
|
: context.lookAndFeel.choice
|
|
|
|
);
|
2023-11-10 06:51:00 +00:00
|
|
|
|
2023-08-29 06:00:54 +00:00
|
|
|
return (
|
|
|
|
<div>
|
2023-09-06 06:21:09 +00:00
|
|
|
<ProgressBar
|
|
|
|
percent={ 60 }
|
|
|
|
color={ 'var(--wp-admin-theme-color)' }
|
|
|
|
bgcolor={ 'transparent' }
|
|
|
|
/>
|
|
|
|
<CloseButton
|
|
|
|
onClick={ () => {
|
|
|
|
sendEvent( {
|
|
|
|
type: 'AI_WIZARD_CLOSED_BEFORE_COMPLETION',
|
|
|
|
payload: { step: 'look-and-feel' },
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
<div className="woocommerce-cys-design-with-ai-look-and-feel woocommerce-cys-layout">
|
|
|
|
<div className="woocommerce-cys-page">
|
|
|
|
<h1>
|
|
|
|
{ __(
|
|
|
|
'How would you like your store to look?',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</h1>
|
|
|
|
<div className="choices">
|
2023-09-07 09:05:47 +00:00
|
|
|
{ choices.map( ( { title, subtitle, key } ) => {
|
2023-09-06 06:21:09 +00:00
|
|
|
return (
|
|
|
|
<Choice
|
2023-09-07 09:05:47 +00:00
|
|
|
key={ key }
|
2023-09-06 06:21:09 +00:00
|
|
|
name="user-profile-choice"
|
|
|
|
title={ title }
|
|
|
|
subtitle={ subtitle }
|
2023-09-07 09:05:47 +00:00
|
|
|
selected={ look === key }
|
|
|
|
value={ key }
|
|
|
|
onChange={ ( _key ) => {
|
|
|
|
setLook( _key as Look );
|
2023-09-06 06:21:09 +00:00
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} ) }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
onClick={ () => {
|
2023-11-10 06:51:00 +00:00
|
|
|
if (
|
|
|
|
context.lookAndFeel.aiRecommended &&
|
|
|
|
context.lookAndFeel.aiRecommended !== look
|
|
|
|
) {
|
|
|
|
recordEvent(
|
|
|
|
'customize_your_store_ai_wizard_changed_ai_option',
|
|
|
|
{
|
|
|
|
step: 'look-and-feel',
|
|
|
|
ai_recommended:
|
|
|
|
context.lookAndFeel.aiRecommended,
|
|
|
|
user_choice: look,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-09-06 06:21:09 +00:00
|
|
|
sendEvent( {
|
|
|
|
type: 'LOOK_AND_FEEL_COMPLETE',
|
|
|
|
payload: look,
|
|
|
|
} );
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ __( 'Continue', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-29 06:00:54 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|