PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 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 All 127 releases
extendify / src / AutoLaunch / LaunchPage.jsx

LaunchPage.jsx in Extendify 3.1.0, at src/AutoLaunch/LaunchPage.jsx

150 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Launch } from '@auto-launch/components/Launch';
2 import { Logo } from '@auto-launch/components/Logo';
3 import { MovingGradient } from '@auto-launch/components/MovingGradients';
4 import { NeedsTheme } from '@auto-launch/components/NeedsTheme';
5 import { RestartLaunchModal } from '@auto-launch/components/RestartLaunchModal';
6 import { ViewportPulse } from '@auto-launch/components/ViewportPulse';
7 import { preLaunchFunctions } from '@auto-launch/functions/setup';
8 import { updateOption } from '@auto-launch/functions/wp';
9 import { useLaunchDataStore } from '@auto-launch/state/launch-data';
10 import { registerCoreBlocks } from '@wordpress/block-library';
11 import { getBlockTypes } from '@wordpress/blocks';
12 import { useSelect } from '@wordpress/data';
13 import { useEffect, useRef } from '@wordpress/element';
14 import { __ } from '@wordpress/i18n';
15 import { chevronLeft, Icon } from '@wordpress/icons';
16 import { AnimatePresence, motion } from 'framer-motion';
17 import { checkIn } from './functions/insights';
18
19 export const LaunchPage = () => {
20 const theme = useSelect((select) => select('core').getCurrentTheme());
21 // Checking `theme` here makes sure the data is populated
22 const needsTheme = theme && theme?.textdomain !== 'extendable';
23
24 const oldPages = window.extLaunchData.resetSiteInformation.pagesIds ?? [];
25 const needsToReset = oldPages.length > 0;
26
27 const { title, descriptionRaw, go, urlParams, designBuild } =
28 useLaunchDataStore();
29 const skipDescription =
30 Boolean(urlParams?.['build-id']) ||
31 designBuild ||
32 ((title || descriptionRaw) && go);
33
34 const containerRef = useRef(null);
35
36 useEffect(() => {
37 // translators: Launch is a noun.
38 document.title = __('Launch - AI-Powered Web Creation', 'extendify-local');
39 updateOption('extendify_launch_loaded', new Date().toISOString());
40 // We load core blocks so we can parse them
41 if (getBlockTypes().length === 0) registerCoreBlocks();
42
43 preLaunchFunctions();
44 checkIn({ stage: 'launch_page' });
45 }, []);
46
47 if (needsTheme) {
48 return (
49 <Wrapper>
50 <div className="bg-white w-full max-w-3xl rounded-lg border border-design-main/60 relative z-10">
51 <NeedsTheme />
52 </div>
53 </Wrapper>
54 );
55 }
56
57 if (needsToReset) {
58 return (
59 <Wrapper>
60 <div className="w-full max-w-2xl rounded-3xl border bg-gray-100/80 backdrop-blur-2xl shadow-md relative z-10 border-gray-300">
61 <RestartLaunchModal pages={oldPages} />
62 </div>
63 </Wrapper>
64 );
65 }
66
67 return (
68 <Wrapper>
69 <AnimatePresence mode="wait" initial={false}>
70 <TheTitle skipDescription={skipDescription} />
71 </AnimatePresence>
72 <div ref={containerRef} className="w-full max-w-2xl relative z-10">
73 <AnimatePresence mode="wait">
74 <Launch
75 key={skipDescription ? 'description-launch' : 'creating-launch'}
76 skipDescription={skipDescription}
77 lastHeight={containerRef.current?.offsetHeight}
78 />
79 </AnimatePresence>
80 </div>
81 {skipDescription ||
82 window.extLaunchData?.hideAutoLaunchExitLink ? null : (
83 <div className="flex w-full p-6 md:p-8 absolute bottom-0 left-0">
84 <a
85 className="inline-flex items-center gap-0.5 text-sm text-banner-text opacity-70 hover:opacity-100 transition-opacity p-2"
86 href={window.extSharedData.adminUrl}
87 onClick={() => checkIn({ stage: 'exit_to_wp_admin' })}
88 >
89 <Icon fill="currentColor" icon={chevronLeft} size={20} />
90 {__('WP Admin Dashboard', 'extendify-local')}
91 </a>
92 </div>
93 )}
94 </Wrapper>
95 );
96 };
97
98 const Wrapper = ({ children }) => {
99 const { pulse } = useLaunchDataStore();
100
101 return (
102 <div style={{ zIndex: 99999 + 1 }} className="fixed inset-0 bg-white">
103 <div className="relative h-dvh bg-banner-main text-banner-text text-base flex flex-col items-center justify-between">
104 <div className="relative w-full flex flex-col items-center gap-5 md:gap-8 p-6 pb-25 flex-1 justify-center">
105 <div className="mb-4">
106 <Logo />
107 </div>
108 {children}
109 </div>
110 </div>
111 <MovingGradient />
112 {pulse ? <ViewportPulse /> : null}
113 </div>
114 );
115 };
116
117 const TheTitle = ({ skipDescription }) => {
118 if (skipDescription) return null;
119
120 const headingClass =
121 'text-xl md:text-2xl text-pretty text-banner-text font-semibold p-0 m-0 text-center';
122 const transition = {
123 animate: { opacity: 1 },
124 exit: { opacity: 0 },
125 transition: { duration: 0.4 },
126 };
127
128 if (window.extLaunchData?.activeTests?.['AutoLaunch.WebsiteTitle'] === 'B') {
129 return (
130 <motion.div className="flex flex-col items-center gap-2" {...transition}>
131 <h2 className={headingClass}>
132 {__('Tell Us About Your Website', 'extendify-local')}
133 </h2>
134 <p className="text-sm md:text-base text-pretty text-banner-text opacity-70 p-0 m-0 text-center max-w-xl">
135 {__(
136 "Share your vision, and we'll craft a website that's perfectly tailored to your needs, ready to launch in no time.",
137 'extendify-local',
138 )}
139 </p>
140 </motion.div>
141 );
142 }
143
144 return (
145 <motion.h2 className={headingClass} {...transition}>
146 {__('Describe the website you want to build', 'extendify-local')}
147 </motion.h2>
148 );
149 };
150