Code Monkey home page Code Monkey logo

react-crossword's Introduction

react-crossword: A flexible, responsive, and easy-to-use crossword component for React apps.

npm version build status code coverage
known vulnerabilities dependencies
license more badges commitizen friendly semantic-release contributors

Please see the complete docs for in-depth details.


Install

npm install --save @jaredreisinger/react-crossword
  # or #
yarn add @jaredreisinger/react-crossword

Usage

import React from 'react';

import Crossword from '@jaredreisinger/react-crossword';

const data = {
  /* ... puzzle data (see below) ... */
};

export default function MyPage() {
  return <Crossword data={data} />;
}

Clue/data format

To make crosswords as easy to create as possible, with the least amount of extraneous and boilerplate typing, the clue/answer format is structured as a set of nested objects:

{
  across: {
    1: {
      clue: 'one plus one',
      answer: 'TWO',
      row: 0,
      col: 0,
    },
  },
  down: {
    2: {
      clue: 'three minus two',
      answer: 'ONE',
      row: 0,
      col: 2,
    },
  },
}

At the top level, the across and down properties group together the clues/answers for their respective directions. Each of those objects is a map, keyed by the answer number rather than an array. (This is done so that the creator has control over the numbering/labelling of the clues/answers.) Each item contains a clue and answer property, as well as row and col for the starting position.

The Crossword component calculates the needed grid size from the data itself, so you don't need to pass an overall size to the component.

Styling

One other major difference (and advantage) to this crossword component is that it is very "stylable"... as many of the styling properties as possible are exposed so that you can create any look you want for the crossword. The Crossword component makes use of styled-components' ThemeProvider and offers the following properties to control colors and layout:

theme property default description
columnBreakpoint '768px' browser-width at which the clues go from showing beneath the grid to showing beside the grid.
gridBackground 'rgb(0,0,0)' overall background color (fill) for the crossword grid. Can be 'transparent' to show through a page background image.
cellBackground 'rgb(255,255,255)' background for an answer cell
cellBorder 'rgb(0,0,0)' border for an answer cell
textColor 'rgb(0,0,0)' color for answer text (entered by the player)
numberColor 'rgba(0,0,0, 0.25)' color for the across/down numbers in the grid
focusBackground 'rgb(255,255,0)' background color for the cell with focus, the one that the player is typing into
highlightBackground 'rgb(255,255,204)' background color for the cells in the answer the player is working on, helps indicate in which direction focus will be moving; also used as a background on the active clue

