| 1 |
import { useContext } from 'react'; |
| 2 |
import { OnboardingContext } from '../../context/context'; |
| 3 |
import { useNavigate } from '@reach/router'; |
| 4 |
|
| 5 |
import ProgressBarItem from './progress-bar-item'; |
| 6 |
|
| 7 |
export default function ProgressBar() { |
| 8 |
const { state } = useContext( OnboardingContext ), |
| 9 |
navigate = useNavigate(), |
| 10 |
progressBarItemsConfig = [ |
| 11 |
{ |
| 12 |
id: 'account', |
| 13 |
title: __( 'Elementor Account', 'elementor' ), |
| 14 |
route: 'account', |
| 15 |
}, |
| 16 |
]; |
| 17 |
|
| 18 |
// If hello theme is already activated when onboarding starts, don't show this step in the onboarding. |
| 19 |
if ( ! elementorAppConfig.onboarding.helloActivated ) { |
| 20 |
progressBarItemsConfig.push( { |
| 21 |
id: 'hello', |
| 22 |
title: __( 'Hello Theme', 'elementor' ), |
| 23 |
route: 'hello', |
| 24 |
} ); |
| 25 |
} |
| 26 |
|
| 27 |
progressBarItemsConfig.push( { |
| 28 |
id: 'siteName', |
| 29 |
title: __( 'Site Name', 'elementor' ), |
| 30 |
route: 'site-name', |
| 31 |
}, |
| 32 |
{ |
| 33 |
id: 'siteLogo', |
| 34 |
title: __( 'Site Logo', 'elementor' ), |
| 35 |
route: 'site-logo', |
| 36 |
}, |
| 37 |
{ |
| 38 |
id: 'goodToGo', |
| 39 |
title: __( 'Good to Go', 'elementor' ), |
| 40 |
route: 'good-to-go', |
| 41 |
} ); |
| 42 |
|
| 43 |
const progressBarItems = progressBarItemsConfig.map( ( itemConfig, index ) => { |
| 44 |
itemConfig.index = index; |
| 45 |
|
| 46 |
if ( state.steps[ itemConfig.id ] ) { |
| 47 |
itemConfig.onClick = () => { |
| 48 |
elementorCommon.events.dispatchEvent( { |
| 49 |
event: 'step click', |
| 50 |
version: '', |
| 51 |
details: { |
| 52 |
placement: elementorAppConfig.onboarding.eventPlacement, |
| 53 |
step: state.currentStep, |
| 54 |
next_step: itemConfig.id, |
| 55 |
}, |
| 56 |
} ); |
| 57 |
|
| 58 |
navigate( '/onboarding/' + itemConfig.id ); |
| 59 |
}; |
| 60 |
} |
| 61 |
|
| 62 |
return <ProgressBarItem key={ itemConfig.id } { ...itemConfig } />; |
| 63 |
} ); |
| 64 |
|
| 65 |
return ( |
| 66 |
<div className="e-onboarding__progress-bar"> |
| 67 |
{ progressBarItems } |
| 68 |
</div> |
| 69 |
); |
| 70 |
} |
| 71 |
|