-
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.
Showing
12 changed files
with
212 additions
and
164 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/OnboardingSPA/components/RadioControl/RadioControlSkeleton/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,20 @@ | ||
/** | ||
* Renders Skeletons for Radio Control. | ||
* | ||
* @param {number} data The options to be renedered | ||
* | ||
*/ | ||
const RadioControlSkeleton = ( { data } ) => { | ||
const buildDummyRadioControls = () => { | ||
const customItems = []; | ||
|
||
for ( let idx = 0; idx < data.length; idx++ ) | ||
customItems.push( <div className="radio-control-skeleton-item" /> ); | ||
|
||
return <div className="radio-control-skeleton">{ customItems }</div>; | ||
}; | ||
|
||
return buildDummyRadioControls(); | ||
}; | ||
|
||
export default RadioControlSkeleton; |
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
src/OnboardingSPA/components/RadioControl/RadioControlState/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,27 @@ | ||
import { useState, useEffect } from '@wordpress/element'; | ||
import RadioControlSkeleton from '../RadioControlSkeleton'; | ||
|
||
/** | ||
* A State Handler to manage Radio Control | ||
* | ||
* @param {number} data The options to be renedered. | ||
* @param {string} children The children to be rendered out. | ||
* @param {number} watch The variable to be awaited for to be fetched. | ||
* | ||
*/ | ||
const RadioControlState = ( { data, watch, children } ) => { | ||
const [ rerender, doRerender ] = useState( 0 ); | ||
|
||
useEffect( () => doRerender( 1 ), [ watch ] ); | ||
|
||
return ! watch ? ( | ||
<RadioControlSkeleton data={ data } /> | ||
) : ( | ||
<> | ||
{ <div style={ { display: 'none' } }>{ rerender }</div> } | ||
{ children } | ||
</> | ||
); | ||
}; | ||
|
||
export default RadioControlState; |
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,2 @@ | ||
export { default as RadioCtrlSkeleton } from './RadioControlSkeleton'; | ||
export { default as RadioCtrlStateHandler } from './RadioControlState'; |
68 changes: 0 additions & 68 deletions
68
src/OnboardingSPA/components/RadioControlWithSkeleton/index.js
This file was deleted.
Oops, something went wrong.
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.