Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Remove connected blocks on click #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jcpeden
Copy link
Owner

@jcpeden jcpeden commented Apr 16, 2024

What does it do?

As part of my tech test for Esynergy, I've updated this class to remove adjacent blocks of the same colour whenever a user clicks on a block.

How does it work?

When the user clicks on a block, the block is added to an array. This array is then iterated upon to identify any adjacent (up, down, left, right) blocks that have the same colour as the target.

If they share the same colour, then they too are iterated upon such that an entire group of adjacent blocks of the same colour can be identified.

Once identified, these target blocks are 'removed' from the grid by setting their colour to null.

Blocks situated 'above' a removed block are then shifted downwards to fill the available space, not unlike the game Tetris.

What does it look like?

On Loading

Screenshot 2024-04-16 at 16 27 55

After clicking on the central red block

Screenshot 2024-04-16 at 16 28 01

How to test?

  1. Pull this brand down
  2. Run npm install && npm run test
  3. Alternatively, you can run npm run start and manually test the interactions for yourself

How to improve

  1. Refactor to use TypeScript
  2. Improve test coverage
  3. Break the larger blocks of code down further to make them easier to test and more reusable
  4. Consider using more of a unit test approach instead of these pseudo integration tests
  5. Make it work with yarn

dependabot bot and others added 2 commits April 10, 2024 04:31
Bumps the npm_and_yarn group with 21 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [acorn](https://github.com/acornjs/acorn) | `5.7.3` | `5.7.4` |
| [ajv](https://github.com/ajv-validator/ajv) | `6.10.2` | `6.12.6` |
| [browserify-sign](https://github.com/crypto-browserify/browserify-sign) | `4.0.4` | `4.2.3` |
| [browserslist](https://github.com/browserslist/browserslist) | `4.6.6` | `4.23.0` |
| [color-string](https://github.com/Qix-/color-string) | `1.5.3` | `1.9.1` |
| [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) | `0.2.0` | `0.2.2` |
| [dot-prop](https://github.com/sindresorhus/dot-prop) | `4.2.0` | `4.2.1` |
| [elliptic](https://github.com/indutny/elliptic) | `6.5.0` | `6.5.5` |
| [fsevents](https://github.com/fsevents/fsevents) | `1.2.9` | `1.2.13` |
| [handlebars](https://github.com/handlebars-lang/handlebars.js) | `4.1.2` | `4.7.8` |
| [hosted-git-info](https://github.com/npm/hosted-git-info) | `2.8.2` | `2.8.9` |
| [ini](https://github.com/npm/ini) | `1.3.5` | `1.3.8` |
| [json5](https://github.com/json5/json5) | `1.0.1` | `1.0.2` |
| [lodash](https://github.com/lodash/lodash) | `4.17.15` | `4.17.21` |
| [minimatch](https://github.com/isaacs/minimatch) | `3.0.4` | `3.1.2` |
| [path-parse](https://github.com/jbgutierrez/path-parse) | `1.0.6` | `1.0.7` |
| [qs](https://github.com/ljharb/qs) | `6.5.2` | `6.5.3` |
| [semver](https://github.com/npm/node-semver) | `5.7.0` | `5.7.2` |
| [tmpl](https://github.com/daaku/nodejs-tmpl) | `1.0.4` | `1.0.5` |
| [ws](https://github.com/websockets/ws) | `5.2.2` | `5.2.3` |
| [y18n](https://github.com/yargs/y18n) | `4.0.0` | `4.0.3` |



Updates `acorn` from 5.7.3 to 5.7.4
- [Commits](acornjs/acorn@5.7.3...5.7.4)

Updates `ajv` from 6.10.2 to 6.12.6
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](ajv-validator/ajv@v6.10.2...v6.12.6)

Updates `browserify-sign` from 4.0.4 to 4.2.3
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](browserify/browserify-sign@v4.0.4...v4.2.3)

Updates `browserslist` from 4.6.6 to 4.23.0
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](browserslist/browserslist@4.6.6...4.23.0)

Updates `color-string` from 1.5.3 to 1.9.1
- [Release notes](https://github.com/Qix-/color-string/releases)
- [Changelog](https://github.com/Qix-/color-string/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Qix-/color-string/commits/1.9.1)

Updates `decode-uri-component` from 0.2.0 to 0.2.2
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](SamVerschueren/decode-uri-component@v0.2.0...v0.2.2)

Updates `dot-prop` from 4.2.0 to 4.2.1
- [Release notes](https://github.com/sindresorhus/dot-prop/releases)
- [Commits](sindresorhus/dot-prop@v4.2.0...v4.2.1)

Updates `elliptic` from 6.5.0 to 6.5.5
- [Commits](indutny/elliptic@v6.5.0...v6.5.5)

Updates `fsevents` from 1.2.9 to 1.2.13
- [Release notes](https://github.com/fsevents/fsevents/releases)
- [Commits](fsevents/fsevents@v1.2.9...v1.2.13)

Updates `handlebars` from 4.1.2 to 4.7.8
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.8/release-notes.md)
- [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.7.8)

Updates `hosted-git-info` from 2.8.2 to 2.8.9
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](npm/hosted-git-info@v2.8.2...v2.8.9)

Updates `ini` from 1.3.5 to 1.3.8
- [Release notes](https://github.com/npm/ini/releases)
- [Changelog](https://github.com/npm/ini/blob/main/CHANGELOG.md)
- [Commits](npm/ini@v1.3.5...v1.3.8)

Updates `json5` from 1.0.1 to 1.0.2
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](json5/json5@v1.0.1...v1.0.2)

Updates `lodash` from 4.17.15 to 4.17.21
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.21)

Updates `minimatch` from 3.0.4 to 3.1.2
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](isaacs/minimatch@v3.0.4...v3.1.2)

Updates `path-parse` from 1.0.6 to 1.0.7
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

Updates `qs` from 6.5.2 to 6.5.3
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](ljharb/qs@v6.5.2...v6.5.3)

Updates `semver` from 5.7.0 to 5.7.2
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](npm/node-semver@v5.7.0...v5.7.2)

Updates `tmpl` from 1.0.4 to 1.0.5
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

Updates `ws` from 5.2.2 to 5.2.3
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@5.2.2...5.2.3)

Updates `y18n` from 4.0.0 to 4.0.3
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md)
- [Commits](yargs/y18n@v4.0.0...y18n-v4.0.3)

---
updated-dependencies:
- dependency-name: acorn
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: ajv
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: browserify-sign
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: browserslist
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: color-string
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: decode-uri-component
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: dot-prop
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: elliptic
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: fsevents
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: handlebars
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: hosted-git-info
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: ini
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: json5
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: lodash
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: minimatch
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: path-parse
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: qs
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: semver
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: tmpl
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: ws
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: y18n
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant