| 1 |
import { useEffect, useRef } from '@wordpress/element' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import { updateOption } from '@onboarding/api/WPApi' |
| 4 |
import { PageLayout } from '@onboarding/layouts/PageLayout' |
| 5 |
import { usePagesStore } from '@onboarding/state/Pages' |
| 6 |
import { pageState } from '@onboarding/state/factory' |
| 7 |
|
| 8 |
export const state = pageState('Welcome', () => ({ |
| 9 |
title: __('Welcome', 'extendify'), |
| 10 |
default: undefined, |
| 11 |
ready: true, |
| 12 |
isDefault: () => true, |
| 13 |
})) |
| 14 |
export const Landing = () => { |
| 15 |
const nextPage = usePagesStore((state) => state.nextPage) |
| 16 |
const continueButton = useRef(null) |
| 17 |
|
| 18 |
useEffect(() => { |
| 19 |
const raf = requestAnimationFrame(() => continueButton.current.focus()) |
| 20 |
return () => cancelAnimationFrame(raf) |
| 21 |
}, [continueButton]) |
| 22 |
|
| 23 |
const handleSkipLaunch = async (e) => { |
| 24 |
e.preventDefault() |
| 25 |
|
| 26 |
// Store when Launch is skipped. |
| 27 |
await updateOption( |
| 28 |
'extendify_onboarding_skipped', |
| 29 |
new Date().toISOString(), |
| 30 |
) |
| 31 |
|
| 32 |
location.href = window.extOnbData.adminUrl |
| 33 |
} |
| 34 |
|
| 35 |
return ( |
| 36 |
<PageLayout> |
| 37 |
<div> |
| 38 |
<h1 className="text-3xl text-partner-primary-text mb-4 mt-0"> |
| 39 |
{__('Welcome to Your WordPress Site', 'extendify')} |
| 40 |
</h1> |
| 41 |
<p className="text-base opacity-70 mb-0"> |
| 42 |
{__( |
| 43 |
'Design and launch your site with this guided experience, or head right into the WordPress dashboard if you know your way around.', |
| 44 |
'extendify', |
| 45 |
)} |
| 46 |
</p> |
| 47 |
</div> |
| 48 |
<div> |
| 49 |
<h2 className="text-lg m-0 mb-4 text-gray-900"> |
| 50 |
{__('Pick one:', 'extendify')} |
| 51 |
</h2> |
| 52 |
<div className="xl:flex xl:gap-x-6"> |
| 53 |
<button |
| 54 |
onClick={nextPage} |
| 55 |
ref={continueButton} |
| 56 |
type="button" |
| 57 |
aria-label={__('Press to continue', 'extendify')} |
| 58 |
className="button-card max-w-sm button-focus mb-6 xl:mb-0"> |
| 59 |
<div |
| 60 |
className="bg-gray-100 w-full h-64 bg-cover bg-center border border-gray-200" |
| 61 |
style={{ |
| 62 |
backgroundImage: `url(${window.extOnbData.pluginUrl}/public/assets/extendify-preview.png)`, |
| 63 |
}} |
| 64 |
/> |
| 65 |
<p className="font-bold text-lg text-gray-900"> |
| 66 |
Extendify Launch |
| 67 |
</p> |
| 68 |
<p className="text-base text-gray-900"> |
| 69 |
{__( |
| 70 |
'Create a super-fast, beautiful, and fully customized site in minutes. Simply answer a few questions and pick a design to get started. Then, everything can be fully customized in the core WordPress editor.', |
| 71 |
'extendify', |
| 72 |
)} |
| 73 |
</p> |
| 74 |
</button> |
| 75 |
<a |
| 76 |
onClick={(e) => handleSkipLaunch(e)} |
| 77 |
className="button-card max-w-sm button-focus"> |
| 78 |
<div |
| 79 |
className="bg-gray-100 w-full h-64 bg-cover bg-center border border-gray-200" |
| 80 |
style={{ |
| 81 |
backgroundImage: `url(${window.extOnbData.pluginUrl}/public/assets/wp-admin.png)`, |
| 82 |
}} |
| 83 |
/> |
| 84 |
<p className="font-bold text-lg text-gray-900"> |
| 85 |
{__('WordPress Dashboard', 'extendify')} |
| 86 |
</p> |
| 87 |
<p className="text-base text-gray-900"> |
| 88 |
{__( |
| 89 |
'Are you a WordPress developer and want to go straight to the admin dashboard?', |
| 90 |
'extendify', |
| 91 |
)} |
| 92 |
</p> |
| 93 |
</a> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
</PageLayout> |
| 97 |
) |
| 98 |
} |
| 99 |
|