Skip to content

Commit

Permalink
Added State Handler
Browse files Browse the repository at this point in the history
Ran Lint
  • Loading branch information
officiallygod committed Dec 26, 2022
1 parent 61fbfe0 commit 91bdda1
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 164 deletions.
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;
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;
2 changes: 2 additions & 0 deletions src/OnboardingSPA/components/RadioControl/index.js
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 src/OnboardingSPA/components/RadioControlWithSkeleton/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { __, sprintf } from '@wordpress/i18n';
import { translations } from '../../../../../../utils/locales/translations';
import { institution } from '@wordpress/icons';

const getContents = ( brandName, techSupportLink, fullServiceCreativeTeamLink ) => {
const getContents = (
brandName,
techSupportLink,
fullServiceCreativeTeamLink
) => {
return {
introduction: {
heading: __( 'Tax Info', 'wp-module-onboarding' ),
subheading: sprintf(
/* translators: 1: Site 2: Brand 3: Site */
__(
'A %s that does taxes in one click. That’s pretty novel.'
),
__( 'A %s that does taxes in one click. That’s pretty novel.' ),
translations( 'site' ),
brandName,
translations( 'Site' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ const StepIntroPanel = lazy( () =>
);

const LearnMore = () => {
const { brandName, techSupportLink, fullServiceCreativeTeamLink } = useSelect( ( select ) => {
return {
brandName: select( nfdOnboardingStore ).getNewfoldBrandName(),
techSupportLink: select( nfdOnboardingStore ).getTechSupportUrl(),
fullServiceCreativeTeamLink: select( nfdOnboardingStore ).getfullServiceCreativeTeamUrl(),
};
} );
const { brandName, techSupportLink, fullServiceCreativeTeamLink } =
useSelect( ( select ) => {
return {
brandName: select( nfdOnboardingStore ).getNewfoldBrandName(),
techSupportLink:
select( nfdOnboardingStore ).getTechSupportUrl(),
fullServiceCreativeTeamLink:
select(
nfdOnboardingStore
).getfullServiceCreativeTeamUrl(),
};
} );

const content = getContents( brandName, techSupportLink, fullServiceCreativeTeamLink );
const content = getContents(
brandName,
techSupportLink,
fullServiceCreativeTeamLink
);

return (
<div className="nfd-onboarding-sidebar-learn-more__ecommerce-tax-info">
Expand All @@ -61,7 +70,7 @@ const LearnMore = () => {
<ButtonWhite
text={ content.help.fullService.text }
onClick={ () =>
( window.open( content.help.fullService.link, '_blank') )
window.open( content.help.fullService.link, '_blank' )
}
/>
<SupportLink
Expand Down
Loading

0 comments on commit 91bdda1

Please sign in to comment.