PluginProbe
Extendify / 3.1.1
Extendify v3.1.1
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.1, at src/AutoLaunch/LaunchPage.jsx

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