-
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.
Added a Step State Handler for Generic use
- Loading branch information
1 parent
76f8631
commit de8bdd2
Showing
6 changed files
with
158 additions
and
108 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/OnboardingSPA/components/StateHandlers/StepStateHandler/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,29 @@ | ||
import { useState, useEffect } from '@wordpress/element'; | ||
|
||
/** | ||
* A State Handler to manage Steps | ||
* | ||
* @param {string} children The children to be rendered out. | ||
* @param {number} watch The variable to be awaited for to be fetched. | ||
* | ||
*/ | ||
const StepStateHandler = ({ watch, children }) => { | ||
const [rerender, doRerender] = useState(0); | ||
|
||
useEffect(() => doRerender(1), [watch]); | ||
|
||
return !watch ? ( | ||
<div className='step-state-handler--blank'> | ||
{ children } | ||
</div> | ||
) : ( | ||
<> | ||
{<div style={{ display: 'none' }}>{rerender}</div>} | ||
<div className='step-state-handler--visible'> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default StepStateHandler; |
12 changes: 12 additions & 0 deletions
12
src/OnboardingSPA/components/StateHandlers/StepStateHandler/stylesheet.scss
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,12 @@ | ||
.step-state-handler { | ||
|
||
&--blank { | ||
opacity: 0; | ||
pointer-events: none; | ||
} | ||
|
||
&--visible { | ||
animation: fadeInWithDisabledClicks 500ms ease-in; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,13 +102,6 @@ | |
} | ||
} | ||
|
||
&--visible { | ||
animation: fadeIn 500ms ease-in; | ||
} | ||
|
||
&--blank { | ||
opacity: 0; | ||
} | ||
} | ||
} | ||
|
||
|
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