Note that these values can be provided either via ThemeProvider, or directly as a theme property on the Crossword component itself. (And further, if you're not using styled-components, but want to make use of ThemeProvider, this library re-exports ThemeProvider so you can pull it from here.)

Also, several class names are applied to elements in the crossword, in case you want to apply styles that way:

element class name
entire crossword component; encompassing grid and clues crossword
entire crossword is correct (on same element as crossword) correct
answer grid grid
all of the clues clues
header and clues for one direction direction
direction header ('across' or 'down') header
an individual clue clue
an individual clue with a correct answer (on same element as clue) correct

(No class names are currently applied within the grid, as the SVG layout is very layout-sensitive.)

Player progress events

In addition to providing properties for styling, there are some properties to help your application "understand" the player's progress:

property description
onCorrect callback function that fires when a player answers a clue correctly; called with (direction, number, answer) arguments, where direction is 'across' or 'down', number is the clue number as text (like '1'), and answer is the answer itself
onLoadedCorrect callback function that’s called when a crossword is loaded, to batch up correct answers loaded from storage; passed an array of the same values that onCorrect would recieve
onCrosswordCorrect callback function that’s called when the overall crossword is completely correct (or not)
onCellChange callback function called when a cell changes (e.g. when the user types a letter); passed the row and column and the character typed
onClueSelected callback function called when a clue is selected; passed the direction and the “number”

Imperative methods

The following imperative methods can be called on a "ref" handle to the component:

method name parameters description
focus() (none) Sets focus to the crossword component.
reset() (none) Resets the entire crossword; clearing all answers in the grid and also any persisted data.
fillAllAnswers() (none) Fills all the answers in the grid and calls the onLoadedCorrect callback with every answer.
isCrosswordCorrect() (none) Returns whether the crossword is entirely correct or not.

Background

Initially written as a replacement for @guardian/react-crossword, to make custom styling and puzzle-definition easier.

There are several things about the Crossword component from @guardian/react-crossword that are less than ideal, in my opinion:

  • the styles/formatting are baked in
  • semi-unrelated functionality like the "anagram helper" is baked in
  • the data format for clues/answers is horrendous

This is an attempt to create a less-opinionated component that's much easier to drop in to an arbitrary React page.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Pushpendra Singh
Pushpendra Singh

🤔
Amit Bansal
Amit Bansal

🐛
embeddedt
embeddedt

💻
Albranco
Albranco

🤔
Rob McCollough
Rob McCollough

🤔
lorddaedra
lorddaedra

🤔
Ilya Lukyanov
Ilya Lukyanov

🤔
Richard Hoffmann
Richard Hoffmann

🤔
gitname
gitname

🐛
Craig
Craig

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

react-crossword's People

Contributors

dependabot[bot] avatar embeddedt avatar greenkeeper[bot] avatar jaredreisinger avatar semantic-release-bot avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-crossword's Issues

Cell input not functioning

Hi there, I'm trying to get this up and running with react ^17 so using the V2 fork. The cells in the crossword aren't accepting text, otherwise seems to be working as expected.

Is this a bug with V2 or am I missing some code that I should have added to my app?

<Crossword theme={{ textColor: "#1b747a" }} data={crosswordLayout} />

Not working without styled-components

Hi,

This looks interesting, but I cant get it to work. I'm not using styled-components. Your documentation says "Note that these values can be provided either via ThemeProvider, or directly as a theme property on the Crossword component itself. (And further, if you're not using styled-components, but want to make use of ThemeProvider, this library re-exports ThemeProvider so you can pull it from here.)"

So based on the examples in the cookbook, I tried with ThemeProvider:

import Crossword, { ThemeProvider } from '@jaredreisinger/react-crossword';
<ThemeProvider
    theme={{
    ... values from the example
    }}
  >
    <Crossword data={data} />
  </ThemeProvider>

This didnt work, Gave

./node_modules/@jaredreisinger/react-crossword/dist/es/index.js
Module not found: Can't resolve 'styled-components' in '<>\node_modules\@jaredreisinger\react-crossword\dist\es'

Then I tried using the theme property:

import Crossword from '@jaredreisinger/react-crossword';
<Crossword
    data={data}
    theme={{
    ...
    }}
  />

Same error as above.

Please let me know if I'm missing something, or what else needs be done to have this compile.

Cell Overwritten at Junction

When two words start at the same cell, e.g. words GITHUB, GOOGLE if the 1st letter is considered as a point of junction and GITHUB is to be arranged horizontally with clue no. 2 and GOOGLE is to be arranged vertically with clue no. 3 then the crossword cell should show 2, 3 in the cells instead of just 2 or 3. This may be confusing for the players attempting 1st time or if the crossword is converted to a printable format
image

An in-range update of styled-components is breaking the build 🚨

The devDependency styled-components was updated from 5.0.0 to 5.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

