Skip to content

Commit 3973cf2

Browse files
feat: embedded views
1 parent 87fa67d commit 3973cf2

File tree

38 files changed

+518
-1806
lines changed

38 files changed

+518
-1806
lines changed

package-lock.json

Lines changed: 214 additions & 1631 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"url": "https://github.com/edx/frontend-app-ora/issues"
3535
},
3636
"dependencies": {
37-
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
37+
"@edx/brand": "npm:@edx/brand-edx.org@2.1.2",
3838
"@edx/frontend-component-footer": "12.4.0",
3939
"@edx/frontend-component-header": "4.7.1",
4040
"@edx/frontend-platform": "5.6.1",

src/App.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ const RouterRoot = () => {
2424
<Route
2525
path={route}
2626
element={(
27-
<AppContainer Component={Component} />
27+
<AppContainer>
28+
<Component />
29+
</AppContainer>
2830
)}
2931
/>
3032
);
3133
const modalRoute = (route, Component, title) => (
3234
<Route
3335
path={route}
3436
element={(
35-
<ModalContainer title={title}>
36-
<AppContainer Component={Component} />
37-
</ModalContainer>
37+
<AppContainer>
38+
<ModalContainer title={title}>
39+
<Component />
40+
</ModalContainer>
41+
</AppContainer>
3842
)}
3943
/>
4044
);

src/components/AppContainer.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4+
import ProgressBar from 'components/ProgressBar';
5+
46
import { useIsPageDataLoaded, useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors';
57

68
/* The purpose of this component is to wrap views with a header/footer for situations
79
* where we need to run non-embedded
810
*/
911

10-
const AppContainer = ({ Component }) => {
12+
const AppContainer = ({ children }) => {
1113
const isConfigLoaded = useIsORAConfigLoaded();
1214
const isPageDataLoaded = useIsPageDataLoaded();
1315
if (!isConfigLoaded || !isPageDataLoaded) {
1416
return null;
1517
}
16-
return <Component />;
18+
return (
19+
<div style={{ width: '100%' }}>
20+
{children}
21+
</div>
22+
);
1723
};
1824
AppContainer.propTypes = {
19-
Component: PropTypes.elementType.isRequired,
25+
children: PropTypes.node.isRequired,
2026
};
2127

2228
export default AppContainer;

src/components/BaseAssessmentView/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const BaseAssessmentView = ({
2222
getValues,
2323
}) => (
2424
<AssessmentContextProvider>
25-
<ProgressBar />
2625
<div className="assessment-content-layout mr-auto ml-auto">
2726
<div className="content-wrapper">
2827
<Row className="flex-nowrap m-0">

src/components/Instructions/index.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4+
import { stepStates } from 'data/services/lms/constants';
5+
import { useStepState } from 'data/services/lms/hooks/selectors';
6+
47
import useInstructionsMessage from './useInstructionsMessage';
58

69
const Instructions = ({ step }) => {
710
const message = useInstructionsMessage(step);
11+
const stepState = useStepState({ step });
12+
if (stepState !== stepStates.inProgress) {
13+
return null;
14+
}
815
return (
916
<div>
1017
<h2>Instructions</h2>

src/components/Instructions/messages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import { stepNames } from 'data/services/lms/constants';
44

55
const messages = defineMessages({
66
[stepNames.submission]: {
7-
defaultMessage: '<Submittion Instructions: TODO>',
7+
defaultMessage: 'Submittion Instructions: TODO',
88
description: 'Submission step instructions',
99
id: 'frontend-app-ora.instructions.submisison',
1010
},
1111
[stepNames.studentTraining]: {
12-
defaultMessage: '<Student Training Instructions: TODO>',
12+
defaultMessage: 'Student Training Instructions: TODO',
1313
description: 'StudentTraining step instructions',
1414
id: 'frontend-app-ora.instructions.studentTraining',
1515
},
1616
[stepNames.self]: {
17-
defaultMessage: '<Self Assessment Instructions: TODO>',
17+
defaultMessage: 'Self Assessment Instructions: TODO',
1818
description: 'Self Assessment step instructions',
1919
id: 'frontend-app-ora.instructions.selfAssessment',
2020
},
2121
[stepNames.peer]: {
22-
defaultMessage: '<Peer Assessment Instructions: TODO>',
22+
defaultMessage: 'Peer Assessment Instructions: TODO',
2323
description: 'Peer Assessment step instructions',
2424
id: 'frontend-app-ora.instructions.peerAssessment',
2525
},

src/components/ModalContainer.jsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FullscreenModal } from '@edx/paragon';
4-
import { IntlProvider } from '@edx/frontend-platform/i18n';
54

6-
import AppContainer from 'components/AppContainer';
5+
import ProgressBar from 'components/ProgressBar';
76

87
/* The purpose of this component is to wrap views with a header/footer for situations
98
* where we need to run non-embedded
109
*/
1110

12-
const ModalContainer = ({ title, children }) => {
13-
console.log({ children, title });
14-
return (
15-
<FullscreenModal
16-
isOpen
17-
onClose={null}
18-
hasCloseButton={false}
19-
title={title}
20-
modalBodyClassName="content-body bg-light-300"
21-
>
22-
{children}
23-
</FullscreenModal>
24-
);
25-
};
11+
const ModalContainer = ({ title, children }) => (
12+
<FullscreenModal
13+
isOpen
14+
onClose={null}
15+
hasCloseButton={false}
16+
title={title}
17+
modalBodyClassName="content-body bg-light-300"
18+
beforeBodyNode={<ProgressBar className="px-2" />}
19+
>
20+
{children}
21+
</FullscreenModal>
22+
);
2623
ModalContainer.propTypes = {
2724
children: PropTypes.node.isRequired,
2825
title: PropTypes.string.isRequired,

src/components/ProgressBar/ProgressStep.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ const ProgressStep = ({
5555
disabled={!isEnabled}
5656
className={classNames(
5757
'ora-progress-nav',
58-
'px-4',
58+
'px-0',
5959
{ 'is-active': isActive },
6060
)}
6161
>
62-
<Icon className={classNames('nav-icon', colorClass)} src={iconSrc} />
62+
<Icon
63+
className={classNames('nav-icon', 'my-auto', colorClass)}
64+
src={iconSrc}
65+
{...subLabel && { style: { position: 'relative', bottom: '0.7rem' } }}
66+
/>
6367
<div className="d-inline-block">
6468
{label}
6569
{subLabel && (
66-
<p className={classNames('x-small', colorClass)}>{subLabel}</p>
70+
<p className={classNames('x-small', 'm-0', colorClass)}>{subLabel}</p>
6771
)}
6872
</div>
6973
</Nav.Link>

src/components/ProgressBar/hooks.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { useParams } from 'react-router-dom';
22
import { useActiveView, useIsEmbedded } from 'hooks';
3-
import { useStepState, useEffectiveGrade } from 'data/services/lms/hooks/selectors';
3+
import {
4+
useStepState,
5+
useEffectiveGrade,
6+
useGlobalState,
7+
} from 'data/services/lms/hooks/selectors';
48
import {
59
routeSteps,
610
stepRoutes,
@@ -12,7 +16,7 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
1216
const isEmbedded = useIsEmbedded();
1317
const activeView = useActiveView();
1418
const viewStep = routeSteps[activeView];
15-
const stepState = useStepState({ step });
19+
const { activeStepName, stepState } = useGlobalState({ step });
1620

1721
const href = `/${stepRoutes[step]}${isEmbedded ? '/embedded' : ''}/${xblockId}`;
1822
const isActive = viewStep === step;
@@ -22,7 +26,6 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
2226
|| (canRevisit && stepState === stepStates.completed)
2327
);
2428
const myGrade = useEffectiveGrade()?.stepScore;
25-
2629
return {
2730
href,
2831
isEnabled,
@@ -33,7 +36,6 @@ export const useProgressStepData = ({ step, canRevisit = false }) => {
3336
myGrade,
3437
// myGrade: { earned: 8, possible: 10 },
3538
// isPastDue: step === 'self',
36-
3739
};
3840
};
3941

0 commit comments

Comments
 (0)