Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Press2 1233 new modern layout component #338

Closed
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
56108ad
PRESS2-1233 | creating structure from newfold-skeleton
Oct 17, 2023
fcf7faa
PRESS2-1233 | updated progress bar
Oct 17, 2023
4b60a35
PRESS2-1233 | added toggle
Oct 18, 2023
c491ebb
PRESS2-1233 | added a step
Oct 18, 2023
7203e70
PRESS2-1233
Oct 18, 2023
f5c16db
PRESS2-1233
Oct 18, 2023
b13edd5
PRESS2-1233 fixed linting issues
Oct 20, 2023
11ad03a
PRESS2-1233 | fixed PR comments
Oct 23, 2023
0c4f25a
PRESS2-1233 | fixed linting changes
Oct 23, 2023
00be88d
PRESS2-1233 | fixed style lint
Oct 23, 2023
1271c05
Merge branch 'trunk' of https://github.com/newfold-labs/wp-module-onb…
Oct 25, 2023
92c2b3f
PRESS-1233 | added sitegen to directory
Oct 25, 2023
04cb644
PRESS2-1233 | fixed comments
Oct 25, 2023
f1d893e
PRESS2-1233 | fixed styling
Oct 25, 2023
ecb1d0d
PRESS2-1233 | linting issues
Oct 25, 2023
c41ea1f
PRESS2-1233 | WIP adding styles and static iamges
Oct 26, 2023
e8b8fde
PRESS2-1233 | fixed changes
Oct 26, 2023
2a4acaf
PRESS2-1233 | added theme provider for theme toggle
Oct 27, 2023
8c29637
PRESS2-1233 | fixed linting issues
Oct 27, 2023
af5371e
PRESS2-1233 | fixed indentation
Oct 27, 2023
d4bcb7c
PRESS2-1233 | fixed indentation
Oct 27, 2023
87004bc
PRESS2-1233 | deleted image from static
Oct 27, 2023
042dce7
PRESS2-1233 | added common components
Oct 30, 2023
167d9bb
PRESS2-1233 | fixed linting
Oct 30, 2023
475867f
PRESS2-1233 | fixed linting
Oct 30, 2023
f2b58b1
PRESS2-1233 | toggle in footer
Oct 30, 2023
3730377
PRESS2-1233 | added shared directory for common components
Oct 31, 2023
cc073eb
PRESS2-1233 | fixed linting
Oct 31, 2023
7c1b21b
PRESS2-1233 | fixed linting
Oct 31, 2023
84b4737
changes for design studio
Nov 7, 2023
14eb9e7
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
Nov 8, 2023
3e5b0e0
PRESS2-1233 | merged changes
Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/OnboardingSPA/chapters/demographic.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { stepExperience } from '../steps/GetStarted/GetStartedExperience/step';
import { stepPrimarySetup } from '../steps/GetStarted/SiteTypeSetup/PrimarySite/step';
import { stepSecondarySetup } from '../steps/GetStarted/SiteTypeSetup/SecondarySite/step';
import { stepTopPriority } from '../steps/TopPriority/step';
import { stepSiteGenGetStarted } from '../steps/SiteGenGetStarted/step';
import { Chapter } from '../data/models/Chapter';
import { Step } from '../data/models/Step';
import ChapterInterstitialLoader from '../components/Loaders/Chapter/Interstitial';
Expand All @@ -22,6 +23,7 @@ const steps = [
stepSecondarySetup,
stepBasicInfo,
stepTopPriority,
stepSiteGenGetStarted,
];

