Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle crossword articles #12925

Merged
merged 25 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2b3b50b
initial addition of crossword player
sndrs Dec 9, 2024
05ed396
dont use ambient types
sndrs Dec 12, 2024
eaaaaf8
put comments in the right place
sndrs Dec 12, 2024
841fc88
remove custom styling of crossword instructions
sndrs Dec 12, 2024
25813d0
render crosswords as a normal article
sndrs Dec 12, 2024
841001d
remove unnecessary div
sndrs Dec 12, 2024
75069d7
don’t override crossword `format.design` in enhancer
sndrs Dec 12, 2024
4efb62b
no `CrosswordLinks` custom styles
sndrs Dec 12, 2024
bb9f687
mutate lcoal scope for legiblity
sndrs Dec 12, 2024
f3b9feb
removing crossowrd formatting
sndrs Dec 12, 2024
8c33976
update schemas
sndrs Dec 12, 2024
73a5071
crossword instructions are in the main type
sndrs Dec 12, 2024
516c59f
pass the data in a proper prop, don't spread it
sndrs Dec 16, 2024
74c40a1
remove unnecessary `const`
sndrs Dec 16, 2024
633aabd
this is not needed now
sndrs Dec 16, 2024
6b21e8e
bump package
sndrs Dec 16, 2024
b8ebcf6
Merge branch 'main' into e2e/add-react-crossword
oliverabrahams Jan 14, 2025
0fcbe3a
move adding the crossword into the enhanceBlocks.ts / article.ts file…
oliverabrahams Jan 14, 2025
0c590a6
update canary version
oliverabrahams Jan 14, 2025
b3b073e
dont push to array blocks
oliverabrahams Jan 14, 2025
c2da646
change option to allow for more blocks to be added
oliverabrahams Jan 14, 2025
57b0a17
remove inferred types
oliverabrahams Jan 14, 2025
12d7460
Merge branch 'main' into e2e/add-react-crossword
oliverabrahams Jan 14, 2025
5d0ce6b
Add additional blocks in enhanceArticleType
arelra Jan 16, 2025
9adadc5
Merge branch 'main' into e2e/add-react-crossword
oliverabrahams Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/react-crossword@0.0.0-canary-20250114144251",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be preferable to use a release version rather than a canary, particularly before we move to a >0% size test.

"@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\/react-crossword@0.0.0-canary/,
]);

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 }: { 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 @@ -860,6 +861,12 @@ export const renderElement = ({
case 'model.dotcomrendering.pageElements.DisclaimerBlockElement': {
return <AffiliateDisclaimerInline />;
}
case 'model.dotcomrendering.pageElements.CrosswordElement':
return (
<Island priority="critical" defer={{ until: 'visible' }}>
<Crossword data={element.crossword} />
</Island>
);
case 'model.dotcomrendering.pageElements.AudioBlockElement':
case 'model.dotcomrendering.pageElements.ContentAtomBlockElement':
case 'model.dotcomrendering.pageElements.GenericAtomBlockElement':
Expand Down
Loading
Loading