diff --git a/client/src/templates/Introduction/components/block-header.tsx b/client/src/templates/Introduction/components/block-header.tsx index f2009ac1f6b..408e2b7f223 100644 --- a/client/src/templates/Introduction/components/block-header.tsx +++ b/client/src/templates/Introduction/components/block-header.tsx @@ -50,7 +50,7 @@ function BlockHeader({ - {!isEmpty(blockIntroArr) && ( + {isExpanded && !isEmpty(blockIntroArr) && ( )} {!isExpanded && !isCompleted && completedCount > 0 && ( diff --git a/client/src/templates/Introduction/components/block.css b/client/src/templates/Introduction/components/block.css new file mode 100644 index 00000000000..8f7fb1d192e --- /dev/null +++ b/client/src/templates/Introduction/components/block.css @@ -0,0 +1,17 @@ +/* these are all used in the AccordionBlock() layout in Block.tsx */ +.accordion-block-expanded { + padding: 0 24px; +} + +.accordion-block-expanded .block-description { + padding: 18px 15px; + border-bottom: 1px solid var(--secondary-background); +} + +.accordion-block-expanded .challenge-jump-link { + margin: 0 15px 25px; +} + +.accordion-block-expanded .map-challenges-grid { + margin: 0 15px 18px; +} diff --git a/client/src/templates/Introduction/components/block.test.tsx b/client/src/templates/Introduction/components/block.test.tsx index c039b46bb96..a071c65f974 100644 --- a/client/src/templates/Introduction/components/block.test.tsx +++ b/client/src/templates/Introduction/components/block.test.tsx @@ -20,6 +20,13 @@ jest.mock('../../../../../shared/utils/is-audited', () => ({ isAuditedSuperBlock: jest.fn().mockReturnValueOnce(true) })); +jest.mock('../redux', () => ({ + makeExpandedBlockSelector: jest.fn(() => jest.fn(() => true)), + completedChallengesSelector: jest.fn(() => [ + { id: 'mockId', title: 'mockTitle' } + ]) +})); + const defaultProps = { block: 'test-block', blockType: null, @@ -69,7 +76,7 @@ const defaultProps = { }, sourceInstanceName: 'mockSourceInstanceName', superOrder: 1, - superBlock: SuperBlocks.RespWebDesign, + superBlock: SuperBlocks.FullStackDeveloper, tail: ['mockTail'], template: 'mockTemplate', tests: [] as Test[], @@ -84,9 +91,9 @@ const defaultProps = { } ], completedChallengeIds: ['testchallengeIds'], - isExpanded: false, + isExpanded: true, t: jest.fn((key: string) => [key]), - superBlock: SuperBlocks.RespWebDesign, + superBlock: SuperBlocks.FullStackDeveloper, toggleBlock: jest.fn() }; diff --git a/client/src/templates/Introduction/components/block.tsx b/client/src/templates/Introduction/components/block.tsx index e9b6df12f1b..a2f8d8cd9aa 100644 --- a/client/src/templates/Introduction/components/block.tsx +++ b/client/src/templates/Introduction/components/block.tsx @@ -26,6 +26,7 @@ import BlockIntros from './block-intros'; import BlockHeader from './block-header'; import '../intro.css'; +import './block.css'; const { curriculumLocale } = envData; @@ -107,7 +108,7 @@ class Block extends Component { return isProjectBased(challenge.challengeType, block); }); - const isGridBlock = challenges.some(challenge => { + const isGridSuperBlock = challenges.some(challenge => { return isGridBased(superBlock, challenge.challengeType); }); @@ -133,6 +134,7 @@ class Block extends Component { // not being used to render anything const link = challenges[0]?.fields.slug || ''; const blockLayout = challenges[0]?.blockLayout; + const isGridBlock = blockLayout === BlockLayouts.ChallengeGrid; const isEmptyBlock = !challenges.length; @@ -256,26 +258,30 @@ class Block extends Component { isExpanded={isExpanded} percentageCompleted={percentageCompleted} /> - {!isAudited && ( -
- - {t('misc.translation-pending')} - -
- )} + {isExpanded && ( -
- - -
+ <> + {!isAudited && ( +
+ + {t('misc.translation-pending')} + +
+ )} + +
+ + +
+ )} @@ -331,104 +337,9 @@ class Block extends Component { ); /** - * ChallengeListBlock displays challenges in a list. - * Created for the new Full Stack Developer Certification, - * so we can play with it without affecting the existing block layouts. + * AccordionBlock is used as the block layout in new accordion style superblocks. */ - const ChallengeListBlock = ( - <> - - - -
- - {!isAudited && ( -
- - {t('misc.translation-pending')} - -
- )} - {isExpanded && ( -
- -
- )} -
- - ); - - /** - * LinkBlock displays the block as a single link. - * This layout is used if the block has a single challenge. - * Created for the new Full Stack Developer Certification, - * so we can play with it without affecting the existing block layouts. - */ - const LinkBlock = ( - <> - - - -
-
- {!isAudited && ( - - {t('misc.translation-pending')}{' '} - - )} -
-
-

- { - this.handleBlockClick(); - }} - to={link} - > - - {blockType && } - {blockTitle} - - {isBlockCompleted - ? `, ${t('learn.completed')}` - : `, ${t('learn.not-completed')}`} - - -

-
- -
- - ); - - /** - * ChallengeGridBlock displays challenges in a grid. - * This layout is specifically used for the new Full Stack Developer Certification. - */ - const ChallengeGridBlock = ( + const AccordionBlock = ( <> @@ -448,24 +359,30 @@ class Block extends Component { percentageCompleted={percentageCompleted} blockIntroArr={blockIntroArr} /> - {!isAudited && ( -
- - {t('misc.translation-pending')} - -
- )} + {isExpanded && ( -
- +
+ {!isAudited && ( +
+ + {t('misc.translation-pending')} + +
+ )} +
+ +
)}
@@ -473,9 +390,9 @@ class Block extends Component { ); const layoutToComponent = { - [BlockLayouts.ChallengeGrid]: ChallengeGridBlock, - [BlockLayouts.ChallengeList]: ChallengeListBlock, - [BlockLayouts.Link]: LinkBlock, + [BlockLayouts.ChallengeGrid]: AccordionBlock, + [BlockLayouts.ChallengeList]: AccordionBlock, + [BlockLayouts.Link]: AccordionBlock, [BlockLayouts.ProjectList]: ProjectListBlock, [BlockLayouts.LegacyLink]: LegacyLinkBlock, [BlockLayouts.LegacyChallengeList]: LegacyChallengeListBlock, @@ -486,7 +403,7 @@ class Block extends Component { !isEmptyBlock && ( <> {layoutToComponent[blockLayout]} - {(!isGridBlock || isProjectBlock) && + {(!isGridSuperBlock || isProjectBlock) && superBlock !== SuperBlocks.FullStackDeveloper && ( )} diff --git a/e2e/super-block-page.spec.ts b/e2e/super-block-page.spec.ts index 09d6cc564bb..4b489dcbcfe 100644 --- a/e2e/super-block-page.spec.ts +++ b/e2e/super-block-page.spec.ts @@ -123,7 +123,9 @@ test.describe('Super Block Page - Authenticated User', () => { // Module await expect( - page.getByRole('button', { name: /Basic CSS/ }) + page.getByRole('button', { + name: /Basic CSS \d+ of \d+ steps complete/ + }) ).toHaveAttribute('aria-expanded', 'true'); // Block @@ -153,7 +155,9 @@ test.describe('Super Block Page - Authenticated User', () => { // Basic HTML module await expect( - page.getByRole('button', { name: /Basic HTML/ }) + page.getByRole('button', { + name: /Basic HTML \d+ of \d+ steps complete/ + }) ).toHaveAttribute('aria-expanded', 'true'); // What is HTML block