Skip to content

Commit

Permalink
add placeholder custom crossword layout
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed Dec 12, 2024
1 parent 61ad91b commit cb0428c
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion dotcom-rendering/src/components/Crossword.importable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,102 @@
import { css } from '@emotion/react';
import { Crossword as ReactCrossword } from '@guardian/react-crossword-next';
import type { CrosswordProps } from '@guardian/react-crossword-next';
import {
from,
headlineBold17,
palette,
space,
textSans12,
textSans14,
} from '@guardian/source/foundations';
import { memo } from 'react';

const CluesHeader = memo(({ direction }: { direction: 'across' | 'down' }) => {
return (
<div
css={css`
${headlineBold17};
border-top: 1px solid ${palette.neutral[86]};
border-bottom: 1px dotted ${palette.neutral[86]};
height: 2em;
margin-bottom: 0.5em;
`}
>
{direction}
</div>
);
});

const Layout: CrosswordProps['Layout'] = ({
Grid,
Clues,
Controls,
SavedMessage,
// gridWidth - coming in next version of package
}) => {
// replace with gridWidth from props when package is updated
const gridWidth = '496';

return (
<div
css={css`
display: flex;
flex-direction: column;
gap: ${space[4]}px;
${from.leftCol} {
flex-direction: row;
}
`}
>
<div
css={css`
flex-basis: ${gridWidth}px;
${from.leftCol} {
position: sticky;
top: ${space[4]}px;
align-self: flex-start;
}
`}
>
<Grid />
<Controls />
<div
css={css`
${textSans12};
font-style: italic;
`}
>
<SavedMessage />
</div>
</div>

<div
css={css`
${textSans14};
flex: 1;
display: flex;
flex-direction: column;
gap: ${space[4]}px;
align-items: flex-start;
> * {
flex: 1;
}
${from.wide} {
flex-direction: row;
}
`}
>
<Clues direction="across" Header={CluesHeader} />
<Clues direction="down" Header={CluesHeader} />
</div>
</div>
);
};

export const Crossword = (data: CrosswordProps['data']) => (
<ReactCrossword data={data} clueMinWidth={150} />
<ReactCrossword data={data} Layout={Layout} />
);

0 comments on commit cb0428c

Please sign in to comment.