diff --git a/inc/class-api.php b/inc/class-api.php index 18f4992..6675d85 100644 --- a/inc/class-api.php +++ b/inc/class-api.php @@ -59,7 +59,7 @@ public function register_routes() { $namespace = $this->namespace . '/' . $this->version; $routes = array( - 'send' => array( + 'send' => array( 'methods' => \WP_REST_Server::CREATABLE, 'args' => array( 'step' => array( @@ -73,7 +73,7 @@ public function register_routes() { ), 'callback' => array( $this, 'send' ), ), - 'status' => array( + 'status' => array( 'methods' => \WP_REST_Server::READABLE, 'args' => array( 'thread_id' => array( @@ -87,11 +87,17 @@ public function register_routes() { ), 'callback' => array( $this, 'status' ), ), - 'get' => array( + 'get' => array( 'methods' => \WP_REST_Server::READABLE, + 'args' => array( + 'thread_id' => array( + 'required' => true, + 'type' => 'string', + ), + ), 'callback' => array( $this, 'get' ), ), - 'images' => array( + 'images' => array( 'methods' => \WP_REST_Server::READABLE, 'args' => array( 'query' => array( @@ -101,6 +107,16 @@ public function register_routes() { ), 'callback' => array( $this, 'images' ), ), + 'templates' => array( + 'methods' => \WP_REST_Server::READABLE, + 'args' => array( + 'thread_id' => array( + 'required' => true, + 'type' => 'string', + ), + ), + 'callback' => array( $this, 'templates' ), + ), ); foreach ( $routes as $route => $args ) { @@ -123,9 +139,10 @@ public function send( \WP_REST_Request $request ) { $data = $request->get_params(); $request = wp_remote_post( - QUICKWP_API . 'wizard/send', + QUICKWP_APP_API . 'wizard/send', array( - 'body' => array( + 'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout + 'body' => array( 'step' => $data['step'], 'message' => $data['message'], ), @@ -161,9 +178,10 @@ public function status( \WP_REST_Request $request ) { $data = $request->get_params(); $request = wp_remote_get( // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get - QUICKWP_API . 'wizard/status', + QUICKWP_APP_API . 'wizard/status', array( - 'body' => array( + 'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout + 'body' => array( 'thread_id' => $data['thread_id'], 'run_id' => $data['run_id'], ), @@ -199,9 +217,10 @@ public function get( \WP_REST_Request $request ) { $data = $request->get_params(); $request = wp_remote_get(// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get - QUICKWP_API . 'wizard/get', + QUICKWP_APP_API . 'wizard/get', array( - 'body' => array( + 'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout + 'body' => array( 'thread_id' => $data['thread_id'], ), ) @@ -225,6 +244,107 @@ public function get( \WP_REST_Request $request ) { return new \WP_REST_Response( $response, 200 ); } + /** + * Get templates. + * + * @param \WP_REST_Request $request Request. + * + * @return \WP_REST_Response + */ + public function templates( \WP_REST_Request $request ) { + $data = $request->get_params(); + + $request = wp_remote_get(// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get + QUICKWP_APP_API . 'wizard/get', + array( + 'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout + 'body' => array( + 'thread_id' => $data['thread_id'], + ), + ) + ); + + if ( is_wp_error( $request ) ) { + return new \WP_REST_Response( array( 'error' => $request->get_error_message() ), 500 ); + } + + /** + * Holds the response as a standard class object + * + * @var \stdClass $response + */ + $response = json_decode( wp_remote_retrieve_body( $request ) ); + + if ( ! isset( $response->data ) || ! $response->data ) { + return new \WP_REST_Response( array( 'error' => __( 'Error', 'quickwp' ) ), 500 ); + } + + $items = self::process_json_from_response( $response->data ); + + if ( ! $items ) { + return new \WP_REST_Response( array( 'error' => __( 'Error', 'quickwp' ) ), 500 ); + } + + $patterns_used = array(); + + foreach ( $items as $item ) { + if ( ! isset( $item['slug'] ) || ! isset( $item['order'] ) || ! isset( $item['strings'] ) ) { + continue; + } + + $patterns_used[] = array( + 'order' => $item['order'], + 'slug' => $item['slug'], + ); + + $strings = $item['strings']; + + foreach ( $strings as $string ) { + add_filter( + 'quickwp/' . $string['slug'], + function () use( $string ) { + return $string['value']; + } + ); + } + } + + usort( + $patterns_used, + function ( $a, $b ) { + return $a['order'] <=> $b['order']; + } + ); + + $theme_path = get_stylesheet_directory(); + + $filtered_patterns = array(); + + foreach ( $patterns_used as $pattern ) { + $pattern['slug'] = str_replace( 'quickwp/', '', $pattern['slug'] ); + + $pattern_path = $theme_path . '/patterns/' . $pattern['slug'] . '.php'; + + if ( ! file_exists( $pattern_path ) ) { + continue; + } + + ob_start(); + include $pattern_path; + $pattern_content = ob_get_clean(); + + $filtered_patterns[] = $pattern_content; + } + + return new \WP_REST_Response( + array( + 'status' => 'success', + 'data' => implode( '', $filtered_patterns ), + ), + 200 + ); + } + /** * Get images. * @@ -236,9 +356,10 @@ public function images( \WP_REST_Request $request ) { $data = $request->get_params(); $request = wp_remote_get(// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get - QUICKWP_API . 'wizard/images', + QUICKWP_APP_API . 'wizard/images', array( - 'body' => array( + 'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout + 'body' => array( 'query' => $data['query'], ), ) @@ -259,6 +380,45 @@ public function images( \WP_REST_Request $request ) { return new \WP_REST_Response( array( 'error' => __( 'Error', 'quickwp' ) ), 500 ); } + + return new \WP_REST_Response( $response, 200 ); } + + /** + * Get JSON from response. + * + * @param array $data Response. + * + * @return array|bool + */ + private static function process_json_from_response( $data ) { + // Find the target item. + $target = current( $data ); + + if ( false === $target ) { + // Handle the case where the target is not found. + return false; + } + + // Extract the JSON string. + $json_string = $target->content[0]->text->value; + + try { + $json_object = json_decode( $json_string, true ); + return $json_object; + } catch ( \Exception $e) { + // If parsing failed, try to find a JSON array in the string. + preg_match( '/\[(.|\n)*\]/', $json_string, $matches ); + + if ( ! empty( $matches ) ) { + $json_array_string = $matches[0]; + $json_object = json_decode( $json_array_string, true ); + + return $json_object; + } + } + + return false; + } } diff --git a/inc/class-main.php b/inc/class-main.php index 932ce52..624934c 100644 --- a/inc/class-main.php +++ b/inc/class-main.php @@ -54,18 +54,18 @@ public function enqueue_assets() { return; } - $asset_file = include QUICKWP_PATH . '/build/index.asset.php'; + $asset_file = include QUICKWP_APP_PATH . '/build/index.asset.php'; wp_enqueue_style( 'quickwp', - QUICKWP_URL . 'build/style-index.css', + QUICKWP_APP_URL . 'build/style-index.css', array( 'wp-components' ), $asset_file['version'] ); wp_enqueue_script( 'quickwp', - QUICKWP_URL . 'build/index.js', + QUICKWP_APP_URL . 'build/index.js', $asset_file['dependencies'], $asset_file['version'], true diff --git a/quickwp.php b/quickwp.php index 0509da0..7cdd387 100644 --- a/quickwp.php +++ b/quickwp.php @@ -17,13 +17,13 @@ die; } -define( 'QUICKWP_BASEFILE', __FILE__ ); -define( 'QUICKWP_URL', plugins_url( '/', __FILE__ ) ); -define( 'QUICKWP_PATH', __DIR__ ); -define( 'QUICKWP_VERSION', '1.0.0' ); -define( 'QUICKWP_API', 'https://4ab6-103-217-244-109.ngrok-free.app/api/' ); +define( 'QUICKWP_APP_BASEFILE', __FILE__ ); +define( 'QUICKWP_APP_URL', plugins_url( '/', __FILE__ ) ); +define( 'QUICKWP_APP_PATH', __DIR__ ); +define( 'QUICKWP_APP_VERSION', '1.0.0' ); +define( 'QUICKWP_APP_API', 'https://aaf0-103-217-244-105.ngrok-free.app/api/' ); -$vendor_file = QUICKWP_PATH . '/vendor/autoload.php'; +$vendor_file = QUICKWP_APP_PATH . '/vendor/autoload.php'; if ( is_readable( $vendor_file ) ) { require_once $vendor_file; diff --git a/src/components/TemplatePreview.js b/src/components/TemplatePreview.js index 26525e1..f46a698 100644 --- a/src/components/TemplatePreview.js +++ b/src/components/TemplatePreview.js @@ -1,11 +1,24 @@ +/** + * External dependencies. + */ +import classNames from 'classnames'; + /** * WordPress dependencies. */ import { BlockPreview } from '@wordpress/block-editor'; -const TemplatePreview = ({ template }) => { +const TemplatePreview = ({ + template, + canScroll = false +}) => { return ( -
+
{ const { onContinue } = useDispatch( 'quickwp/data' ); const { + globalStylesId, + defaultStyles, palette, template, hasLoaded } = useSelect( ( select ) => { const { getBlocks } = select( 'core/block-editor' ); + const { + __experimentalGetCurrentGlobalStylesId, + __experimentalGetCurrentThemeBaseGlobalStyles + } = select( 'core' ); + const { getColorPalette, getProcessStatus } = select( 'quickwp/data' ); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + return { + globalStylesId, + defaultStyles: __experimentalGetCurrentThemeBaseGlobalStyles(), palette: getColorPalette(), template: getBlocks(), hasLoaded: true === getProcessStatus( 'color_palette' ) }; }); + const { editEntityRecord } = useDispatch( 'core' ); + + useEffect( () => { + if ( hasLoaded && Boolean( palette.length ) ) { + const colorPalette = palette.map( color => { + const paletteColor = defaultStyles.settings.color.palette.theme.find( paletteColor => paletteColor.slug === color.slug ); + + if ( paletteColor ) { + return { + ...color, + name: paletteColor.name + }; + } + + return color; + }); + + const settings = { + color: { + palette: { + theme: [ + ...colorPalette + ] + } + } + }; + + editEntityRecord( 'root', 'globalStyles', globalStylesId, { + settings + }); + } + }, [ hasLoaded, palette ]); + const onSubmit = async() => { onContinue(); }; @@ -77,7 +123,10 @@ const ColorPalette = () => {
- +
); }; diff --git a/src/parts/ImageSuggestions.js b/src/parts/ImageSuggestions.js index 82c8ff4..10b1567 100644 --- a/src/parts/ImageSuggestions.js +++ b/src/parts/ImageSuggestions.js @@ -12,8 +12,10 @@ import { __ } from '@wordpress/i18n'; import { Button, + Disabled, Icon, - Spinner + Spinner, + TextControl } from '@wordpress/components'; import { @@ -23,27 +25,63 @@ import { import { useState } from '@wordpress/element'; +import { ENTER } from '@wordpress/keycodes'; + +/** + * Internal dependencies. + */ +import { requestImages } from '../utils'; + const ImageSuggestions = () => { const [ value, setValue ] = useState([]); + const [ search, setSearch ] = useState( '' ); + const [ isLoading, setIsLoading ] = useState( false ); const { images, + imageKeywords, + activeImageKeyword, hasLoaded } = useSelect( select => { const { getImages, + getImageKeywords, + getActiveImageKeyword, getProcessStatus } = select( 'quickwp/data' ); - const images = getImages() || []; + const activeImageKeyword = getActiveImageKeyword(); + + const images = getImages( activeImageKeyword ) || []; return { - images: images.slice( 0, 9 ), + images, + imageKeywords: getImageKeywords() || [], + activeImageKeyword, hasLoaded: true === getProcessStatus( 'images' ) }; }); - const { onContinue } = useDispatch( 'quickwp/data' ); + const { + onContinue, + setActiveImageKeyword + } = useDispatch( 'quickwp/data' ); + + const onSearch = async( query = search ) => { + if ( ! query || activeImageKeyword === query ) { + return; + } + + if ( query !== search ) { + setSearch( query ); + } + + setActiveImageKeyword( query ); + + setIsLoading( true ); + await requestImages( query ); + setIsLoading( false ); + }; if ( ! hasLoaded ) { return ( @@ -68,41 +106,87 @@ const ImageSuggestions = () => { -
-
- { images.map( ( image, index ) => ( -
{ - if ( value.includes( image.id ) ) { - setValue( value.filter( ( item ) => item !== image.id ) ); - } else { - setValue([ ...value, image.id ]); - } - }} - > - { value.includes( image.id ) && ( -
- -
- ) } - - -
- ) ) } +
+ { + if ( ENTER === e.keyCode ) { + onSearch(); + } + }} + disabled={ isLoading } + className="is-dark" + /> + +
+ { imageKeywords.map( ( keyword ) => { + return ( + + ); + }) }
+ + { ( isLoading ) && ( +
+ +
+ ) } + + +
+ { images.map( image => ( +
{ + if ( value.includes( image.id ) ) { + setValue( value.filter( ( item ) => item !== image.id ) ); + } else { + setValue([ ...value, image.id ]); + } + }} + > + { value.includes( image.id ) && ( +
+ +
+ ) } + + +
+ ) ) } +
+
); diff --git a/src/parts/Template.js b/src/parts/Template.js index 1b0295f..f9a4ee9 100644 --- a/src/parts/Template.js +++ b/src/parts/Template.js @@ -1,18 +1,13 @@ -/** - * External dependencies. - */ -import classNames from 'classnames'; - -import { check } from '@wordpress/icons'; - /** * WordPress dependencies. */ import { __ } from '@wordpress/i18n'; +import { parse } from '@wordpress/blocks'; + import { Button, - Icon + Spinner } from '@wordpress/components'; import { @@ -20,28 +15,39 @@ import { useSelect } from '@wordpress/data'; -import { useState } from '@wordpress/element'; - /** * Internal dependencies. */ import TemplatePreview from '../components/TemplatePreview'; -const dummy = [ 1, 2, 3, 4 ]; - const Template = () => { - const [ value, setValue ] = useState(); - const { onContinue } = useDispatch( 'quickwp/data' ); - const { template } = useSelect( ( select ) => { - const { getBlocks } = select( 'core/block-editor' ); + const { + template, + hasLoaded + } = useSelect( ( select ) => { + const { + getHomepage, + getProcessStatus + } = select( 'quickwp/data' ); + + const homepage = getHomepage(); return { - template: getBlocks() + template: homepage ? parse( homepage ) : [], + hasLoaded: true === getProcessStatus( 'homepage' ) }; }); + if ( ! hasLoaded ) { + return ( +
+ +
+ ); + } + return (
@@ -57,37 +63,10 @@ const Template = () => {
-
-
- { dummy.map( ( image, index ) => ( -
{ - setValue( value === image ? null : image ); - }} - > - { value === image && ( -
- -
- ) } - - -
- ) ) } -
-
+
); }; diff --git a/src/parts/ViewSite.js b/src/parts/ViewSite.js index d76314b..622877d 100644 --- a/src/parts/ViewSite.js +++ b/src/parts/ViewSite.js @@ -3,9 +3,51 @@ */ import { __ } from '@wordpress/i18n'; +import apiFetch from '@wordpress/api-fetch'; + import { Button } from '@wordpress/components'; +import { useDispatch } from '@wordpress/data'; + +import { downloadBlob } from '@wordpress/blob'; + + const ViewSite = () => { + const { createErrorNotice } = useDispatch( 'core/notices' ); + + async function handleExport() { + try { + const response = await apiFetch({ + path: '/wp-block-editor/v1/export', + parse: false, + headers: { + Accept: 'application/zip' + } + }); + const blob = await response.blob(); + const contentDisposition = response.headers.get( + 'content-disposition' + ); + const contentDispositionMatches = + contentDisposition.match( /=(.+)\.zip/ ); + const fileName = contentDispositionMatches[ 1 ] ? + contentDispositionMatches[ 1 ] : + 'edit-site-export'; + + downloadBlob( fileName + '.zip', blob, 'application/zip' ); + } catch ( errorResponse ) { + let error = {}; + try { + error = await errorResponse.json(); + } catch ( e ) {} + const errorMessage = + error.message && 'unknown_error' !== error.code ? + error.message : + __( 'An error occurred while creating the site export.', 'quickwp' ); + + createErrorNotice( errorMessage, { type: 'snackbar' }); + } + } return (
@@ -26,7 +68,7 @@ const ViewSite = () => {
diff --git a/src/store.js b/src/store.js index 0e263b8..5ba1295 100644 --- a/src/store.js +++ b/src/store.js @@ -10,7 +10,11 @@ import { * Internal dependencies. */ import STEPS from './steps'; -import { generateColorPalette, generateImages } from './utils'; +import { + generateColorPalette, + generateImages, + generateHomepage +} from './utils'; const DEFAULT_STATE = { step: 0, @@ -24,13 +28,21 @@ const DEFAULT_STATE = { 'thread_id': null, 'run_id': null, hasLoaded: false + }, + 'homepage': { + 'thread_id': null, + 'run_id': null, + hasLoaded: false } }, - images: [], + colorPalette: [], + images: {}, + imageKeywords: [], + activeImageKeyword: null, + homepage: null, siteTopic: null, siteDescription: null, - hasError: false, - colorPalette: [] + hasError: false }; const actions = { @@ -77,9 +89,12 @@ const actions = { case 'site_topic': generateColorPalette(); break; - case 'color_palette': + case 'site_description': + generateHomepage(); generateImages(); break; + case 'color_palette': + break; } dispatch( actions.nextStep() ); @@ -103,16 +118,35 @@ const actions = { colorPalette }; }, - setError( hasError ) { + setImages( key, images ) { return { - type: 'SET_ERROR', - hasError + type: 'SET_IMAGES', + key, + images }; }, - setImages( images ) { + setImageKeywords( imageKeywords ) { return { - type: 'SET_IMAGES', - images + type: 'SET_IMAGE_KEYWORDS', + imageKeywords + }; + }, + setActiveImageKeyword( activeImageKeyword ) { + return { + type: 'SET_ACTIVE_IMAGE_KEYWORD', + activeImageKeyword + }; + }, + setHomepage( homepage ) { + return { + type: 'SET_HOMEPAGE', + homepage + }; + }, + setError( hasError ) { + return { + type: 'SET_ERROR', + hasError }; }, setThreadID( item, threadID ) { @@ -173,7 +207,25 @@ const store = createReduxStore( 'quickwp/data', { case 'SET_IMAGES': return { ...state, - images: action.images + images: { + ...state.images, + [ action.key ]: action.images + } + }; + case 'SET_IMAGE_KEYWORDS': + return { + ...state, + imageKeywords: action.imageKeywords + }; + case 'SET_ACTIVE_IMAGE_KEYWORD': + return { + ...state, + activeImageKeyword: action.activeImageKeyword + }; + case 'SET_HOMEPAGE': + return { + ...state, + homepage: action.homepage }; case 'SET_THREAD_ID': return { @@ -228,12 +280,21 @@ const store = createReduxStore( 'quickwp/data', { getColorPalette( state ) { return state.colorPalette; }, + getImages( state, key ) { + return state.images[ key ]; + }, + getImageKeywords( state ) { + return state.imageKeywords; + }, + getActiveImageKeyword( state ) { + return state.activeImageKeyword; + }, + getHomepage( state ) { + return state.homepage; + }, hasError( state ) { return state.hasError; }, - getImages( state ) { - return state.images; - }, getThreadID( state, item ) { return state.processes[ item ]?.thread_id; }, diff --git a/src/style.scss b/src/style.scss index 850684d..65ab77c 100644 --- a/src/style.scss +++ b/src/style.scss @@ -5,12 +5,20 @@ #quickwp { --wp-admin-theme-color: #ffffff; - .components-text-control__input { - @apply bg-transparent max-w-xl border-0 h-12 text-2xl not-italic font-normal text-fg shadow-none; - } + .components-base-control { + .components-text-control__input { + @apply bg-transparent max-w-xl border-0 h-12 text-2xl not-italic font-normal text-fg shadow-none; + } + + .components-textarea-control__input { + @apply bg-transparent max-w-5xl h-24 border-0 text-2xl not-italic font-normal text-fg shadow-none resize-none; + } - .components-textarea-control__input { - @apply bg-transparent max-w-5xl h-24 border-0 text-2xl not-italic font-normal text-fg shadow-none resize-none; + &.is-dark { + .components-text-control__input { + @apply text-fg-alt bg-bg-alt h-10 w-full max-w-full text-xs p-3; + } + } } .components-text-control__input::placeholder, @@ -46,6 +54,14 @@ @apply opacity-50; } } + + &.is-token { + @apply text-xs leading-none px-4 py-2; + + &.is-active { + @apply bg-fg text-bg; + } + } } .block-editor-block-preview__content { diff --git a/src/utils.js b/src/utils.js index e4af6ed..75e3738 100644 --- a/src/utils.js +++ b/src/utils.js @@ -7,11 +7,12 @@ import { dispatch, select } from '@wordpress/data'; +import { home } from '@wordpress/icons'; import { Circle, - G, Path, + Rect, SVG } from '@wordpress/primitives'; @@ -46,21 +47,25 @@ export const PageControlIcon = ({ isFilled = false }) => { export const Logo = () => { return ( - + xmlns="http://www.w3.org/2000/svg"> + + ); }; @@ -84,9 +89,10 @@ const sendEvent = async( data ) => { const getEvent = async( type ) => { const threadID = select( 'quickwp/data' ).getThreadID( type ); + const route = 'homepage' !== type ? 'get' : 'templates'; const response = await apiFetch({ - path: addQueryArgs( `${ window.quickwp.api }/get`, { + path: addQueryArgs( `${ window.quickwp.api }/${ route }`, { 'thread_id': threadID }) }); @@ -147,13 +153,31 @@ const extractPalette = response => { const fetchImages = async( request ) => { const runID = select( 'quickwp/data' ).getRunID( 'images' ); - const { setImages } = dispatch( 'quickwp/data' ); + const { + setActiveImageKeyword, + setImageKeywords + } = dispatch( 'quickwp/data' ); const { data } = request; const target = data.find( item => item.run_id === runID ); - const query = target.content[0].text.value; + let queries = target.content[0].text.value; + + queries = queries.split( ',' ); + + queries = queries.map( query => query.trim() ); + + const query = queries[0]; + + setImageKeywords( queries ); + setActiveImageKeyword( query ); + + await requestImages( query ); +}; + +export const requestImages = async( query ) => { + const { setImages } = dispatch( 'quickwp/data' ); const response = await apiFetch({ path: addQueryArgs( `${ window.quickwp.api }/images`, { @@ -161,16 +185,15 @@ const fetchImages = async( request ) => { }) }); - - setImages( response?.photos ); + setImages( query, response?.photos ); }; -const awaitEvent = async( type ) => { +const awaitEvent = async( type, interval = 5000 ) => { const hasResolved = await getEventStatus( type ); if ( ! hasResolved ) { - await new Promise( resolve => setTimeout( resolve, 3000 ) ); - await awaitEvent( type ); + await new Promise( resolve => setTimeout( resolve, interval ) ); + await awaitEvent( type, interval ); return; } }; @@ -208,7 +231,7 @@ export const generateImages = async() => { message: siteDescription }); - await awaitEvent( 'images' ); + await awaitEvent( 'images', 10000 ); const response = await getEvent( 'images' ); @@ -216,3 +239,36 @@ export const generateImages = async() => { setProcessStatus( 'images', true ); }; + +export const generateHomepage = async() => { + const siteTopic = select( 'quickwp/data' ).getSiteTopic(); + const siteDescription = select( 'quickwp/data' ).getSiteDescription(); + + const { + setError, + setProcessStatus, + setHomepage + } = dispatch( 'quickwp/data' ); + + await sendEvent({ + step: 'homepage', + message: `Website topic: ${ siteTopic } | Website description${ siteDescription }` + }); + + await awaitEvent( 'homepage', 10000 ); + + const response = await getEvent( 'homepage' ); + + if ( 'success' !== response?.status ) { + setError( true ); + return; + } + + let homepageTemplate = ''; + homepageTemplate += ''; + homepageTemplate += response.data; + homepageTemplate += ''; + + setHomepage( homepageTemplate ); + setProcessStatus( 'homepage', true ); +}; diff --git a/tailwind.config.js b/tailwind.config.js index 1d2cde9..d048af6 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -12,7 +12,9 @@ module.exports = { colors: { bg: '#000000', fg: '#FFFFFF', - secondary: '#232323' + secondary: '#232323', + 'bg-alt': '#2F2F2F', + 'fg-alt': '#E0E0E0' }, maxHeight: { 'md': '32rem', diff --git a/tests/php/static-analysis-stubs/quickwp.php b/tests/php/static-analysis-stubs/quickwp.php index 7f6783e..fcd5eda 100644 --- a/tests/php/static-analysis-stubs/quickwp.php +++ b/tests/php/static-analysis-stubs/quickwp.php @@ -5,8 +5,8 @@ * Adds QuickWP constants for PHPStan to use. */ -define( 'QUICKWP_BASEFILE', __FILE__ ); -define( 'QUICKWP_URL', plugins_url( '/', __FILE__ ) ); -define( 'QUICKWP_PATH', dirname( __FILE__ ) ); -define( 'QUICKWP_VERSION', '1.0.0' ); -define( 'QUICKWP_API', 'quickwp/v1' ); \ No newline at end of file +define( 'QUICKWP_APP_BASEFILE', __FILE__ ); +define( 'QUICKWP_APP_URL', plugins_url( '/', __FILE__ ) ); +define( 'QUICKWP_APP_PATH', dirname( __FILE__ ) ); +define( 'QUICKWP_APP_VERSION', '1.0.0' ); +define( 'QUICKWP_APP_API', 'quickwp/v1' ); \ No newline at end of file