-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Crossword
component to dev kitchen (#1753)
Co-authored-by: oliverabrahams <[email protected]>
- Loading branch information
1 parent
9276860
commit 3484635
Showing
76 changed files
with
8,913 additions
and
12 deletions.
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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
libs/@guardian/source-development-kitchen/src/react-components/crossword/@types/crossword.ts
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export type CrosswordData = { | ||
creator?: { | ||
name: string; | ||
webUrl: string; | ||
}; | ||
crosswordType: | ||
| 'cryptic' | ||
| 'everyman' | ||
| 'prize' | ||
| 'quick-cryptic' | ||
| 'quick' | ||
| 'quiptic' | ||
| 'special' | ||
| 'speedy' | ||
| 'weekend'; | ||
|
||
date: number; | ||
dateSolutionAvailable?: number; | ||
dimensions: { | ||
cols: number; | ||
rows: number; | ||
}; | ||
entries: Array<{ | ||
clue: string; | ||
direction: 'across' | 'down'; | ||
group: string[]; | ||
humanNumber: string; | ||
id: string; | ||
length: number; | ||
number: number; | ||
position: { x: number; y: number }; | ||
separatorLocations: { | ||
','?: number[] | undefined; | ||
'-'?: number[] | undefined; | ||
}; | ||
solution?: string; | ||
}>; | ||
id: string; | ||
name: string; | ||
number: number; | ||
pdf?: string; | ||
solutionAvailable: boolean; | ||
webPublicationDate?: number; | ||
instructions?: string; | ||
}; |
50 changes: 50 additions & 0 deletions
50
...@guardian/source-development-kitchen/src/react-components/crossword/Crossword.stories.tsx
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import type { CrosswordProps } from './Crossword'; | ||
import { Crossword } from './Crossword'; | ||
import { cryptic } from './stories/cryptic'; | ||
import { everyman } from './stories/everyman'; | ||
import { prize } from './stories/prize'; | ||
import { quick } from './stories/quick'; | ||
import { quickCryptic } from './stories/quick-cryptic'; | ||
import { quiptic } from './stories/quiptic'; | ||
import { special } from './stories/special'; | ||
import { speedy } from './stories/speedy'; | ||
import { weekend } from './stories/weekend'; | ||
|
||
const meta: Meta<typeof Crossword> = { | ||
component: Crossword, | ||
title: 'React Components/Crossword', | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<typeof Crossword> = (args: CrosswordProps) => { | ||
return <Crossword {...args} />; | ||
}; | ||
|
||
export const Cryptic: StoryFn<typeof Crossword> = Template.bind({}); | ||
Cryptic.args = { data: cryptic }; | ||
|
||
export const Everyman: StoryFn<typeof Crossword> = Template.bind({}); | ||
Everyman.args = { data: everyman }; | ||
|
||
export const Prize: StoryFn<typeof Crossword> = Template.bind({}); | ||
Prize.args = { data: prize }; | ||
|
||
export const Quick: StoryFn<typeof Crossword> = Template.bind({}); | ||
Quick.args = { data: quick }; | ||
|
||
export const QuickCryptic: StoryFn<typeof Crossword> = Template.bind({}); | ||
QuickCryptic.args = { data: quickCryptic }; | ||
|
||
export const Quiptic: StoryFn<typeof Crossword> = Template.bind({}); | ||
Quiptic.args = { data: quiptic }; | ||
|
||
export const Special: StoryFn<typeof Crossword> = Template.bind({}); | ||
Special.args = { data: special }; | ||
|
||
export const Speedy: StoryFn<typeof Crossword> = Template.bind({}); | ||
Speedy.args = { data: speedy }; | ||
|
||
export const Weekend: StoryFn<typeof Crossword> = Template.bind({}); | ||
Weekend.args = { data: weekend }; |
37 changes: 37 additions & 0 deletions
37
libs/@guardian/source-development-kitchen/src/react-components/crossword/Crossword.tsx
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { css } from '@emotion/react'; | ||
import { palette } from '@guardian/source/foundations'; | ||
import type { CrosswordData } from './@types/crossword'; | ||
import { CrosswordPlayer } from './vendor/mycrossword'; | ||
|
||
export type CrosswordProps = { | ||
data: CrosswordData; | ||
theme?: { | ||
background?: string; | ||
grid?: string; | ||
}; | ||
}; | ||
|
||
const defaultTheme: CrosswordProps['theme'] = { | ||
background: palette.neutral[100], | ||
grid: palette.neutral[7], | ||
}; | ||
|
||
export const Crossword = ({ | ||
theme: userTheme, | ||
data, | ||
...props | ||
}: CrosswordProps) => { | ||
const theme = { ...defaultTheme, ...userTheme }; | ||
|
||
return ( | ||
<div | ||
css={css` | ||
background-color: ${theme.background}; | ||
border: ${theme.grid} solid 1px; | ||
`} | ||
{...props} | ||
> | ||
<CrosswordPlayer data={data} id={data.id} /> | ||
</div> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
libs/@guardian/source-development-kitchen/src/react-components/crossword/README.md
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# `Crossword` | ||
|
||
A standalone component for rendering crosswords. | ||
|
||
## Install | ||
|
||
```sh | ||
$ pnpm add @guardian/source-development-kitchen | ||
``` | ||
|
||
or | ||
|
||
```sh | ||
$ npm i @guardian/source-development-kitchen | ||
``` | ||
|
||
## Use | ||
|
||
### API | ||
|
||
See [storybook](https://guardian.github.io/storybooks/?path=/docs/source-development-kitchen_react-components-crossword--docs) |
Oops, something went wrong.