PluginProbe
Extendify / 3.0.4
Extendify v3.0.4
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.0.4, at src/AutoLaunch/LaunchPage.jsx

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