styled-components is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v5.0.1
  • Added useTheme hook to named exports for react native (#2982)

  • Performance enhancements

    • Refactored hashing function that is a bit faster in benchmarks (#2983)
    • Fixed a bitwise math issue that was causing SSR performance degradations due to how we allocate typed arrays under the hood (#2996)
  • Added some helpful new dev-time warnings for antipatterns

    • Recommending against usage of css @import inside createGlobalStyle and what to do instead (#2997)
    • Catching and warning against dynamic creation of styled-components inside other component render paths (#2998)
FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Should `useStorage` really be `true` by default?

We currently default useStorage to true, which might be okay, but does tend to make the examples clobber each other.

Other options:

  • simply make useStorage default to faslse
  • add a storageKey prop so that crossword instances can have unique storage

If we do the second option, we could potentially omit useStorage entirely; the presence of storageKey would mean "use storage".

Allow to show what characters have been entered correctly/incorrectly

If used in a learning context, it'd be desirable to show users what characters were entered correctly (or incorrectly). This could be achieved by following the input field changes and finding the appropriate cell in the DOM, but this is pretty inconvenient :-) So:

As a developer, I want to have a way to show the user what characters were entered correctly/incorrectly in order to provide feedback.

Suggestions to choose from :-) (and a query to pre-qualify these for a possible pull-request - accepting isCorrect() and highlight() would be highly appreciated):

  • Add method isCorrect(column, row)
    A developer can keep track of this himself/herself by controlling the input data and the onCellChange callback, but it might be more convenient to ask the crossword.

  • Add method highlight(column, row, color)
    Would allow to style each cell individually.

  • Add highlightCorrect and highlightIncorrect properties to the theme, defaulting to e.g. #a2bdb0 and #deb8b8

  • Add method highlightCorrect()to highlight all correct answers
    Convenience function for less experienced developers. Would highlight all correct answers with the default color for correct answers.

  • Add method highlightIncorrect({blankIsFalse: true}) to highlight all incorrect answers
    Convenience function for less experienced developers. Would highlight all incorrect answers with the default color for incorrect answers. Could optionally take the parameter blankIsFalse (default: true) to let the author decide whether a blank field without input should be considered as wrong

  • Add method highlightAnswers({blankIsFalse: true}) to highlight all correct and incorrect answers
    Convenience function for less experienced developers. Would highlight all correct and incorrect answers. Could optionally take the parameter blankIsFalse (default: true) to let the author decide whether a blank field without input should be considered as wrong

Snyk brings in a boat-load of dependencies

A bit puzzled here. Why would this package need so many dependencies?

[4/4] Building fresh packages...
success Saved lockfile.
success Saved 187 new dependencies.
info Direct dependencies
└─ @jaredreisinger/[email protected]
info All dependencies
├─ @arcanis/[email protected]
├─ @emotion/[email protected]
├─ @jaredreisinger/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @octetstream/[email protected]
├─ @sindresorhus/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @snyk/[email protected]
├─ @szmarczak/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @yarnpkg/[email protected]
├─ @yarnpkg/[email protected]
├─ @yarnpkg/[email protected]
├─ @yarnpkg/[email protected]
├─ @yarnpkg/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]

Originally posted by @zehawki in #31 (comment)

Allow unused cells

My crossword generator is not so smart to fill all cells with letters. Thus, I am getting

Uncaught Error: unexpected unused cell

Is there a reason why unused cells are not allowed?

Crossword states update availability.

Its great what you have built here. And your approach toward customization and composable nature of the lib is nice.

I would like to add few use cases to be covered which will really enhance the whole dev experience of the library :

  • onCheck : Function returning whether the current filled crossword is correct or not, as onLoadedCorrect is invoked only on load and not every update.
  • onReset : Resets the state of crossword, i.e erase user inputs.
  • onFillCorrect : Updates the crossword state with correct answers.
  • onChange : Function returning the current state of crossword.

Thanks.

An in-range update of lint-staged is breaking the build 🚨

The devDependency lint-staged was updated from 10.0.3 to 10.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

lint-staged is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v10.0.4

10.0.4 (2020-01-29)

Bug Fixes

Commits

The new version differs by 2 commits.

  • 9c08e8e fix: use verbose renderer when TERM=dumb (#782)
  • 7fac11f docs: Add better docs on running multiple commands

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Node version > 10.18

Hiya, any particular reason to look for Node > 10.18.

Havent had this requirement from any package till date....

Call onClueSelected on click of cell and input to know the clue

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @jaredreisinger/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js b/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
index 8165e51..e55772a 100644
--- a/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
+++ b/node_modules/@jaredreisinger/react-crossword/dist/CrosswordProvider.js
@@ -561,6 +561,9 @@ const CrosswordProvider = react_1.default.forwardRef(({ data, theme, onAnswerCom
                 direction = other;
             }
             setCurrentNumber((_a = cellData[direction]) !== null && _a !== void 0 ? _a : '');
+            if (onClueSelected) {
+                onClueSelected(direction, cellData[direction] ?? '');
+            }
         }
         focus();
     }, [currentDirection, focus, focused, focusedCol, focusedRow]);
diff --git a/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx b/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
index 8d8633c..2ad68a5 100644
--- a/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
+++ b/node_modules/@jaredreisinger/react-crossword/src/CrosswordProvider.tsx
@@ -886,6 +886,9 @@ const CrosswordProvider = React.forwardRef<
           }
 
           setCurrentNumber(cellData[direction] ?? '');
+          if (onClueSelected) {
+            onClueSelected(direction, cellData[direction] ?? '');
+          }
         }
 
         focus();

This issue body was partially generated by patch-package.

More natural navigation through the puzzle?

Right now, after the user is done typing a guess, the focus doesn't jump to the next open square. It seems like this behavior would help with getting around the puzzle quickly, so I was wondering if there could be an option to enable this kind of navigation? (Maybe something like autoJumpToNextClue)

If my description wasn't clear, this demo has the behavior I'm describing.
(Also, the above demo's arrowkey navigation works a bit differently as well—it lets you go "through" black squares instead of having to go around them. That might also be desirable for navigability)

i've run every example in the repo and it doesn't work

image

i get this error message.

const data2 = {
  across: {
    1: { clue: 'This', answer: 'XXX', row: 0, col: 0 },
    4: { clue: 'is', answer: 'XXX', row: 0, col: 4 },
    7: { clue: 'not', answer: 'XXX', row: 1, col: 0 },
    8: { clue: 'a', answer: 'XXXX', row: 1, col: 4 },
    10: { clue: 'real', answer: 'XX', row: 2, col: 0 },
    11: { clue: 'crossword,', answer: 'XX', row: 2, col: 3 },
    12: { clue: 'it', answer: 'XX', row: 2, col: 6 },
    13: { clue: 'is', answer: 'XXXXXX', row: 3, col: 0 },
    16: { clue: 'only', answer: 'XXXXXX', row: 4, col: 2 },
    19: { clue: 'showing', answer: 'XX', row: 5, col: 0 },
    21: { clue: 'the', answer: 'XX', row: 5, col: 3 },
    22: { clue: 'kind', answer: 'XX', row: 5, col: 6 },
    23: { clue: 'of', answer: 'XXXX', row: 6, col: 0 },
    25: { clue: 'thing', answer: 'XXX', row: 6, col: 5 },
    26: { clue: 'you', answer: 'XXX', row: 7, col: 1 },
    27: { clue: 'can', answer: 'XXX', row: 7, col: 5 },
  },
  down: {
    1: { clue: 'create.', answer: 'XXXX', row: 0, col: 0 },
    2: { clue: 'All', answer: 'XXXX', row: 0, col: 1 },
    3: { clue: 'of', answer: 'XX', row: 0, col: 2 },
    4: { clue: 'the', answer: 'XXXXXX', row: 0, col: 4 },
    5: { clue: 'answers', answer: 'XX', row: 0, col: 5 },
    6: { clue: 'are', answer: 'XXX', row: 0, col: 6 },
    9: { clue: '"X"', answer: 'XX', row: 1, col: 7 },
    11: { clue, answer: 'XXXXXX', row: 2, col: 3 },
    14: { clue, answer: 'XX', row: 3, col: 2 },
    15: { clue, answer: 'XX', row: 3, col: 5 },
    17: { clue, answer: 'XXXX', row: 4, col: 6 },
    18: { clue, answer: 'XXXX', row: 4, col: 7 },
    19: { clue, answer: 'XX', row: 5, col: 0 },
    20: { clue, answer: 'XXX', row: 5, col: 1 },
    24: { clue, answer: 'XX', row: 6, col: 2 },
    25: { clue, answer: 'XX', row: 6, col: 5 },
  },
};
        <Crossword data={data2} useStorage={false} />
        

what is the issue here?

How to replace (localize) direction header?

Current code (en):
<h3 className="header">{direction.toUpperCase()}</h3>

Expected result (ru):
<h3 className="header">По горизонтали:</h3>

Please, add feature to do that.

On updating data prop, app crashes with error "Cannot read property '0' of undefined"

When updating the data prop of the crossword the, the app crashes and return error Cannot read property '0' of undefined.

Why I need to update data props ? I want to update the clue with check icon `onCorrect'.

Implementation snippet

import React from "react";
import Crossword from "@jaredreisinger/react-crossword";

import { initialData } from "../utils/crossword";

function Play() {
  const [data, setData] = React.useState(initialData);

  const onCorrect = (...values) => {
    try {
      const [direction, number, answer] = values;
      const newData = { ...data };
      newData[direction][number].clue = newData[direction][number].clue + " ✅";
      setData(newData);
    } catch (error) {
      console.log(error);
    }
  };

  return (
      <Crossword
        data={data}
        onCorrect={onCorrect}
      />
  );
}

export default Play;

If data props should not be updated, please mention that and I will close the issue.

Thanks.

a11y issues preventing usage by people with disabilities

I am not an accessibility expert, but there are some things I noticed in version 2.2.8:

  • When the crossword receives focus, e.g. by tabbing into it, users cannot tab out of it. They are trapped inside (cmp. https://www.digitala11y.com/understanding-sc-2-1-2-no-keyboard-trap/).
  • When a cell where a clue starts gets focus, the clue is not announced in any way and a visually impaired user would not know what to fill into the cells.
  • When a cell gets focus, there's no hint given to explain where in the crossword the user is.

I think these are relevant issues, because they prevent people with visual impairment or motor skill limitations to use the crossword.

Suggestions:

  • Find the source of trapping focus and remove it.
  • Use the aria grid role (cmp. https://www.digitala11y.com/grid-role/) with proper aria labels to tell visually impaired people what they are expected to enter.

Imperative methods & Player progress events

Hi there,
Sorry to be a noob, but would someone please mind sharing some code showing how to access and use these methods?
I searched through the examples, but couldn't see anything that made sense.
Thanks in advance!

Allow retrieval of player's guess onAnswerComplete

Would it be possible to modify, or implement a separate callback that returns the player's guess and its properties (direction, start position, guess) on answer complete? I would use this to implement server-sided checking, and to avoid answer leaking in the current format, would generate a dummy grid with dummy words of the same length.

If I understand correctly, it seems like answer checking is done by by checking each cell one by one with the corresponding correct answer. So maybe could there be a way to join each cell's contents together into a string and return that along with the meta-properties (start-position, direction)?

A callback function that notifies that the word is guessed incorrectly

In my project, I needed to change the state of the application when the user completely filled in the word cells, but it was guessed incorrectly. the api of the library does not provide such an opportunity, so I suggest that the developers implement it, since I had to do it manually and it was not very easy

Attempting to use the style props causes an error

When I attempt to use the github.io styling example

<Crossword
    data={data}
    columnBreakpoint="9999px"
    gridBackground="#acf"
    cellBackground="#ffe"
    cellBorder="#fca"
    textColor="#fff"
    numberColor="#9f9"
    focusBackground="#f00"
    highlightBackground="#f99"
  />

I get the following error:

TypeError: Cannot read property '0' of undefined
(anonymous function)
src/app/node_modules/@jaredreisinger/react-crossword/dist/es/Crossword/util.js:191
188 | var r = isAcross ? row : row + i;
189 | var c = isAcross ? col + i : col;
190 |

191 | if (gridData[r][c].guess !== info.answer[i]) {
| ^ 192 | correct = false;
193 | break;
194 | }
View compiled

(anonymous function)
src/app/node_modules/@jaredreisinger/react-crossword/dist/es/Crossword/util.js:180
177 | var correctAnswers = [];
178 | bothDirections.forEach(function (direction) {
179 | var isAcross = direction === 'across';

180 | Object.entries(data[direction]).forEach(function (_ref5) {
| ^ 181 | var num = _ref5[0],
182 | info = _ref5[1];
183 | var row = info.row,
View compiled

findCorrectAnswers
src/app/node_modules/@jaredreisinger/react-crossword/dist/es/Crossword/util.js:178
175 |
176 | function findCorrectAnswers(data, gridData) {
177 | var correctAnswers = [];

178 | bothDirections.forEach(function (direction) {
179 | var isAcross = direction === 'across';
180 | Object.entries(data[direction]).forEach(function (_ref5) {
181 | var num = _ref5[0],
View compiled

Here's how I'm using it in my app:

render() {

...

return (
            <div className="bodyOuterContainer text-center mt-5 pt-5">
                <div className="bodyInnerContainer pt-2">
                    <Crossword data={data} cellBackground='rgba(255, 255, 255, 0.3)' textColor='#666' numberColor='#ccc' focusBackground='rgba(255, 255, 255, 0.7)' highlightBackground='rgba(170, 205, 255, 0.7)' />
                </div>
            </div>
        );
}

Rich text formatting of clues

If I pass through JSON with HTML elements e.g., <em>...</em>, it automatically gets converted to HTML entities \u003cem\u003e ... \u003c/em\u003e.

Can support for rich text formatting be added to a future release?

Allow define how an answer is correct?

Im a VietNamese people, so if the answer is TuyệtVời. I want to when user input: TuyetVoi, TuyệtVoi, tuyetvoi or anymore that only remove accent is also correct.
I want to define a function to consider when a answer is accepted.
Any solution? Please help me. Thank you.

Allow to set cell programmatically?

I am currently toying with the idea of creating a collaborative crossword solving website using socket.io. One thing that I cant seem to figure out how to do is set the value of the grid or individual cells functionally.

Is this something that I just can't find or is it not possible? I know this project was written as a kind of alternative/improvement on the guardian crossword component. That component has exposed functions to update the grid and individual cells.

I guess my question is was that functionality removed or could it be accomplished a different way using this crossword component?

Imperative `isCrosswordCorrect()` function returns `false` after web page reloads

Thanks for sharing this package!

I think I have run into a bug related to checking whether the crossword is correct.

When I fill in all the grid cells with correct letters and then call the imperative isCrosswordCorrect() function, the function returns true. That is what I expect it to do.

image

crosswordRef.current.isCrosswordCorrect(); // returns true ✅ 

However, when I then reload the web page (which leads to the grid being automatically re-populated with the same, correct letters) and then I call that same function again, the function returns false, whereas I expect it to return true since all the grid cells are still populated with correct letters.

image

crosswordRef.current.isCrosswordCorrect(); // returns false 😞 

At this point, if I call the imperative reset() function, fill in all the grid cells with the correct letters again, and then call the imperative isCrosswordCorrect() function again, the latter function once again returns true.

crosswordRef.current.reset();

image

image

crosswordRef.current.isCrosswordCorrect(); // returns true ✅ 

Here's some information about the environment in which I observed this:

  • OS: Windows 10
  • Browser: Google Chrome Version 100.0.4896.88 (Official Build) (64-bit)
  • @jaredreisinger/react-crossword version: 4.3.2
  • React version: 17.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.