Skip to content

Commit

Permalink
Merge pull request #462 from newfold-labs/save-continue-dim-ui
Browse files Browse the repository at this point in the history
Save continue dim UI
  • Loading branch information
officiallygod authored Feb 21, 2024
2 parents 088d4a2 + c7dea0d commit 3e1ac87
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,25 @@ const SiteGen = () => {
}, [ newfoldBrand ] );
const location = useLocation();

const { currentData, initialize, pluginInstallHash, siteGenErrorStatus } =
useSelect( ( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
initialize: select( nfdOnboardingStore ).getInitialize(),
pluginInstallHash:
select( nfdOnboardingStore ).getPluginInstallHash(),
siteGenErrorStatus:
select( nfdOnboardingStore ).getSiteGenErrorStatus(),
};
} );
const {
currentData,
initialize,
pluginInstallHash,
siteGenErrorStatus,
interactionDisabled,
} = useSelect( ( select ) => {
return {
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
initialize: select( nfdOnboardingStore ).getInitialize(),
pluginInstallHash:
select( nfdOnboardingStore ).getPluginInstallHash(),
siteGenErrorStatus:
select( nfdOnboardingStore ).getSiteGenErrorStatus(),
interactionDisabled:
select( nfdOnboardingStore ).getInteractionDisabled(),
};
} );

const { setCurrentOnboardingData, updateSiteGenErrorStatus } =
useDispatch( nfdOnboardingStore );
Expand Down Expand Up @@ -181,7 +188,10 @@ const SiteGen = () => {
}, [ location.pathname ] );

Check warning on line 188 in src/OnboardingSPA/components/NewfoldInterfaceSkeleton/SiteGen/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'generateSiteGenData', 'handlePreviousStepTracking', and 'syncStoreToDB'. Either include them or remove the dependency array

useEffect( () => {
if ( prevSiteGenErrorStatus.current === true && siteGenErrorStatus === false ) {
if (
prevSiteGenErrorStatus.current === true &&
siteGenErrorStatus === false
) {
generateSiteGenData();
syncStoreToDB();
}
Expand All @@ -205,6 +215,7 @@ const SiteGen = () => {
content={ <Content /> }
sidebar={ <Sidebar /> }
footer={ <Footer /> }
interactionDisabled={ interactionDisabled }
/>
</ThemeProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function NewfoldInterfaceSkeleton(
labels,
className,
shortcuts,
interactionDisabled,
},
ref
) {
Expand Down Expand Up @@ -182,6 +183,9 @@ function NewfoldInterfaceSkeleton(
{ footer }
</div>
) }
{ interactionDisabled && (
<div className="nfd-interface-interface-skeleton__overlay--disabled"></div>
) }
</div>
);
}
Expand Down
16 changes: 15 additions & 1 deletion src/OnboardingSPA/components/NewfoldInterfaceSkeleton/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,28 @@ html.nfd-interface-interface-skeleton__html-container {
top: 0;
}
}

&__overlay {
// z-index: to display over sidebar.
&--disabled {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(var(--nfd-onboarding-secondary-rgb), 0.3);
cursor: not-allowed;
z-index: 1000001;
}
}
}

.nfd-interface-interface-skeleton__editor {
display: flex;
flex-direction: column;
flex: 0 1 100%;
overflow: hidden;
position: relative;
}

@include editor-left(".nfd-interface-interface-skeleton");
Expand Down Expand Up @@ -197,4 +212,3 @@ html.nfd-interface-interface-skeleton__html-container {
}
}
}

