Skip to content

Commit

Permalink
Merge pull request #360 from newfold-labs/Customer-detail-and-experie…
Browse files Browse the repository at this point in the history
…nce-steps-merger

Customer Detail and Experience and Site Generation Pages
  • Loading branch information
officiallygod authored Nov 22, 2023
2 parents 5b375ed + 857a0d0 commit 6f42762
Show file tree
Hide file tree
Showing 38 changed files with 871 additions and 67 deletions.
19 changes: 19 additions & 0 deletions src/OnboardingSPA/components/Animate/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@
}
}

@keyframes fadeInFast {

0% {
opacity: 0.1;
}

25% {
opacity: 1;
}

75% {
opacity: 1;
}

100% {
opacity: 0.1;
}
}

@-webkit-keyframes spin {

0% {
Expand Down
13 changes: 10 additions & 3 deletions src/OnboardingSPA/components/Button/NextButtonSiteGen/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import classNames from 'classnames';
import { useNavigate } from 'react-router-dom';

import { useSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { Icon, chevronRight } from '@wordpress/icons';
import { store as nfdOnboardingStore } from '../../../store';
import classNames from 'classnames';

const NextButtonSiteGen = ( { text, className } ) => {
const NextButtonSiteGen = ( { text, className, callback = null } ) => {
const navigate = useNavigate();
const { nextStep } = useSelect( ( select ) => {
return {
Expand All @@ -19,12 +19,19 @@ const NextButtonSiteGen = ( { text, className } ) => {
className
) }
onClick={ () => {
if ( callback && typeof callback === 'function' ) {
callback();
}
if ( nextStep ) {
navigate( nextStep.path );
}
} }
>
{ text }
<Icon
className={ 'nfd-onboarding-button--site-gen-next--icon' }
icon={ chevronRight }
/>
</Button>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
.nfd-onboarding-button {

&--site-gen-next {
display: block;
background-color: var(--nfd-onboarding-primary);
color: var(--nfd-onboarding-secondary);
text-align: center;
width: 164px;
height: 50px;
font-size: clamp(0.5rem, 0.3864rem + 0.5682vw, 1.75rem);
display: flex;
cursor: pointer;
margin-top: 24px;
border-radius: 6px;
text-align: center;
border-radius: 8px;
align-items: center;
justify-content: center;
color: var(--nfd-onboarding-secondary);
background-color: var(--nfd-onboarding-primary);
font-size: clamp(0.5rem, 0.3864rem + 0.5682vw, 1.75rem);

@media (min-width: 2600px ) {
width: 250px;
Expand All @@ -22,4 +25,8 @@
margin-top: 10px;
}
}

&--icon {
fill: var(--nfd-onboarding-secondary);
}
}
71 changes: 71 additions & 0 deletions src/OnboardingSPA/components/CardWithOptions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Icon, chevronRight } from '@wordpress/icons';

const CardWithOptions = ( { title, options, skip, callback } ) => {
const buildOptions = () => {
return options.map( ( data, idx ) => {
return (
<div
key={ idx }
role="button"
tabIndex={ 0 }
className={ 'nfd-sg-card__data__option' }
onClick={ () => {
if ( callback && typeof callback === 'function' ) {
callback( idx + 1 );
}
} }
onKeyDown={ () => {
if ( callback && typeof callback === 'function' ) {
callback( idx + 1 );
}
} }
>
<div className={ 'nfd-sg-card__data__option__left' }>
<div
className={ 'nfd-sg-card__data__option__left_top' }
>
{ data.title }
</div>
<div
className={
'nfd-sg-card__data__option__left_bottom'
}
>
{ data.desc }
</div>
</div>
<Icon
className={ 'nfd-sg-card__data__option__right' }
icon={ chevronRight }
/>
</div>
);
} );
};

return (
<div className={ 'nfd-sg-card' }>
<div className={ 'nfd-sg-card__title' }>{ title }</div>
<div className={ 'nfd-sg-card__data' }>{ buildOptions() }</div>
<div
role="button"
tabIndex={ 0 }
className={ 'nfd-sg-card__skip' }
onClick={ () => {
if ( callback && typeof callback === 'function' ) {
callback( -1 );
}
} }
onKeyDown={ () => {
if ( callback && typeof callback === 'function' ) {
callback( -1 );
}
} }
>
{ skip }
</div>
</div>
);
};

export default CardWithOptions;
79 changes: 79 additions & 0 deletions src/OnboardingSPA/components/CardWithOptions/stylesheet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
$background-color: var(--nfd-onboarding-card-background);

.nfd-sg-card {

margin: 8px;
max-width: 90vw;
padding: 24px 12px;
border-radius: 12px;
background-color: $background-color;
width: clamp(18.75rem, 22.6136rem + 5.6818vw, 31.25rem);
box-shadow: 3px 3px 5px rgba(var(--nfd-onboarding-primary-rgb), $alpha: 0.05);

&__title {
color: var(--nfd-onboarding-primary);
margin: 16px;
line-height: 2;
font-size: 18px;
text-align: center;
margin-bottom: 30px;
letter-spacing: 1.5px;
}

&__data {
margin: 12px;

&__option {
display: flex;
cursor: pointer;
margin: 16px 4px;
align-items: center;
border-radius: 4px 4px 0 0;
padding: 16px 12px 20px 12px;
justify-content: space-between;
transition: background-color 400ms ease-in-out;

&:not(:last-child) {
border-bottom: 0.5px solid rgba(var(--nfd-onboarding-primary-rgb), 0.3);
}

&:hover {
background-color: var(--nfd-onboarding-hover);
}

&__left_top {
color: var(--nfd-onboarding-primary);
font-size: 16px;
font-weight: 500;
padding-bottom: 12px;
}

&__left_bottom {
color: var(--nfd-onboarding-primary);
font-size: 14px;
font-weight: 300;
}

&__right {
fill: var(--nfd-onboarding-primary);
transition: all 200ms ease-in-out;

&:hover {
transform: scale(1.1);
}
}
}
}

&__skip {
cursor: pointer;
text-align: end;
margin: 0 20px 6px 20px;
transition: color 200ms ease-in-out;
color: rgba(var(--nfd-onboarding-primary-rgb), 0.8);

&:hover {
color: var(--nfd-onboarding-primary);
}
}
}
2 changes: 1 addition & 1 deletion src/OnboardingSPA/components/ErrorState/Step/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CommonLayout from '../../Layouts/Common';
import HeadingWithSubHeading from '../../HeadingWithSubHeading';
import HeadingWithSubHeading from '../../Heading/HeadingWithSubHeading';
import NeedHelpTag from '../../NeedHelpTag';

const StepErrorState = ( { title, subtitle, error } ) => {
Expand Down
10 changes: 10 additions & 0 deletions src/OnboardingSPA/components/Heading/AIHeading/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const AIHeading = ( { title } ) => {
return (
<div className={ 'ai-heading' }>
<div className={ 'ai-heading--icon' } />
<div className={ 'ai-heading--title' }>{ title }</div>
</div>
);
};

export default AIHeading;
24 changes: 24 additions & 0 deletions src/OnboardingSPA/components/Heading/AIHeading/stylesheet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.ai-heading {

display: flex;
margin-bottom: 20px;
align-items: center;

&--icon {
width: 50px;
margin: 4px;
height: 50px;
background-size: 200%;
background-position: center;
background-repeat: no-repeat;
background-image: var(--sitegen-ai-animation);
}

&--title {
margin: 10px;
line-height: 1.5;
font-weight: 500;
font-size: 1.2rem;
color: var(--nfd-onboarding-primary);
}
}
32 changes: 32 additions & 0 deletions src/OnboardingSPA/components/Loaders/SiteGenLoader/contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { __ } from '@wordpress/i18n';

const getContents = () => {
return {
title: __( 'Building Website', 'wp-module-onboarding' ),
status: [
{
title: __( 'Generating Website', 'wp-module-onboarding' ),
},
{
title: __( 'Finding Font Pairings', 'wp-module-onboarding' ),
},
{
title: __(
'Building Custom Color Palettes',
'wp-module-onboarding'
),
},
{
title: __( 'Populating Images', 'wp-module-onboarding' ),
},
{
title: __( 'Finalizing Previews', 'wp-module-onboarding' ),
},
{
title: __( 'Packaging Website', 'wp-module-onboarding' ),
},
],
};
};

export default getContents;
64 changes: 64 additions & 0 deletions src/OnboardingSPA/components/Loaders/SiteGenLoader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import getContents from './contents';
import { useSelect } from '@wordpress/data';
import { useNavigate } from 'react-router-dom';
import { useEffect, useState } from '@wordpress/element';
import { store as nfdOnboardingStore } from '../../../store';

const SiteGenLoader = ( { autoNavigate = false } ) => {
let statusIdx = 0;
const content = getContents();
const navigate = useNavigate();
const [ percentage, setPercentage ] = useState( 0 );
const [ status, setStatus ] = useState( content.status[ statusIdx ].title );

const { nextStep } = useSelect( ( select ) => {
return {
nextStep: select( nfdOnboardingStore ).getNextStep(),
};
} );

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;

Check warning on line 28 in src/OnboardingSPA/components/Loaders/SiteGenLoader/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

Assignments to the 'statusIdx' variable from inside React Hook useEffect will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useEffect
if ( statusIdx === content.status.length ) statusIdx = 0;
setStatus( content.status[ statusIdx ].title );
}, 3000 );
return () => {
clearInterval( statusTimer );
};
}, [] );

useEffect( () => {
if ( percentage === 100 ) {
if ( nextStep && autoNavigate ) {
navigate( nextStep.path );
}
}
}, [ percentage ] );

Check warning on line 43 in src/OnboardingSPA/components/Loaders/SiteGenLoader/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'autoNavigate', 'navigate', and 'nextStep'. Either include them or remove the dependency array

return (
<div className={ 'nfd-sg-loader' }>
<div className={ 'nfd-sg-loader__title' }>{ content.title }</div>
<div className={ 'nfd-sg-loader__progress' }>
<div className={ 'nfd-sg-loader__progress_bars' }>
<div className={ 'nfd-sg-loader__progress_bars_bg' } />
<div
className={ 'nfd-sg-loader__progress_bars_bar' }
style={ { width: `${ percentage }%` } }
/>
</div>
</div>
<div
className={ 'nfd-sg-loader__status' }
>{ `${ status }...` }</div>
</div>
);
};

export default SiteGenLoader;
Loading

0 comments on commit 6f42762

Please sign in to comment.