Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESS2 335 Fix the blank space before theme skeleton spins up #104

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
30fc0dd
Fixed Blank Space in Theme Style selection step
officiallygod Nov 9, 2022
7d9bfea
Removed Blank Space from Preview step
officiallygod Nov 9, 2022
e176873
Refactored Code
officiallygod Nov 9, 2022
4e6cd43
New Data Structure to save data
officiallygod Nov 10, 2022
3027baa
Added Fast Loader to other pages
officiallygod Nov 10, 2022
9227507
Factored out Skeleton for Live Preview
officiallygod Nov 15, 2022
946f790
Added a few Fixes
officiallygod Nov 15, 2022
9970370
Merge branch 'release/v1.0.0' into PRESS2-335-Fix-the-Blank-Space-bef…
officiallygod Nov 15, 2022
1112399
Update Patterns.php
officiallygod Nov 16, 2022
6e052d6
Moved Style calc to Themes.php
officiallygod Nov 17, 2022
9e3c4dc
Moved Skeleton inside the LivePreview component
officiallygod Nov 17, 2022
3d090de
Review Comments
officiallygod Nov 17, 2022
8460053
Update DesignThemeStylesPreview.js
officiallygod Nov 17, 2022
c119bbf
Fix Homepage step
officiallygod Nov 17, 2022
1b81839
Combining Functions using Ternary
officiallygod Nov 17, 2022
a55546e
Combined the Theme Step data into Preview Settings
officiallygod Nov 21, 2022
c7b0955
JS Lint
officiallygod Nov 21, 2022
d7d9611
PHP Format
officiallygod Nov 21, 2022
513a054
Merge branch 'release/v1.0.0' into PRESS2-335-Fix-the-Blank-Space-bef…
officiallygod Nov 22, 2022
7f36fbb
Added support for Typography Step
officiallygod Nov 22, 2022
59db863
Added Extra checks for previews
officiallygod Nov 22, 2022
891e246
Setting a MAX Animation duration
officiallygod Nov 22, 2022
77b5b99
Update index.js
officiallygod Nov 22, 2022
428ef4c
Refactored Code
officiallygod Nov 23, 2022
ae9bc0a
Merge remote-tracking branch 'origin/release/v1.0.0' into PRESS2-335-…
officiallygod Nov 24, 2022
5452dff
Added Live Preview Skeleton for Site Pages
officiallygod Nov 24, 2022
341a32e
Code Review Comments
officiallygod Nov 29, 2022
6057961
Used store data instead of window data
officiallygod Nov 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions includes/Data/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ final class Data {
*/
public static function runtime() {
return array(
'buildUrl' => \NFD_ONBOARDING_BUILD_URL,
'siteUrl' => \get_site_url(),
'restUrl' => \get_home_url() . '/index.php?rest_route=',
'adminUrl' => \admin_url(),
'currentBrand' => self::current_brand(),
'currentPlan' => self::current_plan(),
'currentFlow' => self::current_flow(),
'pluginInstallHash' => Permissions::rest_get_plugin_install_hash(),
'previewSettings' => Preview::get_settings(),
'buildUrl' => \NFD_ONBOARDING_BUILD_URL,
'siteUrl' => \get_site_url(),
'restUrl' => \get_home_url() . '/index.php?rest_route=',
'adminUrl' => \admin_url(),
'currentBrand' => self::current_brand(),
'currentPlan' => self::current_plan(),
'currentFlow' => self::current_flow(),
'pluginInstallHash' => Permissions::rest_get_plugin_install_hash(),
'previewSettings' => Preview::get_settings(),
'themeStepData' => self::theme_data(),
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down Expand Up @@ -105,4 +106,17 @@ public static function customer_data() {
}
return array();
}

/**
* Get the current theme data like the theme variations and previews per step
*
* @return array
*/
public static function theme_data()
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
{
$theme_step_data = Patterns::get_count_of_patterns();
$theme_step_data["theme-styles"]["styles"] = count(\WP_Theme_JSON_Resolver::get_style_variations()) + 1;
return $theme_step_data;
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
}

officiallygod marked this conversation as resolved.
Show resolved Hide resolved
} // END \NewfoldLabs\WP\Module\Onboarding\Data()
68 changes: 59 additions & 9 deletions includes/Data/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,44 @@ final class Patterns
protected static $theme_step_patterns = array(
'yith-wonder' => array(
'theme-styles' => array(
'site-header-left-logo-navigation-inline',
'homepage-1',
'site-footer',
'site-header-left-logo-navigation-inline' => array(
'active',
'selected'
),
'homepage-1' => array(
'active',
'selected',
'shown'
),
'site-footer' => array(
'active',
'selected'
),
),
'homepage-styles' => array(
'site-header-left-logo-navigation-inline',
'homepage-1',
'homepage-2',
'homepage-3',
'site-footer',
'site-header-left-logo-navigation-inline' => array(
'active',
'selected'
),
'homepage-1' => array(
'active',
'selected',
'shown'
),
'homepage-2' => array(
'active',
'selected',
'shown'
),
'homepage-3' => array(
'active',
arunshenoy99 marked this conversation as resolved.
Show resolved Hide resolved
'selected',
'shown'
),
'site-footer' => array(
'active',
'selected'
),
),
),
);
Expand Down Expand Up @@ -69,7 +97,7 @@ public static function get_theme_step_patterns_from_step($step, $squash = false)
$block_patterns_registry = \WP_Block_Patterns_Registry::get_instance();
$block_patterns = array();
$block_patterns_squashed = '';
foreach ($pattern_slugs as $pattern_slug) {
foreach ($pattern_slugs as $pattern_slug=>$i) {
$pattern_name = $active_theme . '/' . $pattern_slug;
if ($block_patterns_registry->is_registered($pattern_name)) {
$pattern = $block_patterns_registry->get_registered($pattern_name);
Expand Down Expand Up @@ -175,4 +203,26 @@ public static function set_theme_step_patterns($step, $slug)
);
}
}

public static function get_count_of_patterns() {

$active_theme = (\wp_get_theme())->get('TextDomain');
$theme_steps = self::$theme_step_patterns[$active_theme];

$theme_pattern_count = array();
foreach ($theme_steps as $theme_step => $patterns) {
$theme_step_count = 0;
foreach ($patterns as $pattern => $pattern_data) {
foreach ($pattern_data as $property) {
if($property === 'shown')
$theme_step_count += 1;
}
}
$theme_pattern_count[$theme_step] = array(
'styles' => 1,
'patterns' => $theme_step_count
);
}
return $theme_pattern_count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {

const DesignThemeStylesPreview = () => {
const MAX_PREVIEWS_PER_ROW = 3;

const [ isLoaded, setIsLoaded ] = useState( false );
const [ pattern, setPattern ] = useState();
const [ globalStyles, setGlobalStyles ] = useState();
Expand All @@ -36,6 +37,10 @@ const DesignThemeStylesPreview = () => {
updateThemeStatus,
} = useDispatch( nfdOnboardingStore );

const THEME_VARIATIONS
= window.nfdOnboarding.themeStepData[currentStep.patternId].styles
* window.nfdOnboarding.themeStepData[currentStep.patternId].patterns;

const getStylesAndPatterns = async () => {
const patternResponse = await getPatterns(
currentStep.patternId,
Expand Down Expand Up @@ -91,6 +96,25 @@ const DesignThemeStylesPreview = () => {
setCurrentOnboardingData( currentData );
};

const buildDummyPreviews = () => {
let dummyPreview = [];

for (let i = 0; i < THEME_VARIATIONS; i++) {
dummyPreview.push(
<LivePreviewSelectableCard
key={i}
className={'theme-styles-preview--drawer__list__item'}
blockGrammer={''}
viewportWidth={900}
styling={'custom'}
skeletonLoadingTime={4000}
/>
);
}

return dummyPreview;
};

const buildPreviews = () => {
return globalStyles?.map( ( globalStyle, idx ) => {
return (
Expand All @@ -112,17 +136,22 @@ const DesignThemeStylesPreview = () => {
return (
<div className="theme-styles-preview--drawer">
<div className="theme-styles-preview--drawer__list">
{!globalStyles
&& buildDummyPreviews().slice(0, MAX_PREVIEWS_PER_ROW)}
{ globalStyles
? buildPreviews().slice( 0, MAX_PREVIEWS_PER_ROW )
: '' }
&& buildPreviews().slice( 0, MAX_PREVIEWS_PER_ROW ) }
</div>
<div className="theme-styles-preview--drawer__list">
{!globalStyles
&& buildDummyPreviews().slice(
MAX_PREVIEWS_PER_ROW,
THEME_VARIATIONS
)}
{ globalStyles
? buildPreviews().slice(
&& buildPreviews().slice(
MAX_PREVIEWS_PER_ROW,
globalStyles.length
)
: '' }
) }
</div>
</div>
);
Expand Down
7 changes: 7 additions & 0 deletions src/OnboardingSPA/pages/Steps/DesignColors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ const StepDesignColors = () => {
</div>
</div>
<div className="theme-colors-preview__live-preview-container">
{!pattern && (
<LivePreview
blockGrammer={''}
styling={'custom'}
viewportWidth={1300}
/>
)}
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
{pattern && (
<LivePreview
blockGrammer={pattern}
Expand Down
24 changes: 24 additions & 0 deletions src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ const StepDesignHomepageMenu = () => {
updateThemeStatus,
} = useDispatch( nfdOnboardingStore );

const THEME_VARIATIONS
= window.nfdOnboarding.themeStepData[currentStep.patternId].styles
* window.nfdOnboarding.themeStepData[currentStep.patternId].patterns;

useEffect( () => {
if ( isLargeViewport ) {
setIsDrawerOpened( true );
Expand Down Expand Up @@ -156,6 +160,25 @@ const StepDesignHomepageMenu = () => {
}
}, [ isLoaded, themeStatus ] );

const buildDummyPreviews = () => {
let dummyPreview = [];

for (let i = 0; i < THEME_VARIATIONS; i++) {
dummyPreview.push(
<LivePreviewSelectableCard
key={i}
className={'homepage_preview__list__item'}
blockGrammer={''}
viewportWidth={900}
styling={'custom'}
skeletonLoadingTime={4000}
/>
);
}

return dummyPreview;
};

function buildHomepagePreviews() {
return homepagePattern?.map( ( homepage, idx ) => {
if ( homepage ) {
Expand Down Expand Up @@ -186,6 +209,7 @@ const StepDesignHomepageMenu = () => {
subtitle={ currentStep?.subheading }
/>
<div className="theme-styles-menu__list">
{ !globalStyle && buildDummyPreviews() }
{ globalStyle && buildHomepagePreviews() }
</div>
</div>
Expand Down
35 changes: 32 additions & 3 deletions src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const StepDesignThemeStylesMenu = () => {
};
}, [] );

const THEME_VARIATIONS
= window.nfdOnboarding.themeStepData[currentStep.patternId].styles
* window.nfdOnboarding.themeStepData[currentStep.patternId].patterns;

const {
setDrawerActiveView,
setIsDrawerOpened,
Expand Down Expand Up @@ -101,6 +105,25 @@ const StepDesignThemeStylesMenu = () => {
navigate( nextStep.path );
};

const buildDummyPreviews = () => {
let dummyPreview = [];

for (let i = 0; i < THEME_VARIATIONS; i++) {
dummyPreview.push(
<LivePreviewSelectableCard
key={i}
className={'theme-styles-menu__list__item'}
blockGrammer={''}
viewportWidth={900}
styling={'custom'}
skeletonLoadingTime={3000}
/>
);
}

return dummyPreview;
};

const buildPreviews = () => {
return globalStyles?.map( ( globalStyle, idx ) => {
return (
Expand All @@ -118,7 +141,7 @@ const StepDesignThemeStylesMenu = () => {
);
} );
};

return (
<DesignStateHandler>
<CommonLayout>
Expand All @@ -128,15 +151,21 @@ const StepDesignThemeStylesMenu = () => {
subtitle={ currentStep?.subheading }
/>
<div className="theme-styles-menu__list">
{!globalStyles && buildDummyPreviews().slice(0, MAX_PREVIEWS_PER_ROW)}
{ globalStyles &&
buildPreviews().slice( 0, MAX_PREVIEWS_PER_ROW ) }
buildPreviews().slice( 0, MAX_PREVIEWS_PER_ROW )}
</div>
<div className="theme-styles-menu__list">
{!globalStyles &&
buildDummyPreviews().slice(
MAX_PREVIEWS_PER_ROW,
THEME_VARIATIONS
)}
{ globalStyles &&
buildPreviews().slice(
MAX_PREVIEWS_PER_ROW,
globalStyles.length
) }
)}
</div>
</div>
</CommonLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ const StepDesignThemeStylesPreview = () => {
</div>
</div>
<div className="theme-styles-preview__live-preview-container">
{ !pattern && (
<LivePreview
blockGrammer={''}
styling={'custom'}
viewportWidth={1300}
/>
)}
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
{ pattern && (
<LivePreview
blockGrammer={ pattern }
Expand Down
1 change: 1 addition & 0 deletions src/OnboardingSPA/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function setRuntime( runtime ) {
siteUrl: runtime.siteUrl,
migrated: true,
currentFlow: runtime.currentFlow ?? 'wp-setup',
themeStepData: runtime.themeStepData,
};
return {
type: 'SET_RUNTIME',
Expand Down