export const demographic = new Chapter( {
Expand Down
30 changes: 30 additions & 0 deletions src/OnboardingSPA/components/AdminBarSiteGen/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { __ } from '@wordpress/i18n';
import { Icon, wordpress } from '@wordpress/icons';

const AdminBarSiteGen = ( {} ) => {
return (
<div className="nfd-sitegen-admin-bar">
<div className="nfd-admin-bar-wplogo">
<Icon icon={ wordpress } />
<span>{ __( 'WordPress', 'wp-module-onboarding' ) }</span>
</div>
<div className="nfd-sitegen-admin-bar-profile">
<span className="nfd-admin-bar-greeting">
Howdy, Maya Jiménez
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
</span>
<img
alt=""
src="http://1.gravatar.com/avatar/729ae85bf62b9917e93538db2f2688ca?s=26&amp;d=mm&amp;r=g"
srcSet="http://1.gravatar.com/avatar/729ae85bf62b9917e93538db2f2688ca?s=52&amp;d=mm&amp;r=g 2x"
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
className="avatar avatar-26 photo"
height="20"
width="20"
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
loading="lazy"
decoding="async"
></img>
</div>
</div>
);
};

export default AdminBarSiteGen;
37 changes: 37 additions & 0 deletions src/OnboardingSPA/components/AdminBarSiteGen/stylesheet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.nfd-interface-interface-skeleton__adminbar {

.nfd-sitegen-admin-bar {
padding: 5px;
background-color: #23282d; // Dark grayish background
display: flex;
justify-content: space-between;
align-items: center;

.nfd-admin-bar-wplogo {
color: #fff; // Logo color
font-size: 16px;
display: flex;
align-items: center;

svg {
color: #a0a5aa;
fill: #a0a5aa;
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
}

span {
margin-left: 15px;
}
}

.nfd-sitegen-admin-bar-profile {
display: flex;
align-items: center;

.nfd-admin-bar-greeting {
color: #a0a5aa; // Text color
font-size: 16px;
margin-right: 5px;
}
}
}
}
78 changes: 78 additions & 0 deletions src/OnboardingSPA/components/AppSiteGen/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import Content from '../Content';
import Header from '../HeaderSiteGen';
import ToggleDarkMode from '../ToggleDarkMode';
import AdminBarSiteGen from '../AdminBarSiteGen';
import ProgressBarSiteGen from '../ProgressBarSiteGen';
import classNames from 'classnames';
import { useLocation } from 'react-router-dom';

import { store as nfdOnboardingStore } from '../../store';
// eslint-disable-next-line import/no-extraneous-dependencies
import { kebabCase } from 'lodash';
import { useViewportMatch } from '@wordpress/compose';
import { useDispatch, useSelect } from '@wordpress/data';
import { SlotFillProvider } from '@wordpress/components';
import { useEffect, Fragment } from '@wordpress/element';
import { FullscreenMode } from '@wordpress/interface';
import SiteGenInterfaceSkeleton from '../SiteGenInterfaceSkeleton';

const AppSiteGen = () => {
const location = useLocation();
const isLargeViewport = useViewportMatch( 'medium' );
const pathname = kebabCase( location.pathname );

const { isDrawerOpen, newfoldBrand, onboardingFlow } = useSelect(
( select ) => {
return {
newfoldBrand: select( nfdOnboardingStore ).getNewfoldBrand(),
onboardingFlow:
select( nfdOnboardingStore ).getOnboardingFlow(),
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
allSteps: select( nfdOnboardingStore ).getAllSteps(),
};
},
[ location.pathname ]

Check warning on line 35 in src/OnboardingSPA/components/AppSiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useSelect has an unnecessary dependency: 'location.pathname'. Either exclude it or remove the dependency array
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
);

const { setActiveStep, setActiveFlow } = useDispatch( nfdOnboardingStore );

useEffect( () => {
document.body.classList.add( `nfd-brand-${ newfoldBrand }` );
}, [ newfoldBrand ] );

useEffect( () => {
if ( location.pathname.includes( '/step' ) ) {
setActiveFlow( onboardingFlow );
setActiveStep( location.pathname );
}
}, [ location.pathname, onboardingFlow ] );

Check warning on line 49 in src/OnboardingSPA/components/AppSiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setActiveFlow' and 'setActiveStep'. Either include them or remove the dependency array

return (
<Fragment>
<FullscreenMode isActive={ true } />
<SlotFillProvider>
<SiteGenInterfaceSkeleton
className={ classNames(
'nfd-onboarding-skeleton',
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
'nfd-sitegen-skeleton',
`brand-${ newfoldBrand }`,
`path-${ pathname }`,
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
{ 'is-drawer-open': isDrawerOpen },
{ 'is-large-viewport': isLargeViewport },
{ 'is-small-viewport': ! isLargeViewport }
) }
adminbar={ <AdminBarSiteGen /> }
progressbar={
<ProgressBarSiteGen current={ 20 } total={ 100 } />
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do the percent calc inside the component itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is just for representation. we will need to pass the necessary data (current value and total value) as props to the component. Then, we can perform the calculation within the component itself

header={ <Header /> }
content={ <Content /> }
darkModeToggle={ <ToggleDarkMode /> }
/>
</SlotFillProvider>
</Fragment>
);
};

export default AppSiteGen;
13 changes: 13 additions & 0 deletions src/OnboardingSPA/components/HeaderSiteGen/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { memo } from '@wordpress/element';

import StepNavigation from './step-navigation';

const Header = () => {
return (
<div className="nfd-onboarding-header">
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
<StepNavigation />
</div>
);
};

export default memo( Header );
151 changes: 151 additions & 0 deletions src/OnboardingSPA/components/HeaderSiteGen/step-navigation.js
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { useSelect, useDispatch } from '@wordpress/data';
import { useNavigate } from 'react-router-dom';
import { Button, ButtonGroup } from '@wordpress/components';
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

import { setFlow } from '../../utils/api/flow';
import { store as nfdOnboardingStore } from '../../store';
import { pluginDashboardPage } from '../../../constants';
import { activateInitialPlugins } from '../../utils/api/plugins';
import {
OnboardingEvent,
sendOnboardingEvent,
} from '../../utils/analytics/hiive';
import { ACTION_ONBOARDING_COMPLETE } from '../../utils/analytics/hiive/constants';

/**
* Back step Navigation button.
*
* @param {*} param0
*
* @return {WPComponent} Back Component
*/
const Back = ( { path, showErrorDialog } ) => {
const { setNavErrorContinuePath } = useDispatch( nfdOnboardingStore );
const navigate = useNavigate();
const navigateBack = () => {
if ( showErrorDialog !== false ) {
setNavErrorContinuePath( path );
} else {
navigate( path, { state: { origin: 'header' } } );
}
};
return (
<Button
className="navigation-buttons navigation-buttons_back"
onClick={ navigateBack }
variant="secondary"
>
<Icon icon={ chevronLeft } />
{ __( 'Back', 'wp-module-onboarding' ) }
</Button>
);
};

/**
* Next step naigation button
*
* @param {*} param0
*
* @return {WPComponent} Next Component
*/
const Next = ( { path, showErrorDialog } ) => {
const { setNavErrorContinuePath } = useDispatch( nfdOnboardingStore );
/* [TODO]: some sense of isStepComplete to enable/disable */
const navigate = useNavigate();
const navigateNext = () => {
if ( showErrorDialog !== false ) {
setNavErrorContinuePath( path );
} else {
navigate( path, { state: { origin: 'header' } } );
}
};
return (
<Button
onClick={ navigateNext }
variant="primary"
className="navigation-buttons navigation-buttons_next"
>
{ __( 'Next', 'wp-module-onboarding' ) }
<Icon icon={ chevronRight } />
</Button>
);
};

async function saveDataAndExit( currentData ) {
if ( currentData ) {
currentData.isComplete = new Date().getTime();
setFlow( currentData );
}

activateInitialPlugins();
sendOnboardingEvent( new OnboardingEvent( ACTION_ONBOARDING_COMPLETE ) );
window.location.replace( pluginDashboardPage );
}

/**
* Finish step navigation button.
*
* @param {*} param0
*
* @return {WPComponent} Finish Component
*/
const Finish = ( { currentData, saveDataAndExitFunc } ) => (
<Button
onClick={ () => saveDataAndExitFunc( currentData ) }
className="navigation-buttons navigation-buttons_finish"
variant="primary"
>
{ __( 'Finish', 'wp-module-onboarding' ) }
<Icon icon={ chevronRight } />
</Button>
);

/**
* Step buttons presented in Header.
*
* @return {WPComponent} StepNavigation Component
*/
const StepNavigation = () => {
const { previousStep, nextStep, currentData, showErrorDialog } = useSelect(
( select ) => {
return {
nextStep: select( nfdOnboardingStore ).getNextStep(),
previousStep: select( nfdOnboardingStore ).getPreviousStep(),
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
showErrorDialog:
select( nfdOnboardingStore ).getShowErrorDialog(),
};
},
[]
);
const isFirstStep = null === previousStep || false === previousStep;
const isLastStep = null === nextStep || false === nextStep;
return (
<div className="nfd-onboarding-header__step-navigation">
<ButtonGroup style={ { display: 'flex', columnGap: '0.5rem' } }>
{ isFirstStep || isLastStep ? null : (
<Back
path={ previousStep.path }
showErrorDialog={ showErrorDialog }
/>
) }
{ isLastStep ? (
<Finish
currentData={ currentData }
saveDataAndExitFunc={ saveDataAndExit }
/>
) : (
<Next
path={ nextStep.path }
showErrorDialog={ showErrorDialog }
/>
) }
</ButtonGroup>
</div>
);
};

export default StepNavigation;
Loading