-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from openedx/bw/routes
Bw/routes
- Loading branch information
Showing
19 changed files
with
1,105 additions
and
868 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useLocation } from 'react-router-dom'; | ||
import classNames from 'classnames'; | ||
|
||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { Navbar, Nav, Icon } from '@edx/paragon'; | ||
import { Locked, CheckCircle, Error } from '@edx/paragon/icons'; | ||
|
||
import { | ||
useAssessmentStepConfig, | ||
useProgressData, | ||
useIsPageDataLoaded, | ||
} from 'data/services/lms/hooks/selectors'; | ||
|
||
import messages from './messages'; | ||
import './index.scss'; | ||
|
||
export const ProgressStep = ({ | ||
children, | ||
href, | ||
isActive, | ||
isEnabled, | ||
isComplete, | ||
isError, | ||
number, | ||
}) => { | ||
let icon = <Icon className="nav-icon" src={Locked} />; | ||
if (isComplete) { | ||
icon = <Icon className="nav-icon" src={CheckCircle} />; | ||
} else if (isError) { | ||
icon = <Icon className="nav-icon text-danger-300" src={Error} />; | ||
} else if (number) { | ||
icon = <span className="nav-icon number-icon">{number}</span>; | ||
} | ||
return ( | ||
<Nav.Link | ||
href={href} | ||
disabled={!isEnabled} | ||
className={classNames( | ||
'ora-progress-nav', | ||
'px-4', | ||
{ 'is-active': isActive }, | ||
)} | ||
> | ||
{icon} | ||
{children} | ||
</Nav.Link> | ||
); | ||
}; | ||
ProgressStep.defaultProps = { | ||
href: '#', | ||
isActive: false, | ||
isEnabled: false, | ||
isComplete: false, | ||
isError: false, | ||
number: null, | ||
}; | ||
ProgressStep.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
href: PropTypes.string, | ||
isActive: PropTypes.bool, | ||
isEnabled: PropTypes.bool, | ||
isError: PropTypes.bool, | ||
isComplete: PropTypes.bool, | ||
number: PropTypes.number, | ||
}; | ||
|
||
export const SubmissionStep = () => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<ProgressStep>{formatMessage(messages.createSubmission)}</ProgressStep> | ||
); | ||
}; | ||
|
||
export const TrainingStep = () => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<ProgressStep>{formatMessage(messages.practice)}</ProgressStep> | ||
); | ||
}; | ||
|
||
export const SelfAssessStep = () => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<ProgressStep>{formatMessage(messages.selfAssess)}</ProgressStep> | ||
); | ||
}; | ||
|
||
export const PeerAssessStep = () => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<ProgressStep>{formatMessage(messages.peerAssess)}</ProgressStep> | ||
); | ||
}; | ||
|
||
export const MyGradeStep = () => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<ProgressStep>{formatMessage(messages.myGrade)}</ProgressStep> | ||
); | ||
}; | ||
|
||
export const ProgressBar = () => { | ||
const stepConfig = useAssessmentStepConfig(); | ||
const progress = useProgressData(); | ||
const isLoaded = useIsPageDataLoaded(); | ||
const location = useLocation(); | ||
if (!isLoaded) { | ||
return null; | ||
} | ||
console.log({ | ||
stepConfig, progress, location, | ||
}); | ||
return ( | ||
<Navbar> | ||
<Navbar.Collapse className="ora-progress-nav-group"> | ||
<hr className="ora-progress-divider" /> | ||
<SubmissionStep /> | ||
{stepConfig.order.map(step => { | ||
if (step === 'peer') { | ||
return <PeerAssessStep />; | ||
} | ||
if (step === 'training') { | ||
return <TrainingStep />; | ||
} | ||
if (step === 'self') { | ||
return <SelfAssessStep />; | ||
} | ||
return null; | ||
})} | ||
<MyGradeStep /> | ||
</Navbar.Collapse> | ||
</Navbar> | ||
); | ||
}; | ||
|
||
export default ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.ora-progress-nav-group { | ||
display: flex; | ||
justify-content: space-between; | ||
.ora-progress-divider { | ||
position: absolute; | ||
width: 95%; | ||
} | ||
.ora-progress-nav { | ||
background-color: white; | ||
z-index: 5; | ||
font-size: 1.125rem; | ||
&.is-active { | ||
border-bottom: 2px solid black; | ||
} | ||
} | ||
.nav-icon { | ||
display: inline-block; | ||
margin-inline-end: 0.5rem; | ||
margin-left: -0.25rem; | ||
} | ||
.number-icon { | ||
background-color: black; | ||
color: white; | ||
border-radius: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
createSubmission: { | ||
id: 'ora-grading.ProgressBar.createSubmission', | ||
defaultMessage: 'Create your response', | ||
description: 'Create response progress indicator', | ||
}, | ||
practice: { | ||
id: 'ora-grading.ProgressBar.practice', | ||
defaultMessage: 'Practice grading', | ||
description: 'Student training step progress indicator', | ||
}, | ||
selfAssess: { | ||
id: 'ora-grading.ProgressBar.selfAssess', | ||
defaultMessage: 'Grade yourself', | ||
description: 'Self assessment step progress indicator', | ||
}, | ||
peerAssess: { | ||
id: 'ora-grading.ProgressBar.peerAssess', | ||
defaultMessage: 'Grade peers', | ||
description: 'Peer assessment step progress indicator', | ||
}, | ||
myGrade: { | ||
id: 'ora-grading.ProgressBar.myGrade', | ||
defaultMessage: 'My grade', | ||
description: 'My Grade step progress indicator', | ||
}, | ||
}); | ||
|
||
export default messages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
/* The purpose of this component is to wrap views with a header/footer for situations | ||
* where we need to run non-embedded | ||
*/ | ||
|
||
const AppContainer = ({ Component }) => ( | ||
<div> | ||
<Component /> | ||
</div> | ||
); | ||
AppContainer.propTypes = { | ||
Component: PropTypes.elementType.isRequired, | ||
}; | ||
|
||
export default AppContainer; |
Oops, something went wrong.