Skip to content

Commit

Permalink
Merge pull request #8801 from MiroslavDionisiev/UEPR-44
Browse files Browse the repository at this point in the history
[UEPR-44] Implemented custom journeys for onboarding
  • Loading branch information
MiroslavDionisiev authored Oct 18, 2024
2 parents abb1aa6 + a4b0b7b commit f98be9e
Show file tree
Hide file tree
Showing 28 changed files with 1,185 additions and 4,596 deletions.
5,003 changes: 422 additions & 4,581 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"dependencies": {
"bunyan": "1.8.15",
"clipboard-copy": "2.0.1",
"driver.js": "^1.3.1",
"express": "4.21.1",
"express-http-proxy": "1.6.3",
"lodash.defaults": "4.2.0",
Expand Down Expand Up @@ -127,7 +128,7 @@
"postcss-loader": "4.3.0",
"postcss-simple-vars": "5.0.2",
"prop-types": "15.8.1",
"query-string": "5.1.1",
"query-string": "9.1.0",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-intl": "5.25.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer/www/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const Footer = props => (
</a>
</dd>
<dd>
<a href="https://www.scratchfoundation.org/DSA/">
<a href="https://www.scratchfoundation.org/dsa/">
<FormattedMessage id="general.dsa" />
</a>
</dd>
Expand Down
69 changes: 69 additions & 0 deletions src/components/journeys/driver-journey/driver-journey.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const React = require('react');
const {useState, useEffect, isValidElement} = require('react');
const {createPortal} = require('react-dom');
const PropTypes = require('prop-types');
require('driver.js/dist/driver.css');

const DriverJourney = ({configProps, driverObj}) => {
const [renderState, setRenderState] = useState();

useEffect(() => {
const {steps, ...restConfig} = configProps;
const driverSteps = steps.map((step, index) => {
const {sectionComponents = {}, callback, ...popoverProps} = step.popover;
return {
...step,
popover: {
...popoverProps,
onPopoverRender: popover => {
if (callback) {
callback();
}
const portalData = [];
for (const [section, component] of Object.entries(
sectionComponents
)) {
if (isValidElement(component)) {
popover[section].style.display = 'block';
popover[section].innerHTML = '';
portalData.push({
parentElement: popover[section],
childElement: component
});
}
}

setRenderState({components: portalData, stepIndex: index});
}
}
};
});

driverObj.setConfig({...restConfig, steps: driverSteps});

driverObj.drive();
}, [driverObj, configProps]);

if (!renderState) return null;
if (!configProps.steps[renderState.stepIndex]) return null;

return (
<>
{renderState.components.map(obj =>
createPortal(obj.childElement, obj.parentElement)
)}
</>
);
};

DriverJourney.propTypes = {
configProps: PropTypes.shape({
steps: PropTypes.arrayOf(PropTypes.object)
}),
driverObj: PropTypes.shape({
setConfig: PropTypes.func,
drive: PropTypes.func
})
};

module.exports = DriverJourney;
Loading

0 comments on commit f98be9e

Please sign in to comment.