16 changes: 11 additions & 5 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@ const DropDownMenu = memo(
onRenameItemSelect,
onViewAll,
isLargeViewport,
onToggle,
} ) => {
const onMenuItemClick = ( action ) => () => {
action();
onToggle();
};
return (
<MenuGroup className="nfd-onboarding-header__version_dropdown-menu">
{ ! isLargeViewport && (
<>
<MenuItem onClick={ onRegenerate }>
<MenuItem onClick={ onMenuItemClick( onRegenerate ) }>
<Icon icon={ reusableBlock } />
{ __( 'Regenerate', 'wp-module-onboarding' ) }
</MenuItem>
<MenuItem onClick={ onCustomize }>
<MenuItem onClick={ onMenuItemClick( onCustomize ) }>
<div className="nfd-onboarding-header__version_dropdown-menu__customize-button__icon"></div>
{ __( 'Customize', 'wp-module-onboarding' ) }
</MenuItem>
</>
) }

<MenuItem onClick={ onRenameItemSelect }>
<MenuItem onClick={ onMenuItemClick( onRenameItemSelect ) }>
{ __( 'Rename', 'wp-module-onboarding' ) }
</MenuItem>
<MenuItem onClick={ onViewAll }>
<MenuItem onClick={ onMenuItemClick( onViewAll ) }>
{ __( 'View All', 'wp-module-onboarding' ) }
</MenuItem>
</MenuGroup>
Expand Down Expand Up @@ -126,13 +131,14 @@ const TitleContent = memo(
/>
</div>
) }
renderContent={ () => (
renderContent={ ( { onToggle } ) => (
<DropDownMenu
onRegenerate={ onRegenerate }
onCustomize={ onCustomize }
onRenameItemSelect={ onRenameItemSelect }
onViewAll={ onViewAll }
isLargeViewport={ isLargeViewport }
onToggle={ onToggle }
/>
) }
/>
Expand Down
19 changes: 16 additions & 3 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const StepSiteGenEditorHeader = () => {
setCurrentOnboardingData,
setSidebarActiveView,
setIsSidebarOpened,
setInteractionDisabled,
} = useDispatch( nfdOnboardingStore );
const { currentData, sideBarView, isSidebarOpened } = useSelect(
( select ) => {
Expand Down Expand Up @@ -222,6 +223,18 @@ const StepSiteGenEditorHeader = () => {
}
}, [ currentData ] );

useEffect( () => {
if ( isSaving || isRegenerating ) {
setInteractionDisabled( true );
} else {
setInteractionDisabled( false );
}

return () => {
setInteractionDisabled( false );
};
}, [ isSaving, isRegenerating ] );

Check warning on line 236 in src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'setInteractionDisabled'. Either include it or remove the dependency array

return (
<>
<Fill name={ `${ HEADER_SITEGEN }/${ HEADER_START }` }>
Expand Down Expand Up @@ -299,9 +312,9 @@ const StepSiteGenEditorHeader = () => {
>
{ isLargeViewport
? __(
'Save & Continue',
'wp-module-onboarding'
)
'Save & Continue',
'wp-module-onboarding'
)
: __( 'Next', 'wp-module-onboarding' ) }
</div>
{ isSaving ? (
Expand Down
7 changes: 7 additions & 0 deletions src/OnboardingSPA/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,10 @@ export function updateSiteGenErrorStatus( siteGenErrorStatus ) {
siteGenErrorStatus,
};
}

export function setInteractionDisabled( interactionDisabled ) {
return {
type: 'SET_INTERACTION_DISABLED',
interactionDisabled,
};
}
6 changes: 6 additions & 0 deletions src/OnboardingSPA/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function flow(
},
},
chapter: undefined,
interactionDisabled: false,
},
action
) {
Expand Down Expand Up @@ -121,6 +122,11 @@ export function flow(
...state,
chapter: action.chapter,
};
case 'SET_INTERACTION_DISABLED':
return {
...state,
interactionDisabled: action.interactionDisabled,
};
}

return state;
Expand Down
4 changes: 4 additions & 0 deletions src/OnboardingSPA/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,7 @@ export function getCustomizeSidebarData( state ) {
export function getSiteGenErrorStatus( state ) {
return state.data.flowData.sitegen.siteGenErrorStatus;
}

export function getInteractionDisabled( state ) {
return state.flow.interactionDisabled;
}

0 comments on commit 3e1ac87

Please sign in to comment.