import { Fragment } from '@wordpress/element' import { __ } from '@wordpress/i18n' import classNames from 'classnames' import { colord } from 'colord' import { useGlobalStore } from '../state/Global' const steps = { 'site-type': { step: __('Site Industry', 'extendify'), title: __("Let's Start Building Your Website", 'extendify'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with the Launch in the core WordPress editor.', 'extendify', ), buttonText: __('Select Site Industry', 'extendify'), }, goals: { step: __('Goals', 'extendify'), title: __('Continue Building Your Website', 'extendify'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with the Launch in the core WordPress editor.', 'extendify', ), buttonText: __('Select Site Goals', 'extendify'), }, style: { step: __('Design', 'extendify'), title: __('Continue Building Your Website', 'extendify'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with the Launch in the core WordPress editor.', 'extendify', ), buttonText: __('Select Site Design', 'extendify'), }, pages: { step: __('Pages', 'extendify'), title: __('Continue Building Your Website', 'extendify'), description: __( 'Create a super-fast, beautiful, and fully customized site in minutes with the Launch in the core WordPress editor.', 'extendify', ), buttonText: __('Select Site Pages', 'extendify'), }, confirmation: { step: __('Launch', 'extendify'), title: __("Let's Launch Your Site", 'extendify'), description: __( "You're one step away from creating a super-fast, beautiful, and fully customizable site with the Launch in the core WordPress editor.", 'extendify', ), buttonText: __('Launch The Site', 'extendify'), }, } export const AdminNotice = () => { const noticeKey = 'extendify-launch' const { isDismissed, dismissNotice } = useGlobalStore() // To avoid content flash, we load in this partial piece of state early via php const dismissed = window.extAssistData.dismissedNotices.find( (notice) => notice.id === noticeKey, ) if (dismissed || isDismissed(noticeKey)) return null const pageData = JSON.parse(localStorage.getItem('extendify-pages') ?? null) if (!pageData) return null // Filter out pages that don't match step keys const pages = pageData?.state?.availablePages.filter((p) => Object.keys(steps).includes(p), ) // If their last step doesn't exist in our options, just use step 1 const lastStep = pageData?.state?.currentPageSlug const currentStep = Object.keys(steps).includes(lastStep) ? lastStep : 'site-type' let reached = false // Compute the color based on the active admin menu item color const bgColor = window.getComputedStyle( document.querySelector('a.wp-has-current-submenu'), )['background-color'] ?? '#3858e9' const bgDarker = colord(bgColor).darken(0.05).toHex() return (