From e297da4f98576649aa0ce0d933280dc62f865dd0 Mon Sep 17 00:00:00 2001 From: Allen Benny Date: Fri, 3 Nov 2023 13:46:47 +0530 Subject: [PATCH] Make everything Usable --- .../components/CardWithOptions/index.js | 22 ++++++++- src/SiteGenSPA/components/Loader/index.js | 28 ++++++++--- .../components/Loader/stylesheet.scss | 47 +++++++++++++------ src/SiteGenSPA/steps/ExperienceLevel/index.js | 9 ++++ 4 files changed, 83 insertions(+), 23 deletions(-) diff --git a/src/SiteGenSPA/components/CardWithOptions/index.js b/src/SiteGenSPA/components/CardWithOptions/index.js index a2e74c69b..9f31157a5 100644 --- a/src/SiteGenSPA/components/CardWithOptions/index.js +++ b/src/SiteGenSPA/components/CardWithOptions/index.js @@ -1,13 +1,21 @@ import { addThemeSuffix } from '../../utils/helper'; import { Icon, chevronRight } from '@wordpress/icons'; -const CardWithOptions = ( { title, options, skip } ) => { +const CardWithOptions = ( { title, options, skip, setSelection } ) => { const buildOptions = () => { return options.map( ( data, idx ) => { return (
{ + setSelection( idx ); + } } + onKeyDown={ () => { + setSelection( idx ); + } } >
{
{ buildOptions() }
-
+
{ + setSelection( -1 ); + } } + onKeyDown={ () => { + setSelection( -1 ); + } } + > { skip }
diff --git a/src/SiteGenSPA/components/Loader/index.js b/src/SiteGenSPA/components/Loader/index.js index 9d5e7f9af..eea146bb1 100644 --- a/src/SiteGenSPA/components/Loader/index.js +++ b/src/SiteGenSPA/components/Loader/index.js @@ -4,12 +4,18 @@ import { useEffect, useState } from '@wordpress/element'; const Loader = () => { let statusIdx = 0; - const percentage = 70; const content = getContents(); + const [ percentage, setPercentage ] = useState( 0 ); const [ status, setStatus ] = useState( content.status[ statusIdx ].title ); + const checkStatus = async () => { + // Make fake API Call to get the status. + if ( percentage !== 100 ) setPercentage( ( t ) => t + 10 ); + }; + useEffect( () => { const statusTimer = setInterval( () => { + checkStatus(); statusIdx += 1; if ( statusIdx === content.status.length ) statusIdx = 0; setStatus( content.status[ statusIdx ].title ); @@ -25,15 +31,23 @@ const Loader = () => { { content.title }
-
+ > +
+
+
{ const content = getContents(); + // Index of the selection user makes + const [ selection, setSelection ] = useState(); + + useEffect( () => { + // undefined => not selected, 0-2 => Selections, -1 => Skip + // console.log( 'Selection changed to', selection ); + }, [ selection ] ); return ( @@ -15,6 +23,7 @@ const ExperienceLevel = () => { title={ content.heading } options={ content.options } skip={ content.skip } + setSelection={ setSelection } />