diff --git a/client/src/templates/Introduction/components/block.tsx b/client/src/templates/Introduction/components/block.tsx index 191c6447045..1492ba8f53a 100644 --- a/client/src/templates/Introduction/components/block.tsx +++ b/client/src/templates/Introduction/components/block.tsx @@ -25,7 +25,11 @@ import { BlockTypes } from '../../../../../shared-dist/config/blocks'; import CheckMark from './check-mark'; -import Challenges from './challenges'; +import { + GridMapChallenges, + ChallengesList, + ChallengesWithDialogues +} from './challenges'; import BlockLabel from './block-label'; import BlockIntros from './block-intros'; import BlockHeader from './block-header'; @@ -220,12 +224,7 @@ export class Block extends Component { - {isExpanded && ( - - )} + {isExpanded && } ); @@ -257,10 +256,7 @@ export class Block extends Component { )} - + ); @@ -304,10 +300,55 @@ export class Block extends Component {
- +
+ + )} + + + ); + + /** + * TaskGridBlock displays tasks in a grid and dialogues separately. + * This layout is used for task-based blocks. + * Example: https://www.freecodecamp.org/learn/a2-english-for-developers/#learn-greetings-in-your-first-day-at-the-office + */ + const TaskGridBlock = ( + +
+ + + {isExpanded && ( + <> + {!isAudited && ( +
+ + {t('misc.translation-pending')} + +
+ )} + +
+ +
@@ -412,12 +453,15 @@ export class Block extends Component { id={`${block}-panel`} className={isGridBlock ? 'challenge-grid-block-panel' : ''} > - + {isGridBlock ? ( + + ) : ( + + )}
)} @@ -433,7 +477,7 @@ export class Block extends Component { [BlockLayouts.LegacyLink]: LegacyLinkBlock, [BlockLayouts.LegacyChallengeList]: LegacyChallengeListBlock, [BlockLayouts.LegacyChallengeGrid]: LegacyChallengeGridBlock, - [BlockLayouts.DialogueGrid]: LegacyChallengeGridBlock + [BlockLayouts.DialogueGrid]: TaskGridBlock }; return ( diff --git a/client/src/templates/Introduction/components/challenges.tsx b/client/src/templates/Introduction/components/challenges.tsx index 8d166763513..d686c43d7fa 100644 --- a/client/src/templates/Introduction/components/challenges.tsx +++ b/client/src/templates/Introduction/components/challenges.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { withTranslation, useTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import GreenNotCompleted from '../../../assets/icons/green-not-completed'; import GreenPass from '../../../assets/icons/green-pass'; @@ -18,11 +18,16 @@ interface ChallengeInfo { challengeType: number; } -interface Challenges { +interface ChallengesProps { challenges: ChallengeInfo[]; +} + +interface BlockTitleProps { + blockTitle: string; +} + +interface IsProjectBlockProps { isProjectBlock: boolean; - isGridMap?: boolean; - blockTitle?: string | null; } const CheckMark = ({ isCompleted }: { isCompleted: boolean }) => @@ -46,21 +51,40 @@ const CertChallenge = ({ challenge }: { challenge: ChallengeInfo }) => ( ); +export function ChallengesList({ challenges }: ChallengesProps): JSX.Element { + return ( +
    + {challenges.map(challenge => ( +
  • + +
  • + ))} +
+ ); +} // Step or Task challenge -const GridChallenge = ({ challenge }: { challenge: ChallengeInfo }) => { +const GridChallenge = ({ + challenge, + isTask = false +}: { + challenge: ChallengeInfo; + isTask?: boolean; +}) => { const { t } = useTranslation(); return ( - {challenge.superBlock === SuperBlocks.A2English - ? t('aria.task') - : t('aria.step')} + {isTask ? t('aria.task') : t('aria.step')} {challenge.stepNumber} @@ -70,12 +94,10 @@ const GridChallenge = ({ challenge }: { challenge: ChallengeInfo }) => { ); }; -function Challenges({ +const LinkToFirstIncompleteChallenge = ({ challenges, - isProjectBlock, - isGridMap = false, blockTitle -}: Challenges): JSX.Element { +}: ChallengesProps & BlockTitleProps) => { const { t } = useTranslation(); const firstIncompleteChallenge = challenges.find( @@ -85,28 +107,32 @@ function Challenges({ const isChallengeStarted = !!challenges.find( challenge => challenge.isCompleted ); + return firstIncompleteChallenge ? ( +
+ + {!isChallengeStarted + ? t('buttons.start-project') + : t('buttons.resume-project')}{' '} + {blockTitle} + +
+ ) : null; +}; - return isGridMap ? ( +export const GridMapChallenges = ({ + challenges, + blockTitle, + isProjectBlock +}: ChallengesProps & BlockTitleProps & IsProjectBlockProps) => { + const { t } = useTranslation(); + + return ( <> - {firstIncompleteChallenge && ( -
- - {!isChallengeStarted - ? t('buttons.start-project') - : t('buttons.resume-project')}{' '} - {blockTitle && {blockTitle}} - -
- )} -