Skip to content

Commit

Permalink
Merge branch 'e2e/add-react-crossword' of github.com:guardian/dotcom-…
Browse files Browse the repository at this point in the history
…rendering into e2e/add-react-crossword
  • Loading branch information
sndrs committed Dec 12, 2024
2 parents 4212c19 + 53a0cef commit bf139e7
Show file tree
Hide file tree
Showing 14 changed files with 812 additions and 45 deletions.
1 change: 1 addition & 0 deletions dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@guardian/libs": "19.2.1",
"@guardian/ophan-tracker-js": "2.2.5",
"@guardian/react-crossword": "2.0.2",
"@guardian/react-crossword-next": "npm:@guardian/[email protected]",
"@guardian/shimport": "1.0.2",
"@guardian/source": "8.0.0",
"@guardian/source-development-kitchen": "12.0.0",
Expand Down
22 changes: 18 additions & 4 deletions dotcom-rendering/scripts/env/check-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@ if (pkg.devDependencies) {
process.exit(1);
}

const mismatches = Object.entries(pkg.dependencies).filter(
([, version]) =>
!semver.valid(version) && !version.startsWith('workspace:'),
);
/**
* We don't check packages that are not semver-compatible
* @type {RegExp[]}
*/
const exceptions = /** @type {const} */ ([
/npm:@guardian\/[email protected]/,
]);

const mismatches = Object.entries(pkg.dependencies)
.filter(
([, version]) =>
!exceptions.some((exception) => exception.test(version)),
)

.filter(
([, version]) =>
!semver.valid(version) && !version.startsWith('workspace:'),
);

if (mismatches.length !== 0) {
warn('dotcom-rendering dependencies should be pinned.');
Expand Down
6 changes: 6 additions & 0 deletions dotcom-rendering/src/components/Crossword.importable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Crossword as ReactCrossword } from '@guardian/react-crossword-next';
import type { CrosswordProps } from '@guardian/react-crossword-next';

export const Crossword = (data: CrosswordProps['data']) => (
<ReactCrossword data={data} clueMinWidth={150} />
);
7 changes: 7 additions & 0 deletions dotcom-rendering/src/lib/renderElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CartoonComponent } from '../components/CartoonComponent';
import { ChartAtom } from '../components/ChartAtom.importable';
import { CodeBlockComponent } from '../components/CodeBlockComponent';
import { CommentBlockComponent } from '../components/CommentBlockComponent';
import { Crossword } from '../components/Crossword.importable';
import { DividerBlockComponent } from '../components/DividerBlockComponent';
import { DocumentBlockComponent } from '../components/DocumentBlockComponent.importable';
import { EmailSignUpWrapper } from '../components/EmailSignUpWrapper';
Expand Down Expand Up @@ -841,6 +842,12 @@ export const renderElement = ({
case 'model.dotcomrendering.pageElements.DisclaimerBlockElement': {
return <AffiliateDisclaimerInline />;
}
case 'model.dotcomrendering.pageElements.CrosswordElement':
return (
<Island priority="critical" defer={{ until: 'visible' }}>
<Crossword {...element.crossword} />
</Island>
);
case 'model.dotcomrendering.pageElements.AudioBlockElement':
case 'model.dotcomrendering.pageElements.ContentAtomBlockElement':
case 'model.dotcomrendering.pageElements.GenericAtomBlockElement':
Expand Down
Loading

0 comments on commit bf139e7

Please sign in to comment.