Skip to content

The classic hangman game, but online. Written in React + TypeScript to practice fundamental knowledge of TypeScript.

Notifications You must be signed in to change notification settings

smithy773/hangman-game-TS-React

Repository files navigation

Hangman

The classic Hangman game, made with React + TypeScript.

Table of contents

Screenshot

Hangman project screenshot

Links

Built with

  • TypeScript
  • React
  • Vite
  • CSS

What I learned

  • Practiced Event delegation when implementing the Keyboard component. Instead of having an event listener for click or press of each button, corresponding to each letter of the alphabet, I delegated said events to a single event listener per action - one for clicking the keyboard buttons on screen and one for pressing your PC's keyboard buttons.

keyboard

keyboard.tsx image

Full Hangman Keyboard code available inside the Keyboard.tsx file.

  • Instead of relying on an image and waiting for it to load each time a different part of the Hangman graphic must be displayed, I simply built the whole graphic with CSS. The graphic is always loaded, but it is hidden by default. The different parts are displayed whenever a wrong letter is guessed.

Hangman graphic

Hangman graphic code

Full code available inside HangmanGraphic.tsx.

Author

About

The classic hangman game, but online. Written in React + TypeScript to practice fundamental knowledge of TypeScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published