selectCustomColor( 'secondary' ) }
+ onClick={ () => selectCustomColor( 'secondary' ) }
+ onKeyDown={ () => selectCustomColor( 'secondary' ) }
+ role="button"
+ tabIndex={ paletteCount + 3 }
>
selectCustomColor( 'tertiary' ) }
+ onClick={ () => selectCustomColor( 'tertiary' ) }
+ onKeyDown={ () => selectCustomColor( 'tertiary' ) }
+ role="button"
+ tabIndex={ paletteCount + 4 }
>
{
@@ -490,6 +511,9 @@ const DesignColors = () => {
setShowColorPicker( false ) }
+ role="button"
+ tabIndex={ 0 }
+ onKeyDown={ () => setShowColorPicker( false ) }
>
X
diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js
index 821655848..ba020515a 100644
--- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js
+++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js
@@ -3,13 +3,13 @@ import { useState, useEffect } from '@wordpress/element';
import { useLocation } from 'react-router-dom';
import { store as nfdOnboardingStore } from '../../../store';
import { getPatterns } from '../../../utils/api/patterns';
-import { LivePreviewSkeleton, LivePreviewSelectableCard } from '../../../components/LivePreview';
+import {
+ LivePreviewSkeleton,
+ LivePreviewSelectableCard,
+} from '../../../components/LivePreview';
import { setFlow } from '../../../utils/api/flow';
-import {
- THEME_STATUS_ACTIVE,
- THEME_STATUS_INIT,
-} from '../../../../constants';
+import { THEME_STATUS_ACTIVE, THEME_STATUS_INIT } from '../../../../constants';
const DesignHeaderMenu = () => {
const headerMenuSlugs = [
@@ -28,28 +28,39 @@ const DesignHeaderMenu = () => {
const [ selectedPattern, setSelectedPattern ] = useState( '' );
const location = useLocation();
- const { currentStep, currentData, themeStatus, storedPreviewSettings } = useSelect( ( select ) => {
- return {
- currentStep: select( nfdOnboardingStore ).getStepFromPath(
- location.pathname
- ),
- currentData:
- select( nfdOnboardingStore ).getCurrentOnboardingData(),
- themeStatus: select( nfdOnboardingStore ).getThemeStatus(),
- storedPreviewSettings: select( nfdOnboardingStore ).getStepPreviewData(),
- };
- }, [] );
-
- const { setCurrentOnboardingData, updateThemeStatus, setHeaderMenuData } = useDispatch( nfdOnboardingStore );
+ const { currentStep, currentData, themeStatus, storedPreviewSettings } =
+ useSelect( ( select ) => {
+ return {
+ currentStep: select( nfdOnboardingStore ).getStepFromPath(
+ location.pathname
+ ),
+ currentData:
+ select( nfdOnboardingStore ).getCurrentOnboardingData(),
+ themeStatus: select( nfdOnboardingStore ).getThemeStatus(),
+ storedPreviewSettings:
+ select( nfdOnboardingStore ).getStepPreviewData(),
+ };
+ }, [] );
+
+ const { setCurrentOnboardingData, updateThemeStatus, setHeaderMenuData } =
+ useDispatch( nfdOnboardingStore );
const getPatternsData = async () => {
+ if (
+ ! currentData.data.partHeader ||
+ currentData.data.partHeader === ''
+ ) {
+ currentData.data.partHeader = headerMenuSlugs[ 0 ];
+ setCurrentOnboardingData( currentData );
+ }
+ setSelectedPattern( currentData.data.partHeader );
+
const headerMenuPreviewResponse = await getPatterns(
currentStep.patternId
);
if ( headerMenuPreviewResponse?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
- setHeaderMenuPreviewData( headerMenuPreviewResponse.body );
const headerMenuPatterns = [];
headerMenuPreviewResponse?.body.forEach( ( pageParts ) => {
@@ -57,16 +68,9 @@ const DesignHeaderMenu = () => {
headerMenuPatterns.push( pageParts );
}
} );
- setPatterns( headerMenuPatterns );
- if (
- ! currentData.data.partHeader ||
- currentData.data.partHeader === ''
- ) {
- currentData.data.partHeader = headerMenuSlugs[ 0 ];
- setCurrentOnboardingData( currentData );
- }
- setSelectedPattern( currentData.data.partHeader );
+ setHeaderMenuPreviewData( headerMenuPreviewResponse.body );
+ setPatterns( headerMenuPatterns );
let [ pageContent, headerContent, pagePreview ] = [ '', '', '' ];
headerMenuPreviewResponse.body.forEach( ( pageParts ) => {
@@ -89,7 +93,8 @@ const DesignHeaderMenu = () => {
const handleClick = async ( idx ) => {
if ( document.getElementsByClassName( 'nfd-onboard-content' ) ) {
- document.getElementsByClassName( 'nfd-onboard-content' )[ 0 ]
+ document
+ .getElementsByClassName( 'nfd-onboard-content' )[ 0 ]
.scrollIntoView( {
behavior: 'smooth',
} );
@@ -97,6 +102,10 @@ const DesignHeaderMenu = () => {
const chosenPattern = patterns[ idx ];
+ if ( chosenPattern.slug === selectedPattern ) {
+ return true;
+ }
+
setSelectedPattern( chosenPattern.slug );
currentData.data.partHeader = chosenPattern.slug;
setCurrentOnboardingData( currentData );
@@ -120,7 +129,9 @@ const DesignHeaderMenu = () => {
return (
{
return (
{
updateThemeStatus,
} = useDispatch( nfdOnboardingStore );
- const getStylesAndPatterns = async () => {
- const patternResponse = await getPatterns(
- currentStep.patternId,
- true
- );
- if ( patternResponse?.error ) {
- return updateThemeStatus( THEME_STATUS_INIT );
+ const scrollSelectionIntoView = () => {
+ if (
+ document.getElementsByClassName(
+ 'theme-styles-preview--drawer__list__item__title-bar--selected'
+ ) &&
+ document.getElementsByClassName(
+ 'theme-styles-preview--drawer__list__item__title-bar--selected'
+ )[ 0 ]
+ ) {
+ document
+ .getElementsByClassName(
+ 'theme-styles-preview--drawer__list__item__title-bar--selected'
+ )[ 0 ]
+ .scrollIntoView( {
+ behavior: 'smooth',
+ block: 'center',
+ } );
}
+ };
+
+ const getStylesAndPatterns = async () => {
const globalStylesResponse = await getGlobalStyles( true );
if ( globalStylesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
- setPattern( patternResponse?.body );
- setGlobalStyles( globalStylesResponse?.body );
let selectedGlobalStyle;
if ( currentData.data.theme.variation ) {
selectedGlobalStyle = currentData.data.theme.variation;
@@ -66,20 +74,18 @@ const DesignThemeStylesPreview = () => {
setCurrentOnboardingData( currentData );
}
setSelectedStyle( selectedGlobalStyle );
- if (
- document.getElementsByClassName(
- 'theme-styles-preview--drawer__list__item__title-bar--selected'
- )
- ) {
- document
- .getElementsByClassName(
- 'theme-styles-preview--drawer__list__item__title-bar--selected'
- )[ 0 ]
- .scrollIntoView( {
- behavior: 'smooth',
- block: 'center',
- } );
+
+ const patternResponse = await getPatterns(
+ currentStep.patternId,
+ true
+ );
+ if ( patternResponse?.error ) {
+ return updateThemeStatus( THEME_STATUS_INIT );
}
+
+ setPattern( patternResponse?.body );
+ setGlobalStyles( globalStylesResponse?.body );
+ scrollSelectionIntoView();
};
useEffect( () => {
@@ -90,6 +96,9 @@ const DesignThemeStylesPreview = () => {
const handleClick = ( idx ) => {
const selectedGlobalStyle = globalStyles[ idx ];
+ if ( selectedStyle === selectedGlobalStyle.title ) {
+ return true;
+ }
updatePreviewSettings(
// eslint-disable-next-line react-hooks/rules-of-hooks
useGlobalStylesOutput( selectedGlobalStyle, storedPreviewSettings )
diff --git a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js
index 8f5813473..01cf6889a 100644
--- a/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js
+++ b/src/OnboardingSPA/components/Drawer/DrawerPanel/DesignTypography.js
@@ -67,6 +67,9 @@ const DesignTypography = () => {
}, [ isLoaded, themeStatus ] );
const handleClick = async ( fontStyle ) => {
+ if ( selectedFont === fontStyle ) {
+ return true;
+ }
setSelectedFont( fontStyle );
// Changes the Global Styles to Recompute css properties
diff --git a/src/OnboardingSPA/components/LivePreview/BlockPreview/auto.js b/src/OnboardingSPA/components/LivePreview/BlockPreview/auto.js
index f522e43dc..3e61e98cb 100644
--- a/src/OnboardingSPA/components/LivePreview/BlockPreview/auto.js
+++ b/src/OnboardingSPA/components/LivePreview/BlockPreview/auto.js
@@ -1,23 +1,32 @@
import { Disabled } from '@wordpress/components';
import { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';
-import { BlockList } from '@wordpress/block-editor';
-import { __unstableIframe as Iframe } from '@wordpress/block-editor';
-import { __unstableEditorStyles as EditorStyles } from '@wordpress/block-editor';
-import { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '@wordpress/block-editor';
+import { useMemo } from '@wordpress/element';
+import {
+ BlockList,
+ // eslint-disable-next-line @wordpress/no-unsafe-wp-apis
+ __unstableIframe as Iframe,
+ // eslint-disable-next-line @wordpress/no-unsafe-wp-apis
+ __unstableEditorStyles as EditorStyles,
+ // eslint-disable-next-line @wordpress/no-unsafe-wp-apis
+ __unstablePresetDuotoneFilter as PresetDuotoneFilter,
+} from '@wordpress/block-editor';
// This is used to avoid rendering the block list if the sizes change.
let MemoizedBlockList;
const MAX_HEIGHT = 6000;
-function AutoBlockPreview( {
+function ScaledBlockPreview( {
viewportWidth,
- __experimentalPadding,
- __experimentalMinHeight,
settings,
+ containerWidth,
+ minHeight,
+ additionalStyles = [],
} ) {
- const [ containerResizeListener, { width: containerWidth } ] =
- useResizeObserver();
+ if ( ! viewportWidth ) {
+ viewportWidth = containerWidth;
+ }
+
const [ contentResizeListener, { height: contentHeight } ] =
useResizeObserver();
const { styles, assets, duotone } = {
@@ -27,95 +36,108 @@ function AutoBlockPreview( {
};
// Avoid scrollbars for pattern previews.
- let editorStyles;
- if ( styles ) {
- editorStyles = [
- ...styles,
- {
- css: 'body{height:auto;overflow:hidden;}',
- __unstableType: 'presets',
- },
- ];
- } else {
- editorStyles = styles;
- }
+ const editorStyles = useMemo( () => {
+ if ( styles ) {
+ return [
+ ...styles,
+ {
+ css: 'body{height:auto;overflow:hidden;border:none;padding:0;}',
+ __unstableType: 'presets',
+ },
+ ...additionalStyles,
+ ];
+ }
+
+ return styles;
+ }, [ styles, additionalStyles ] );
- const svgFilters = [
- ...( duotone?.default ?? [] ),
- ...( duotone?.theme ?? [] ),
- ];
+ const svgFilters = useMemo( () => {
+ return [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];
+ }, [ duotone ] );
// Initialize on render instead of module top level, to avoid circular dependency issues.
MemoizedBlockList = MemoizedBlockList || pure( BlockList );
const scale = containerWidth / viewportWidth;
return (
-
- { containerResizeListener }
-
MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,
+ minHeight,
+ } }
+ >
+ }
+ assets={ assets }
+ contentRef={ useRefEffect( ( bodyElement ) => {
+ const {
+ ownerDocument: { documentElement },
+ } = bodyElement;
+ documentElement.classList.add(
+ 'block-editor-block-preview__content-iframe'
+ );
+ documentElement.style.position = 'absolute';
+ documentElement.style.width = '100%';
+
+ // necessary for contentResizeListener to work.
+ bodyElement.style.boxSizing = 'border-box';
+ bodyElement.style.position = 'absolute';
+ bodyElement.style.width = '100%';
+ bodyElement.spellcheck = 0;
+ }, [] ) }
+ aria-hidden
+ tabIndex={ -1 }
style={ {
- transform: `scale(${ scale })`,
- height: contentHeight * scale,
- maxHeight:
- contentHeight > MAX_HEIGHT
- ? MAX_HEIGHT * scale
- : undefined,
- minHeight: __experimentalMinHeight,
+ position: 'absolute',
+ width: viewportWidth,
+ height: contentHeight,
+ pointerEvents: 'none',
+ // This is a catch-all max-height for patterns.
+ // See: https://github.com/WordPress/gutenberg/pull/38175.
+ maxHeight: MAX_HEIGHT,
+ minHeight:
+ scale !== 0 && scale < 1 && minHeight
+ ? minHeight / scale
+ : minHeight,
} }
>
- }
- assets={ assets }
- contentRef={ useRefEffect( ( bodyElement ) => {
- const {
- ownerDocument: { documentElement },
- } = bodyElement;
- documentElement.classList.add(
- 'block-editor-block-preview__content-iframe'
- );
- documentElement.style.position = 'absolute';
- documentElement.style.width = '100%';
- bodyElement.style.padding =
- __experimentalPadding + 'px';
-
- // necessary for contentResizeListener to work.
- bodyElement.style.boxSizing = 'border-box';
- bodyElement.style.position = 'absolute';
- bodyElement.style.width = '100%';
- bodyElement.spellcheck = 0;
- }, [] ) }
- aria-hidden
- tabIndex={ -1 }
- style={ {
- position: 'absolute',
- width: viewportWidth,
- height: contentHeight,
- pointerEvents: 'none',
- // This is a catch-all max-height for patterns.
- // See: https://github.com/WordPress/gutenberg/pull/38175.
- maxHeight: MAX_HEIGHT,
- minHeight:
- scale !== 0 && scale < 1 && __experimentalMinHeight
- ? __experimentalMinHeight / scale
- : __experimentalMinHeight,
- } }
- >
- { contentResizeListener }
- {
- /* Filters need to be rendered before children to avoid Safari rendering issues. */
- svgFilters.map( ( preset ) => (
-
- ) )
- }
-
-
-
-
+ { contentResizeListener }
+ {
+ /* Filters need to be rendered before children to avoid Safari rendering issues. */
+ svgFilters.map( ( preset ) => (
+
+ ) )
+ }
+
+
+
);
}
-export default AutoBlockPreview;
+export default function AutoBlockPreview( props ) {
+ const [ containerResizeListener, { width: containerWidth } ] =
+ useResizeObserver();
+
+ return (
+ <>
+
+ { containerResizeListener }
+
+
+ { containerWidth && (
+
+ ) }
+
+ >
+ );
+}
diff --git a/src/OnboardingSPA/components/LivePreview/BlockPreview/index.js b/src/OnboardingSPA/components/LivePreview/BlockPreview/index.js
index 9a3c793d3..7c29930e2 100644
--- a/src/OnboardingSPA/components/LivePreview/BlockPreview/index.js
+++ b/src/OnboardingSPA/components/LivePreview/BlockPreview/index.js
@@ -8,21 +8,6 @@ import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-s
import { store as nfdOnboardingStore } from '../../../store';
import Animate from '../../Animate';
-/**
- * Renders themed WordPress block grammer.
- * [Note] Please do not remove any commented code, this will be used later to update our preview
- *
- * @param root0
- * @param root0.blockGrammer
- * @param root0.viewportWidth
- * @param root0.styling
- * @param root0.previewSettings
- * @param root0.setIsLoadingParent
- * @param root0.skeletonLoadingTime
- * @property {string} blockGrammer WordPress block grammer.
- * @property {number} viewportWidth Set viewport width for the AutoHeightBlockPreview component.
- * @property {string} styling The type of styling to be applied (small, large, custom).
- */
const BlockPreview = ( {
blockGrammer,
viewportWidth = 1300,
@@ -63,7 +48,12 @@ const BlockPreview = ( {
useEffect( () => {
if ( previewSettings ) {
setSettings(
- useGlobalStylesOutput( previewSettings, storedPreviewSettings )
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ useGlobalStylesOutput(
+ previewSettings,
+ storedPreviewSettings,
+ 'block-preview'
+ )
);
} else {
setSettings( storedPreviewSettings );
@@ -71,7 +61,9 @@ const BlockPreview = ( {
}, [] );
useEffect( () => {
- setBlocks( parse( blockGrammer ) );
+ if ( blockGrammer ) {
+ setBlocks( parse( blockGrammer ) );
+ }
}, [ blockGrammer ] );
useEffect( () => {
@@ -99,7 +91,7 @@ const BlockPreview = ( {
return (
{ loading &&
}
- { settings && (
+ { blocks && settings && (
{
} else if ( globalStyles.body[ 0 ]?.id === 0 ) {
selectedGlobalStyle = globalStyles.body[ 0 ];
}
+ updatePreviewSettings(
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ useGlobalStylesOutput(
+ selectedGlobalStyle,
+ storedPreviewSettings
+ )
+ );
}
if ( selectedGlobalStyle ) {
@@ -65,10 +72,7 @@ const GlobalStylesProvider = ( { children } ) => {
} )
);
}
- updatePreviewSettings(
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useGlobalStylesOutput( selectedGlobalStyle, storedPreviewSettings )
- );
+
setIsLoaded( true );
};
diff --git a/src/OnboardingSPA/components/LivePreview/LivePreviewSkeleton/index.js b/src/OnboardingSPA/components/LivePreview/LivePreviewSkeleton/index.js
index 037c93240..06f32f1c9 100644
--- a/src/OnboardingSPA/components/LivePreview/LivePreviewSkeleton/index.js
+++ b/src/OnboardingSPA/components/LivePreview/LivePreviewSkeleton/index.js
@@ -1,16 +1,21 @@
import { useState, useEffect } from '@wordpress/element';
+import { __ } from '@wordpress/i18n';
-import { LivePreviewSelectableCard, LivePreviewSelectableCardWithInfo } from '..';
+import {
+ LivePreviewSelectableCard,
+ LivePreviewSelectableCardWithInfo,
+} from '..';
/**
* Renders Skeletons for Live Previews.
*
- * @property {number} count The number of Live Previews to be shown
- * @property {number} watch The variable to be awaited for
- * @property {string} callback The Render function in parent to be called
- * @property {string} className The class name for the Live Preview
- * @property {number} viewportWidth Viewport Width for the Live Preview
- *
+ * @param {Object} root0 Props.
+ * @param {number} root0.count The number of Live Previews to be shown
+ * @param {number} root0.watch The variable to be awaited for
+ * @param {string} root0.callback The Render function in parent to be called
+ * @param {string} root0.className The class name for the Live Preview
+ * @param {number} root0.viewportWidth Viewport Width for the Live Preview
+ * @param {boolean} root0.isWithCard Whether the skeleton is a Card
*/
const LivePreviewSkeleton = ( {
count,
@@ -20,11 +25,10 @@ const LivePreviewSkeleton = ( {
viewportWidth,
isWithCard = false,
} ) => {
-
const MAX_ANIMATION_TIME = 600000;
- const [rerender, doRerender] = useState(0);
+ const [ rerender, doRerender ] = useState( 0 );
- useEffect(() => doRerender(1), [watch]);
+ useEffect( () => doRerender( 1 ), [ watch ] );
const buildDummyPreviews = () => {
const dummyPreviews = [];
@@ -33,7 +37,6 @@ const LivePreviewSkeleton = ( {
dummyPreviews.push(
{
const dummyPreviews = [];
- for (let i = 0; i < count; i++) {
+ for ( let i = 0; i < count; i++ ) {
dummyPreviews.push(
+ key={ i }
+ className={ className }
+ viewportWidth={ 1200 }
+ styling={ 'custom' }
+ title={ __( 'Loading…', 'wp-module-onboarding' ) }
+ description={ __( 'Loading…', 'wp-module-onboarding' ) }
+ />
);
}
return dummyPreviews;
};
- return !watch ? (isWithCard ? buildDummyPreviewsWithInfo() : buildDummyPreviews()) :
- <>
- {watch ? {rerender}
: null}
- {callback()}
- >;
+ const build = () => {
+ if ( isWithCard ) {
+ return buildDummyPreviewsWithInfo();
+ }
+ return buildDummyPreviews();
+ };
+
+ return ! watch ? (
+ build()
+ ) : (
+ <>
+ { watch ? (
+ { rerender }
+ ) : null }
+ { callback() }
+ >
+ );
};
export default LivePreviewSkeleton;
diff --git a/src/OnboardingSPA/pages/Steps/DesignColors/index.js b/src/OnboardingSPA/pages/Steps/DesignColors/index.js
index 9f2f62c72..d109bb9f4 100644
--- a/src/OnboardingSPA/pages/Steps/DesignColors/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignColors/index.js
@@ -21,10 +21,8 @@ const StepDesignColors = () => {
const location = useLocation();
const [ pattern, setPattern ] = useState();
- const { currentData, currentStep, themeStatus } = useSelect( ( select ) => {
+ const { currentStep, themeStatus } = useSelect( ( select ) => {
return {
- currentData:
- select( nfdOnboardingStore ).getCurrentOnboardingData(),
currentStep: select( nfdOnboardingStore ).getStepFromPath(
location.pathname
),
@@ -41,11 +39,14 @@ const StepDesignColors = () => {
}, [] );
const getStylesAndPatterns = async () => {
- const pattern = await getPatterns( currentStep.patternId, true );
- if ( pattern?.error ) {
+ const patternResponse = await getPatterns(
+ currentStep.patternId,
+ true
+ );
+ if ( patternResponse?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
- setPattern( pattern?.body );
+ setPattern( patternResponse?.body );
};
useEffect( () => {
@@ -65,7 +66,6 @@ const StepDesignColors = () => {
{ ! pattern && (
diff --git a/src/OnboardingSPA/pages/Steps/DesignHeaderMenu/index.js b/src/OnboardingSPA/pages/Steps/DesignHeaderMenu/index.js
index 3230f985b..43fd37b22 100644
--- a/src/OnboardingSPA/pages/Steps/DesignHeaderMenu/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignHeaderMenu/index.js
@@ -48,7 +48,6 @@ const StepDesignHeaderMenu = () => {
{ ! pattern && (
diff --git a/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js b/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js
index 847aee2a8..9d9e11ad9 100644
--- a/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js
@@ -48,25 +48,19 @@ const StepDesignHomepageMenu = () => {
const [ homepagePattern, setHomepagePattern ] = useState();
const [ selectedHomepage, setSelectedHomepage ] = useState( 0 );
- const {
- currentStep,
- currentData,
- storedPreviewSettings,
- themeStatus,
- themeVariations,
- } = useSelect( ( select ) => {
- return {
- currentStep: select( nfdOnboardingStore ).getStepFromPath(
- location.pathname
- ),
- currentData:
- select( nfdOnboardingStore ).getCurrentOnboardingData(),
- storedPreviewSettings:
- select( nfdOnboardingStore ).getPreviewSettings(),
- themeStatus: select( nfdOnboardingStore ).getThemeStatus(),
- themeVariations: select( nfdOnboardingStore ).getStepPreviewData(),
- };
- }, [] );
+ const { currentStep, currentData, themeStatus, themeVariations } =
+ useSelect( ( select ) => {
+ return {
+ currentStep: select( nfdOnboardingStore ).getStepFromPath(
+ location.pathname
+ ),
+ currentData:
+ select( nfdOnboardingStore ).getCurrentOnboardingData(),
+ themeStatus: select( nfdOnboardingStore ).getThemeStatus(),
+ themeVariations:
+ select( nfdOnboardingStore ).getStepPreviewData(),
+ };
+ }, [] );
const {
setDrawerActiveView,
@@ -111,12 +105,11 @@ const StepDesignHomepageMenu = () => {
async function getHomepagePatternsData() {
const homepagePatternDataTemp = await getPatterns(
- currentStep.patternId,
+ currentStep.patternId
);
if ( homepagePatternDataTemp?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
- setHomepagePattern( refactorPatterns( homepagePatternDataTemp ) );
if ( currentData?.data.sitePages.homepage !== '' ) {
setSelectedHomepage(
@@ -131,6 +124,8 @@ const StepDesignHomepageMenu = () => {
};
setCurrentOnboardingData( currentData );
}
+
+ setHomepagePattern( refactorPatterns( homepagePatternDataTemp ) );
}
function saveDataForHomepage( idx ) {
@@ -159,7 +154,6 @@ const StepDesignHomepageMenu = () => {
blockGrammer={ homepage }
viewportWidth={ 1200 }
styling={ 'custom' }
- previewSettings={ storedPreviewSettings }
overlay={ false }
onClick={ () => saveDataForHomepage( idx ) }
/>
diff --git a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js
index 15fb19a3a..a17c0e0e6 100644
--- a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js
@@ -83,13 +83,15 @@ const StepDesignThemeStylesMenu = () => {
if ( patternsResponse?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
+
const globalStylesResponse = await getGlobalStyles( true );
if ( globalStylesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_INIT );
}
+
+ setSelectedStyle( currentData.data.theme.variation );
setPattern( patternsResponse?.body );
setGlobalStyles( globalStylesResponse?.body );
- setSelectedStyle( currentData.data.theme.variation );
};
useEffect( () => {
diff --git a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js
index 6a62e8179..fdaeb133a 100644
--- a/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignThemeStyles/Preview/index.js
@@ -146,7 +146,6 @@ const StepDesignThemeStylesPreview = () => {
diff --git a/src/OnboardingSPA/pages/Steps/DesignTypography/index.js b/src/OnboardingSPA/pages/Steps/DesignTypography/index.js
index 9170603ab..a19e50176 100644
--- a/src/OnboardingSPA/pages/Steps/DesignTypography/index.js
+++ b/src/OnboardingSPA/pages/Steps/DesignTypography/index.js
@@ -66,7 +66,6 @@ const StepDesignTypography = () => {