mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
feat: [UEPR-44] handled interaction with highlighted element
This commit is contained in:
parent
8a76614bea
commit
ebad69d7d1
6 changed files with 64 additions and 23 deletions
|
@ -11,12 +11,15 @@ const DriverJourney = ({configProps, driverObj}) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const driverSteps = steps.map((step, index) => {
|
const driverSteps = steps.map((step, index) => {
|
||||||
const {sectionComponents = {}, ...popoverProps} = step.popover;
|
const {sectionComponents = {}, callback, ...popoverProps} = step.popover;
|
||||||
return {
|
return {
|
||||||
...step,
|
...step,
|
||||||
popover: {
|
popover: {
|
||||||
...popoverProps,
|
...popoverProps,
|
||||||
onPopoverRender: popover => {
|
onPopoverRender: popover => {
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
const portalData = [];
|
const portalData = [];
|
||||||
for (const [section, component] of Object.entries(
|
for (const [section, component] of Object.entries(
|
||||||
sectionComponents
|
sectionComponents
|
||||||
|
|
|
@ -138,8 +138,8 @@ const openTutorial = (onActivateDeck, tutorial, driverObj) => {
|
||||||
driverObj.destroy();
|
driverObj.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
const ownOptingPicked = (setIsOnOwnOptionPicked, driverObg) => {
|
const ownOptingPicked = (setCanViewTutorialsHighlight, driverObg) => {
|
||||||
setIsOnOwnOptionPicked(true);
|
setCanViewTutorialsHighlight(true);
|
||||||
driverObg.destroy();
|
driverObg.destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ const EditorJourneyDescription = ({title, descriptionData}) => (
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
const EditorJourney = ({onActivateDeck, setCanViewTutorialsHighlight}) => {
|
||||||
const [driverObj] = useState(() => (
|
const [driverObj] = useState(() => (
|
||||||
driver()
|
driver()
|
||||||
));
|
));
|
||||||
|
@ -290,7 +290,7 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -318,7 +318,7 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -347,7 +347,7 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -375,7 +375,7 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -403,7 +403,7 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -431,13 +431,13 @@ const EditorJourney = ({onActivateDeck, setIsOnOwnOptionPicked}) => {
|
||||||
{
|
{
|
||||||
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
imgSrc: '/images/onboarding-journeys/On-Own-Icon.png',
|
||||||
text: intl.formatMessage(messages.onMyOwnTitle),
|
text: intl.formatMessage(messages.onMyOwnTitle),
|
||||||
handleOnClick: () => ownOptingPicked(setIsOnOwnOptionPicked, driverObj)
|
handleOnClick: () => ownOptingPicked(setCanViewTutorialsHighlight, driverObj)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}], [onActivateDeck, setIsOnOwnOptionPicked]
|
}], [onActivateDeck, setCanViewTutorialsHighlight]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -463,7 +463,7 @@ EditorJourneyDescription.propTypes = {
|
||||||
|
|
||||||
EditorJourney.propTypes = {
|
EditorJourney.propTypes = {
|
||||||
onActivateDeck: PropTypes.func,
|
onActivateDeck: PropTypes.func,
|
||||||
setIsOnOwnOptionPicked: PropTypes.func
|
setCanViewTutorialsHighlight: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = EditorJourney;
|
module.exports = EditorJourney;
|
||||||
|
|
|
@ -2,6 +2,8 @@ const React = require('react');
|
||||||
const {driver} = require('driver.js');
|
const {driver} = require('driver.js');
|
||||||
const DriverJourney = require('../driver-journey/driver-journey.jsx');
|
const DriverJourney = require('../driver-journey/driver-journey.jsx');
|
||||||
const {defineMessages, useIntl} = require('react-intl');
|
const {defineMessages, useIntl} = require('react-intl');
|
||||||
|
const {useState} = require('react');
|
||||||
|
const PropTypes = require('prop-types');
|
||||||
require('./project-journey.scss');
|
require('./project-journey.scss');
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -17,8 +19,8 @@ const messages = defineMessages({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ProjectJourney = () => {
|
const ProjectJourney = ({setCanViewProjectJourney}) => {
|
||||||
const [driverObj] = React.useState(() => (
|
const [driverObj] = useState(() => (
|
||||||
driver()
|
driver()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -27,12 +29,26 @@ const ProjectJourney = () => {
|
||||||
const steps = [{
|
const steps = [{
|
||||||
element: 'div[class^="stage_green-flag-overlay-wrapper"] > div',
|
element: 'div[class^="stage_green-flag-overlay-wrapper"] > div',
|
||||||
popover: {
|
popover: {
|
||||||
|
callback: () => {
|
||||||
|
const greenFlagButton = document.querySelector('div[class^="stage_green-flag-overlay-wrapper"] > div');
|
||||||
|
greenFlagButton.addEventListener('click', () => {
|
||||||
|
setCanViewProjectJourney(false);
|
||||||
|
driverObj.destroy();
|
||||||
|
});
|
||||||
|
},
|
||||||
description: intl.formatMessage(messages.playProject)
|
description: intl.formatMessage(messages.playProject)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
element: '.remix-button',
|
element: '.remix-button',
|
||||||
popover: {
|
popover: {
|
||||||
|
callback: () => {
|
||||||
|
const remixButton = document.querySelector('.remix-button');
|
||||||
|
remixButton.addEventListener('click', () => {
|
||||||
|
setCanViewProjectJourney(false);
|
||||||
|
driverObj.destroy();
|
||||||
|
});
|
||||||
|
},
|
||||||
description: intl.formatMessage(messages.remixProject)
|
description: intl.formatMessage(messages.remixProject)
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
@ -45,6 +61,9 @@ const ProjectJourney = () => {
|
||||||
'next',
|
'next',
|
||||||
'previous'
|
'previous'
|
||||||
],
|
],
|
||||||
|
onDestroyed: () => {
|
||||||
|
setCanViewProjectJourney(false);
|
||||||
|
},
|
||||||
nextBtnText: 'Next',
|
nextBtnText: 'Next',
|
||||||
prevBtnText: 'Previous',
|
prevBtnText: 'Previous',
|
||||||
showProgress: false,
|
showProgress: false,
|
||||||
|
@ -55,4 +74,8 @@ const ProjectJourney = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ProjectJourney.propTypes = {
|
||||||
|
setCanViewProjectJourney: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = ProjectJourney;
|
module.exports = ProjectJourney;
|
||||||
|
|
|
@ -3,6 +3,7 @@ const {driver} = require('driver.js');
|
||||||
const DriverJourney = require('../driver-journey/driver-journey.jsx');
|
const DriverJourney = require('../driver-journey/driver-journey.jsx');
|
||||||
const {defineMessages, useIntl} = require('react-intl');
|
const {defineMessages, useIntl} = require('react-intl');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
|
const {useState} = require('react');
|
||||||
require('./tutorials-highlight.scss');
|
require('./tutorials-highlight.scss');
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -13,8 +14,8 @@ const messages = defineMessages({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const TutorialsHighlight = ({setIsOnOwnOptionPicked}) => {
|
const TutorialsHighlight = ({setCanViewTutorialsHighlight}) => {
|
||||||
const [driverObj] = React.useState(() => (
|
const [driverObj] = useState(() => (
|
||||||
driver()
|
driver()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -24,6 +25,13 @@ const TutorialsHighlight = ({setIsOnOwnOptionPicked}) => {
|
||||||
element: '.tutorials-button',
|
element: '.tutorials-button',
|
||||||
popover: {
|
popover: {
|
||||||
showButtons: ['close'],
|
showButtons: ['close'],
|
||||||
|
callback: () => {
|
||||||
|
const tutorialsButton = document.querySelector('.tutorials-button');
|
||||||
|
tutorialsButton.addEventListener('click', () => {
|
||||||
|
setCanViewTutorialsHighlight(false);
|
||||||
|
driverObj.destroy();
|
||||||
|
});
|
||||||
|
},
|
||||||
side: 'bottom',
|
side: 'bottom',
|
||||||
description: intl.formatMessage(messages.tutorialsHighlight)
|
description: intl.formatMessage(messages.tutorialsHighlight)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +44,7 @@ const TutorialsHighlight = ({setIsOnOwnOptionPicked}) => {
|
||||||
showProgress: false,
|
showProgress: false,
|
||||||
overlayOpacity: 0,
|
overlayOpacity: 0,
|
||||||
onDestroyed: () => {
|
onDestroyed: () => {
|
||||||
setIsOnOwnOptionPicked(false);
|
setCanViewTutorialsHighlight(false);
|
||||||
},
|
},
|
||||||
steps: steps
|
steps: steps
|
||||||
}}
|
}}
|
||||||
|
@ -46,7 +54,7 @@ const TutorialsHighlight = ({setIsOnOwnOptionPicked}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
TutorialsHighlight.propTypes = {
|
TutorialsHighlight.propTypes = {
|
||||||
setIsOnOwnOptionPicked: PropTypes.func
|
setCanViewTutorialsHighlight: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = TutorialsHighlight;
|
module.exports = TutorialsHighlight;
|
||||||
|
|
|
@ -150,6 +150,9 @@ const PreviewPresentation = ({
|
||||||
visibilityInfo
|
visibilityInfo
|
||||||
}) => {
|
}) => {
|
||||||
const [hasSubmittedComment, setHasSubmittedComment] = useState(false);
|
const [hasSubmittedComment, setHasSubmittedComment] = useState(false);
|
||||||
|
const [canViewProjectJourney, setCanViewProjectJourney] = useState(
|
||||||
|
queryString.parse(location.search, {parseBooleans: true}).showJourney
|
||||||
|
);
|
||||||
const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : '';
|
const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : '';
|
||||||
const revisedDate = ((projectInfo.history && projectInfo.history.modified)) ? projectInfo.history.modified : '';
|
const revisedDate = ((projectInfo.history && projectInfo.history.modified)) ? projectInfo.history.modified : '';
|
||||||
const showInstructions = editable || projectInfo.instructions ||
|
const showInstructions = editable || projectInfo.instructions ||
|
||||||
|
@ -259,8 +262,8 @@ const PreviewPresentation = ({
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{
|
{
|
||||||
isProjectLoaded &&
|
isProjectLoaded &&
|
||||||
queryString.parse(location.search, {parseBooleans: true}).showJourney &&
|
canViewProjectJourney &&
|
||||||
<ProjectJourney />
|
<ProjectJourney setCanViewProjectJourney={setCanViewProjectJourney} />
|
||||||
}
|
}
|
||||||
{showEmailConfirmationBanner && <EmailConfirmationBanner
|
{showEmailConfirmationBanner && <EmailConfirmationBanner
|
||||||
/* eslint-disable react/jsx-no-bind */
|
/* eslint-disable react/jsx-no-bind */
|
||||||
|
|
|
@ -50,7 +50,7 @@ const TutorialsHighlight = require('../../components/journeys/tutorials-highligh
|
||||||
|
|
||||||
const IntlGUIWithProjectHandler = ({...props}) => {
|
const IntlGUIWithProjectHandler = ({...props}) => {
|
||||||
const [showJourney, setShowJourney] = useState(false);
|
const [showJourney, setShowJourney] = useState(false);
|
||||||
const [isOnOwnOptionPicked, setIsOnOwnOptionPicked] = useState(false);
|
const [canViewTutorialsHighlight, setCanViewTutorialsHighlight] = useState(false);
|
||||||
const prevProjectId = usePrevious(props.projectId);
|
const prevProjectId = usePrevious(props.projectId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -72,10 +72,14 @@ const IntlGUIWithProjectHandler = ({...props}) => {
|
||||||
{showJourney && (
|
{showJourney && (
|
||||||
<EditorJourney
|
<EditorJourney
|
||||||
onActivateDeck={props.onActivateDeck}
|
onActivateDeck={props.onActivateDeck}
|
||||||
setIsOnOwnOptionPicked={setIsOnOwnOptionPicked}
|
setCanViewTutorialsHighlight={setCanViewTutorialsHighlight}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{canViewTutorialsHighlight && (
|
||||||
|
<TutorialsHighlight
|
||||||
|
setCanViewTutorialsHighlight={setCanViewTutorialsHighlight}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isOnOwnOptionPicked && <TutorialsHighlight setIsOnOwnOptionPicked={setIsOnOwnOptionPicked} />}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue