Skip to content

Commit 6ec5418

Browse files
Puzzles/Polish the Puzzles and Games hub responsive layout (#16734)
* Add responsive ilustrated header * Improve puzzle image accesibility and display stters * Update to temporarily hide puzzles newsletter and popularity sections * Update to use guardian headline typography for puzzles useful links * Fix issue variable name * Update puzzles hub card styling and responsive dimensions * Fix puzzles hub alignment and header image resolution * Update crossword archive icon and add sidebar links * Add responsive separators between puzzle cards * Update to align useful links divider at wide breakpoint * Update to remove 768px breakpoint * Fix puzzles header tests * Update to replace puzzle colours with source palette tokens * Update to support dated puzzle routes with section-prefixed slugs * Update to rollback newslettersignup card we are not going to implement it yet
1 parent 8616c02 commit 6ec5418

12 files changed

Lines changed: 940 additions & 210 deletions

dotcom-rendering/src/components/PuzzlesArchiveMenu.island.tsx

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,18 @@ const wrapperStyles = css`
3333
position: relative;
3434
display: block;
3535
width: max-content;
36-
margin-top: ${space[1]}px;
36+
margin-top: ${space[2]}px;
3737
margin-left: auto;
3838
3939
${from.tablet} {
4040
margin-left: 0;
4141
}
42-
43-
&[open] .archive-arrow {
44-
transform: rotate(90deg);
45-
}
4642
`;
4743

4844
const summaryStyles = css`
45+
position: relative;
4946
display: inline-flex;
50-
min-height: 44px;
47+
min-height: 24px;
5148
align-items: center;
5249
gap: ${space[2]}px;
5350
padding: 0;
@@ -57,6 +54,12 @@ const summaryStyles = css`
5754
cursor: pointer;
5855
list-style: none;
5956
${textSans14};
57+
/* Preserve a 44px pointer target around the 24px archive label. */
58+
::before {
59+
position: absolute;
60+
inset: -10px 0;
61+
content: '';
62+
}
6063
6164
::-webkit-details-marker {
6265
display: none;
@@ -70,8 +73,8 @@ const summaryStyles = css`
7073
`;
7174

7275
const arrowStyles = css`
73-
display: inline-block;
74-
transition: transform 0.1s ease-out;
76+
display: block;
77+
flex-shrink: 0;
7578
`;
7679

7780
const menuStyles = css`
@@ -116,27 +119,27 @@ export const PuzzlesArchiveMenu = ({
116119
const summaryRef = useRef<HTMLElement>(null);
117120

118121
useEffect(() => {
119-
const close = (event: MouseEvent | KeyboardEvent) => {
122+
const close = (event: Event) => {
120123
const details = detailsRef.current;
121124
if (details?.open !== true) {
122125
return;
123126
}
124-
if (event instanceof KeyboardEvent && event.key !== 'Escape') {
125-
return;
126-
}
127-
if (
128-
event instanceof MouseEvent &&
129-
details.contains(event.target as Node)
130-
) {
127+
if (event instanceof KeyboardEvent) {
128+
if (event.key !== 'Escape') return;
129+
} else if (event.composedPath().includes(details)) {
131130
return;
132131
}
133132
details.open = false;
134133
if (event instanceof KeyboardEvent) summaryRef.current?.focus();
135134
};
136-
document.addEventListener('mousedown', close);
135+
document.addEventListener('pointerdown', close, true);
136+
document.addEventListener('mousedown', close, true);
137+
document.addEventListener('click', close, true);
137138
document.addEventListener('keydown', close);
138139
return () => {
139-
document.removeEventListener('mousedown', close);
140+
document.removeEventListener('pointerdown', close, true);
141+
document.removeEventListener('mousedown', close, true);
142+
document.removeEventListener('click', close, true);
140143
document.removeEventListener('keydown', close);
141144
};
142145
}, []);
@@ -153,13 +156,23 @@ export const PuzzlesArchiveMenu = ({
153156
<details css={wrapperStyles} ref={detailsRef}>
154157
<summary css={summaryStyles} ref={summaryRef}>
155158
{label}{' '}
156-
<span
159+
<svg
160+
width="9"
161+
height="5"
162+
viewBox="0 0 9 5"
163+
fill="none"
164+
xmlns="http://www.w3.org/2000/svg"
157165
aria-hidden="true"
158-
className="archive-arrow"
166+
focusable="false"
159167
css={arrowStyles}
160168
>
161-
{'>'}
162-
</span>
169+
<path
170+
fillRule="evenodd"
171+
clipRule="evenodd"
172+
d="M3.05176e-05 0.712324L3.82876 5H4.55936L8.38813 0.712328L7.69406 0L4.19403 3L0.694092 0L3.05176e-05 0.712324Z"
173+
fill="black"
174+
/>
175+
</svg>
163176
</summary>
164177
<ul aria-label={label} css={menuStyles}>
165178
{validArchives.map(({ archive, url }) => (

dotcom-rendering/src/components/PuzzlesDirectory.stories.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { breakpoints } from '@guardian/source/foundations';
22
import type { PuzzlesLayoutType } from '../types/puzzlesPage';
33
import { PuzzlesDirectory } from './PuzzlesDirectory';
44

5-
const previewImage =
6-
'https://i.guim.co.uk/img/uploads/2023/11/01/SaturdayEdition_-_5-3.jpg?width=600&dpr=1&s=none&crop=5%3A3';
7-
85
const layout: PuzzlesLayoutType = {
96
containers: [
107
{
@@ -17,26 +14,28 @@ const layout: PuzzlesLayoutType = {
1714
items: [
1815
[
1916
{
20-
id: 'ball',
21-
title: 'On the ball',
22-
type: 'quiz',
23-
set: 'all',
17+
id: 'featured-mini',
18+
title: 'Mini crossword',
19+
type: 'crossword',
20+
set: 'mini',
2421
cardVariant: 'large',
2522
cadence: 'Daily',
26-
image: previewImage,
27-
slug: 'on-the-ball',
28-
variant: 'iframe-page',
23+
image: 'https://i.guim.co.uk/img/uploads/2026/09/15/crossword-MINI.png?width=440&dpr=2&s=none',
24+
imageAlt: 'Mini crossword illustration',
25+
setter: 'Example setter',
26+
url: '/puzzles-and-games/crosswords/mini/1',
2927
backgroundColour: '#e5e5e5',
3028
},
3129
{
32-
id: 'film',
33-
title: 'Film reveal',
34-
type: 'quiz',
30+
id: 'featured-word-wheel',
31+
title: 'Word wheel',
32+
type: 'word-wheel',
3533
set: 'all',
3634
cardVariant: 'large',
3735
cadence: 'Daily',
38-
image: previewImage,
39-
slug: 'film-reveal',
36+
image: 'https://i.guim.co.uk/img/uploads/2026/09/15/word-games-WORD-WHEEL.png?width=440&dpr=2&s=none',
37+
imageAlt: 'Word wheel illustration',
38+
slug: 'word-wheel',
4039
variant: 'iframe-page',
4140
backgroundColour: '#e5e5e5',
4241
},

0 commit comments

Comments
 (0)