-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from newfold-labs/PRESS2-335-Fix-the-Blank-Sp…
…ace-before-Theme-Skeleton-spins-up PRESS2 335 Fix the blank space before theme skeleton spins up
- Loading branch information
Showing
20 changed files
with
272 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/OnboardingSPA/components/LivePreview/LivePreviewSkeleton/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { useState, useEffect } from '@wordpress/element'; | ||
|
||
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 | ||
* | ||
*/ | ||
const LivePreviewSkeleton = ( { | ||
count, | ||
watch, | ||
callback, | ||
className, | ||
viewportWidth, | ||
isWithCard = false, | ||
} ) => { | ||
|
||
const MAX_ANIMATION_TIME = 600000; | ||
const [rerender, doRerender] = useState(0); | ||
|
||
useEffect(() => doRerender(1), [watch]); | ||
|
||
const buildDummyPreviews = () => { | ||
const dummyPreviews = []; | ||
|
||
for ( let i = 0; i < count; i++ ) { | ||
dummyPreviews.push( | ||
<LivePreviewSelectableCard | ||
key={ i } | ||
blockGrammer={ '' } | ||
styling={ 'custom' } | ||
className={ className } | ||
skeletonLoadingTime={ MAX_ANIMATION_TIME } | ||
viewportWidth={ viewportWidth } | ||
/> | ||
); | ||
} | ||
return dummyPreviews; | ||
}; | ||
|
||
const buildDummyPreviewsWithInfo = () => { | ||
const dummyPreviews = []; | ||
|
||
for (let i = 0; i < count; i++) { | ||
dummyPreviews.push( | ||
<LivePreviewSelectableCardWithInfo | ||
key={ i } | ||
className={ className } | ||
blockGrammer={ '' } | ||
viewportWidth={ 1200 } | ||
styling={ 'custom' } | ||
title={ 'Loading...' } | ||
description={'Loading...'} | ||
/> | ||
); | ||
} | ||
return dummyPreviews; | ||
}; | ||
|
||
return !watch ? (isWithCard ? buildDummyPreviewsWithInfo() : buildDummyPreviews()) : | ||
<> | ||
{watch ? <div style={{ display: 'none' }}>{rerender}</div> : null} | ||
{callback()} | ||
</>; | ||
}; | ||
|
||
export default LivePreviewSkeleton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as LivePreview } from './BlockPreview'; | ||
export { default as LivePreviewSkeleton } from './LivePreviewSkeleton'; | ||
export { default as LivePreviewSelectableCard } from './SelectableCard'; | ||
export { default as LivePreviewSelectableCardWithInfo } from './SelectableCardWithInfo'; | ||
export { default as GlobalStylesProvider } from './GlobalStylesProvider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.