diff --git a/.storybook/stories.js b/.storybook/stories.js index 0add68b..061f719 100644 --- a/.storybook/stories.js +++ b/.storybook/stories.js @@ -4,3 +4,4 @@ require('../src/components/SelectorInput/SelectorInput.story.js'); require('../src/components/MarkupRenderer/MarkupRenderer.story.js'); require('../src/components/BannedCharacters/BannedCharacters.story.js'); require('../src/components/Scoreboard/Scoreboard.story.js'); +require('../src/components/PuzzleTitle/PuzzleTitle.story.js'); diff --git a/scenarios/game/index.js b/scenarios/game/index.js index 13e968a..ae3decb 100644 --- a/scenarios/game/index.js +++ b/scenarios/game/index.js @@ -8,6 +8,8 @@ import { setPuzzle } from './puzzle'; countdown(); setPuzzle({ + title: 'Signing Up', + index: 1, markup :`
diff --git a/src/components/PuzzleTitle/PuzzleTitle.js b/src/components/PuzzleTitle/PuzzleTitle.js new file mode 100644 index 0000000..7c92744 --- /dev/null +++ b/src/components/PuzzleTitle/PuzzleTitle.js @@ -0,0 +1,34 @@ +import { h } from 'preact'; + +const textShadow = '0 1px 4px rgba(0, 0, 0, 0.15)'; +const margin = '0 0.3em 0 0;'; + +const PuzzleTitle = ({ index, title }) => ( +

+ #{index} + { title } + + +

+); + +export { PuzzleTitle }; diff --git a/src/components/PuzzleTitle/PuzzleTitle.story.js b/src/components/PuzzleTitle/PuzzleTitle.story.js new file mode 100644 index 0000000..2252d1a --- /dev/null +++ b/src/components/PuzzleTitle/PuzzleTitle.story.js @@ -0,0 +1,9 @@ +import { h } from 'preact'; +import { storiesOf } from '@storybook/react'; + +import { PuzzleTitle } from './PuzzleTitle'; + +storiesOf('PuzzleTitle', module) + .add('default', () => ( + + )); diff --git a/src/game/components/RoundLayout.js b/src/game/components/RoundLayout.js index 48c4ca5..d3bb002 100644 --- a/src/game/components/RoundLayout.js +++ b/src/game/components/RoundLayout.js @@ -8,6 +8,7 @@ const RoundLayout = ({ children }) => { return (
+ { components.PuzzleTitle } { components.BannedCharacters }
diff --git a/src/game/containers/RoundContainer.js b/src/game/containers/RoundContainer.js index 50260dc..3ef07b0 100644 --- a/src/game/containers/RoundContainer.js +++ b/src/game/containers/RoundContainer.js @@ -9,13 +9,20 @@ import { MarkupRenderer } from '../../components/MarkupRenderer/MarkupRenderer'; import { withDotSelectionIndicator } from '../../components/MarkupRenderer/with-dot-selection-indicator'; import { Line } from '../../components/MarkupRenderer/Line'; import { BannedCharacters } from '../../components/BannedCharacters/BannedCharacters'; +import { PuzzleTitle } from '../../components/PuzzleTitle/PuzzleTitle'; import * as RoundPhase from '../../shared/constants/round-phase'; import { DURATION } from '../../shared/constants/round'; import { phase } from '../../shared/selectors/round-phase-selectors'; import { countdown } from '../../shared/selectors/countdown-selectors'; -import { expectedSelection, bannedChars, markup} from '../../shared/selectors/puzzle-selectors'; +import { + expectedSelection, + bannedChars, + markup, + index as puzzleIndex, + title as puzzleTitle, +} from '../../shared/selectors/puzzle-selectors'; import { selector, selection } from '../selectors/solution-selectors'; import { highlightedBannedChars } from '../selectors/round-selectors'; @@ -31,8 +38,14 @@ const PureRound = ({ actualSelection, bannedChars, highlightedBannedChars, + puzzleIndex, + puzzleTitle, }) => roundPhase !== RoundPhase.IN_PROGRESS && roundPhase !== RoundPhase.FINISHED ? null : + state.puzzle; +export const title = createSelector([puzzle], puzzle => puzzle.title); +export const index = createSelector([puzzle], puzzle => puzzle.index); export const bannedChars = createSelector([puzzle], puzzle => puzzle.bannedChars); export const markup = createSelector([puzzle], puzzle => puzzle.markup); export const expectedSelection = createSelector([puzzle], puzzle => puzzle.expectedSelection);