/** * External dependencies */ import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; import { Button } from '@wordpress/components'; import { getNewPath } from '@woocommerce/navigation'; import interpolateComponents from '@automattic/interpolate-components'; import { Link } from '@woocommerce/components'; /** * Internal dependencies */ import { Intro } from '.'; import { IntroSiteIframe } from './intro-site-iframe'; import { getAdminSetting } from '~/utils/admin-settings'; import { navigateOrParent } from '../utils'; import { trackEvent } from '../tracking'; export const BaseIntroBanner = ( { bannerTitle, bannerText, bannerClass, showAIDisclaimer, buttonIsLink, bannerButtonOnClick, bannerButtonText, secondaryButton, previewBanner, children, }: { bannerTitle: string; bannerText: string; bannerClass: string; showAIDisclaimer: boolean; buttonIsLink?: boolean; bannerButtonOnClick?: () => void; bannerButtonText?: string; secondaryButton?: React.ReactNode; previewBanner?: React.ReactNode; children?: React.ReactNode; } ) => { return (

{ bannerTitle }

{ bannerText }

{ bannerButtonText && ( ) } { secondaryButton } { showAIDisclaimer && (

{ interpolateComponents( { mixedString: __( 'Powered by experimental AI. {{link}}Learn more{{/link}}', 'woocommerce' ), components: { link: ( ), }, } ) }

) }
{ children }
{ previewBanner }
); }; export const NetworkOfflineBanner = () => { return ( {} } showAIDisclaimer={ true } /> ); }; export const JetpackOfflineBanner = ( { sendEvent, }: { sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ]; } ) => { return ( { sendEvent( { type: 'JETPACK_OFFLINE_HOWTO', } ); } } bannerButtonText={ __( 'Find out how', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const ExistingThemeBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { return ( { setOpenDesignChangeWarningModal( true ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const DefaultBanner = ( { sendEvent, }: { sendEvent: React.ComponentProps< typeof Intro >[ 'sendEvent' ]; } ) => { return ( { sendEvent( { type: 'DESIGN_WITH_AI', } ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const ThemeHasModsBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { return ( { setOpenDesignChangeWarningModal( true ); } } bannerButtonText={ __( 'Design with AI', 'woocommerce' ) } showAIDisclaimer={ true } /> ); }; export const NoAIBanner = ( { redirectToCYSFlow, }: { redirectToCYSFlow: () => void; } ) => { return ( <> { redirectToCYSFlow(); } } showAIDisclaimer={ false } /> ); }; export const ExistingAiThemeBanner = ( { setOpenDesignChangeWarningModal, }: { setOpenDesignChangeWarningModal: ( arg0: boolean ) => void; } ) => { const secondaryButton = ( ); const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { trackEvent( 'customize_your_store_intro_customize_click' ); navigateOrParent( window, getNewPath( { customizing: true }, '/customize-store/assembler-hub', {} ) ); } } bannerButtonText={ __( 'Customize', 'woocommerce' ) } secondaryButton={ secondaryButton } showAIDisclaimer={ true } >
); }; export const ExistingNoAiThemeBanner = () => { const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { trackEvent( 'customize_your_store_intro_customize_click', { theme_type: 'block', } ); navigateOrParent( window, getNewPath( { customizing: true }, '/customize-store/assembler-hub', {} ) ); } } bannerButtonText={ __( 'Customize your store', 'woocommerce' ) } showAIDisclaimer={ false } previewBanner={ } > ); }; export const ClassicThemeBanner = () => { const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { trackEvent( 'customize_your_store_intro_customize_click', { theme_type: 'classic', } ); navigateOrParent( window, 'customize.php?return=/wp-admin/themes.php' ); } } bannerButtonText={ __( 'Go to the Customizer', 'woocommerce' ) } showAIDisclaimer={ false } previewBanner={ } > ); }; export const NonDefaultBlockThemeBanner = () => { const siteUrl = getAdminSetting( 'siteUrl' ) + '?cys-hide-admin-bar=1'; return ( { trackEvent( 'customize_your_store_intro_customize_click', { theme_type: 'block', } ); navigateOrParent( window, 'site-editor.php' ); } } bannerButtonText={ __( 'Go to the Editor', 'woocommerce' ) } showAIDisclaimer={ false } previewBanner={ } > ); };