feat: simplify superblock layouts (#59260)

This commit is contained in:
Oliver Eyton-Williams
2025-03-13 07:46:39 +01:00
committed by GitHub
parent f648dac32f
commit a87df1adc8
2 changed files with 4 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ import { Link } from '../../../components/helpers';
import { completedChallengesSelector } from '../../../redux/selectors';
import { playTone } from '../../../utils/tone';
import { makeExpandedBlockSelector, toggleBlock } from '../redux';
import { isGridBased, isProjectBased } from '../../../utils/curriculum-layout';
import { isProjectBased } from '../../../utils/curriculum-layout';
import { BlockLayouts, BlockTypes } from '../../../../../shared/config/blocks';
import CheckMark from './check-mark';
import Challenges from './challenges';
@@ -115,10 +115,6 @@ class Block extends Component<BlockProps> {
return isProjectBased(challenge.challengeType, block);
});
const isGridSuperBlock = challenges.some(challenge => {
return isGridBased(superBlock, challenge.challengeType);
});
const isAudited = isAuditedSuperBlock(curriculumLocale, superBlock);
const blockTitle = t(`intro:${superBlock}.blocks.${block}.title`);
@@ -410,10 +406,9 @@ class Block extends Component<BlockProps> {
!isEmptyBlock && (
<>
{layoutToComponent[blockLayout]}
{(!isGridSuperBlock || isProjectBlock) &&
superBlock !== SuperBlocks.FullStackDeveloper && (
<Spacer size='m' />
)}
{superBlock !== SuperBlocks.FullStackDeveloper && (
<Spacer size='xs' />
)}
</>
)
);

View File

@@ -1,26 +1,4 @@
import { challengeTypes } from '../../../shared/config/challenge-types';
import { SuperBlocks } from '../../../shared/config/curriculum';
// Show a grid layout on the superblock level
const gridBasedSuperBlocks = [
SuperBlocks.RespWebDesignNew,
SuperBlocks.JsAlgoDataStructNew,
SuperBlocks.SciCompPy,
SuperBlocks.A2English
];
export const isGridBased = (
superBlock: SuperBlocks,
challengeType: unknown = null
) => {
// Python projects should not be displayed as a grid, but should be displayed
// as a list of projects. Otherwise, if we do not do this the project will be
// shown as a single certification project.
if (challengeType === challengeTypes.pythonProject) return false;
return gridBasedSuperBlocks.includes(superBlock);
};
// Show a single project in a certification layout