-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bw/fake data
- Loading branch information
Showing
54 changed files
with
1,106 additions
and
669 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
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,78 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
import { StrictDict } from '@edx/react-unit-test-utils'; | ||
import { Nav, Icon } from '@edx/paragon'; | ||
import { | ||
CheckCircle, | ||
Edit, | ||
Error, | ||
Highlight, | ||
Rule, | ||
} from '@edx/paragon/icons'; | ||
|
||
import { stepNames } from 'data/services/lms/constants'; | ||
import { useProgressStepData } from './hooks'; | ||
|
||
export const stepIcons = StrictDict({ | ||
[stepNames.submission]: Edit, | ||
[stepNames.studentTraining]: Highlight, | ||
[stepNames.self]: Highlight, | ||
[stepNames.peer]: Highlight, | ||
[stepNames.myGrades]: Rule, | ||
}); | ||
|
||
const ProgressStep = ({ | ||
step, | ||
canRevisit, | ||
label, | ||
}) => { | ||
const { | ||
href, | ||
isActive, | ||
isEnabled, | ||
isComplete, | ||
isPastDue, | ||
myGrade, | ||
} = useProgressStepData({ step, canRevisit }); | ||
let iconSrc = stepIcons[step]; | ||
let subLabel = null; | ||
let colorClass = null; | ||
if (isPastDue) { | ||
colorClass = 'text-danger-500'; | ||
iconSrc = Error; | ||
subLabel = 'Past due!'; | ||
} else if (isComplete) { | ||
iconSrc = CheckCircle; | ||
if (step === stepNames.myGrades && myGrade) { | ||
subLabel = `${myGrade.earned} / ${myGrade.possible}`; | ||
} | ||
} | ||
return ( | ||
<Nav.Link | ||
{...(!isActive && { href })} | ||
disabled={!isEnabled} | ||
className={classNames( | ||
'ora-progress-nav', | ||
'px-4', | ||
{ 'is-active': isActive }, | ||
)} | ||
> | ||
<Icon className={classNames('nav-icon', colorClass)} src={iconSrc} /> | ||
<div className="d-inline-block"> | ||
{label} | ||
{subLabel && ( | ||
<p className={classNames('x-small', colorClass)}>{subLabel}</p> | ||
)} | ||
</div> | ||
</Nav.Link> | ||
); | ||
}; | ||
ProgressStep.propTypes = { | ||
label: PropTypes.node.isRequired, | ||
step: PropTypes.string.isRequired, | ||
canRevisit: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export default ProgressStep; |
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,40 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import { useActiveView, useIsEmbedded } from 'hooks'; | ||
import { useStepState, useEffectiveGrade } from 'data/services/lms/hooks/selectors'; | ||
import { | ||
routeSteps, | ||
stepRoutes, | ||
stepStates, | ||
} from 'data/services/lms/constants'; | ||
|
||
export const useProgressStepData = ({ step, canRevisit = false }) => { | ||
const { xblockId } = useParams(); | ||
const isEmbedded = useIsEmbedded(); | ||
const activeView = useActiveView(); | ||
const viewStep = routeSteps[activeView]; | ||
const stepState = useStepState({ step }); | ||
|
||
const href = `/${stepRoutes[step]}${isEmbedded ? '/embedded' : ''}/${xblockId}`; | ||
const isActive = viewStep === step; | ||
const isEnabled = ( | ||
isActive | ||
|| (stepState === stepStates.inProgress) | ||
|| (canRevisit && stepState === stepStates.completed) | ||
); | ||
const myGrade = useEffectiveGrade()?.stepScore; | ||
|
||
return { | ||
href, | ||
isEnabled, | ||
isActive, | ||
isComplete: stepState === stepStates.completed, | ||
inProgress: stepState === stepStates.inProgress, | ||
isPastDue: stepState === stepStates.closed, | ||
myGrade, | ||
// myGrade: { earned: 8, possible: 10 }, | ||
// isPastDue: step === 'self', | ||
|
||
}; | ||
}; | ||
|
||
export default { useProgressStepData }; |
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 |
---|---|---|
|
@@ -23,4 +23,7 @@ | |
color: white; | ||
border-radius: 100%; | ||
} | ||
.active { | ||
border-bottom: 2px solid black; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.