PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0
Elementor Website Builder – more than just a page builder v3.8.0
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / app / modules / onboarding / assets / js / context / context.js

context.js in Elementor Website Builder – more than just a page builder 3.8.0, at app/modules/onboarding/assets/js/context/context.js

48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createContext, useCallback, useState } from 'react';
2
3 export const OnboardingContext = createContext( {} );
4
5 export function ContextProvider( props ) {
6 const onboardingConfig = elementorAppConfig.onboarding,
7 initialState = {
8 // eslint-disable-next-line camelcase
9 hasPro: elementorAppConfig.hasPro,
10 isLibraryConnected: onboardingConfig.isLibraryConnected,
11 isHelloThemeInstalled: onboardingConfig.helloInstalled,
12 isHelloThemeActivated: onboardingConfig.helloActivated,
13 siteName: onboardingConfig.siteName,
14 siteLogo: onboardingConfig.siteLogo,
15 proNotice: '',
16 currentStep: '',
17 nextStep: '',
18 steps: {
19 account: false,
20 hello: false,
21 siteName: false,
22 siteLogo: false,
23 goodToGo: false,
24 },
25 },
26 [ state, setState ] = useState( initialState ),
27 updateState = useCallback( ( newState ) => {
28 setState( ( prev ) => ( { ...prev, ...newState } ) );
29 }, [ setState ] ),
30 getStateObjectToUpdate = ( stateObject, mainChangedPropertyKey, subChangedPropertyKey, subChangedPropertyValue ) => {
31 const mutatedStateCopy = JSON.parse( JSON.stringify( stateObject ) );
32
33 mutatedStateCopy[ mainChangedPropertyKey ][ subChangedPropertyKey ] = subChangedPropertyValue;
34
35 return mutatedStateCopy;
36 };
37
38 return (
39 <OnboardingContext.Provider value={ { state, setState, updateState, getStateObjectToUpdate } }>
40 { props.children }
41 </OnboardingContext.Provider>
42 );
43 }
44
45 ContextProvider.propTypes = {
46 children: PropTypes.any,
47 };
48