PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / AutoLaunch / components / ExtendifyCodeConnector.jsx

ExtendifyCodeConnector.jsx in Extendify 3.1.5, at src/AutoLaunch/components/ExtendifyCodeConnector.jsx

88 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { ChoiceBox } from '@auto-launch/components/ChoiceBox';
2 import { buildExtendifyCodeLink } from '@auto-launch/functions/extendify-code';
3 import { checkIn } from '@auto-launch/functions/insights';
4 import { useLaunchDataStore } from '@auto-launch/state/launch-data';
5 import { useEffect } from '@wordpress/element';
6 import { __ } from '@wordpress/i18n';
7 import { arrowRight, code, external, layout } from '@wordpress/icons';
8 import { motion } from 'framer-motion';
9
10 export const ExtendifyCodeConnector = ({ onProceed }) => {
11 const { descriptionRaw, title } = useLaunchDataStore();
12 const { extendifyCodeData = {} } = window.extSharedData;
13 const { link, title: codeTitle, message, ctaPrimary } = extendifyCodeData;
14
15 const hasCodeConnectorData = link && codeTitle && message && ctaPrimary;
16
17 useEffect(() => {
18 if (!hasCodeConnectorData) {
19 onProceed();
20 return;
21 }
22 checkIn({
23 stage: 'extendify_code_screen_seen',
24 description: descriptionRaw || title,
25 });
26 }, [hasCodeConnectorData, onProceed, descriptionRaw, title]);
27
28 if (!hasCodeConnectorData) return null;
29
30 const goToWordPress = () => {
31 checkIn({ stage: 'extendify_code_choose_wordpress' });
32 onProceed();
33 };
34
35 const goToBuilder = () => {
36 const url = buildExtendifyCodeLink(link, {
37 description: descriptionRaw,
38 title,
39 });
40 checkIn({ stage: 'extendify_code_choose_builder' });
41 if (url) window.location.assign(url);
42 };
43
44 return (
45 <motion.div
46 animate={{ opacity: 1 }}
47 exit={{ opacity: 0 }}
48 transition={{ duration: 0.4 }}
49 className="flex w-full flex-col gap-6"
50 >
51 <div className="flex flex-col items-center gap-2 text-center text-banner-text">
52 <h2 className="m-0 p-0 text-pretty text-xl font-semibold md:text-2xl">
53 {__('How would you like to build this?', 'extendify-local')}
54 </h2>
55 <p className="m-0 max-w-xl p-0 text-pretty text-sm opacity-70 md:text-base">
56 {__(
57 'Based on what you described, your site may need some advanced functionality.',
58 'extendify-local',
59 )}
60 </p>
61 </div>
62 <div className="grid w-full gap-6 sm:mx-auto sm:max-w-2xl sm:grid-cols-2 sm:pt-7">
63 <ChoiceBox
64 icon={layout}
65 heading={__('Keep building with WordPress', 'extendify-local')}
66 description={__(
67 'Great for business sites, e-commerces, landing pages, portfolios, and blogs.',
68 'extendify-local',
69 )}
70 buttonLabel={__('Build with WordPress', 'extendify-local')}
71 buttonIcon={arrowRight}
72 onClick={goToWordPress}
73 />
74 <ChoiceBox
75 icon={code}
76 highlight
77 badgeLabel={__('Recommended for you', 'extendify-local')}
78 heading={codeTitle}
79 description={message}
80 buttonLabel={ctaPrimary}
81 buttonIcon={external}
82 onClick={goToBuilder}
83 />
84 </div>
85 </motion.div>
86 );
87 };
88