-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add placeholder custom crossword layout
- Loading branch information
Showing
1 changed file
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | ||
); |