From 5f239583fdcb4ed4b727deffb31611f8db5fa984 Mon Sep 17 00:00:00 2001 From: Ben Holt Date: Thu, 17 Dec 2020 11:34:17 -0500 Subject: [PATCH] Extract flyover component and make a version for mobile (#315) --- src/courseware/course/sequence/Sequence.jsx | 201 +++++++++++++++----- 1 file changed, 153 insertions(+), 48 deletions(-) diff --git a/src/courseware/course/sequence/Sequence.jsx b/src/courseware/course/sequence/Sequence.jsx index f85fe803..9bdd06e7 100644 --- a/src/courseware/course/sequence/Sequence.jsx +++ b/src/courseware/course/sequence/Sequence.jsx @@ -11,6 +11,10 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { useSelector } from 'react-redux'; import { history } from '@edx/frontend-platform'; +// These should be reverted after the REV1512 experiment +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'; + import PageLoading from '../../../generic/PageLoading'; import { UserMessagesContext, ALERT_TYPES } from '../../../generic/user-messages'; import { useModel } from '../../../generic/model-store'; @@ -20,6 +24,146 @@ import messages from './messages'; import { SequenceNavigation, UnitNavigation } from './sequence-navigation'; import SequenceContent from './SequenceContent'; +function REV1512Flyover({ toggleREV1512Flyover }) { + // This component should be reverted after the REV1512 experiment + return ( +
+
+ Notification + + + +
+
+
+ ); +} +REV1512Flyover.propTypes = { + toggleREV1512Flyover: PropTypes.func.isRequired, +}; + +function REV1512FlyoverMobile({ toggleREV1512Flyover }) { + // This component should be reverted after the REV1512 experiment + return ( +
+
+ { + if (event.key === 'Enter') { + toggleREV1512Flyover(); + } + }} + role="button" + tabIndex={0} + style={{ + color: '#00262B', + }} + > + + Back to course + +
+
+ + Notifications + +
+
+
+ ); +} +REV1512FlyoverMobile.propTypes = { + toggleREV1512Flyover: PropTypes.func.isRequired, +}; + function Sequence({ unitId, sequenceId, @@ -46,6 +190,12 @@ function Sequence({ } }; + // These should be reverted after the REV1512 experiment: + const userAgent = typeof window.navigator === 'undefined' ? '' : navigator.userAgent; + const isMobile = Boolean( + userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i), + ); + const handlePrevious = () => { const previousIndex = sequence.unitIds.indexOf(unitId) - 1; if (previousIndex >= 0) { @@ -189,54 +339,9 @@ function Sequence({
{/* This block of code should be reverted post REV1512 experiment */} {REV1512FlyoverEnabled && isREV1512FlyoverVisible() && ( -
-
- Notification - { - toggleREV1512Flyover(); - }} - className="hideFlyover" - width="14" - height="14" - viewBox="0 0 14 14" - fill="none" - xmlns="http://www.w3.org/2000/svg" - style={{ - float: 'right', - marginTop: '5.5px', - }} - > - - -
-
-
+ isMobile + ? + : )}