Git Product home page Git Product logo

memory-game's Introduction

Memory Game

A memory game based on the TV show Southpark. Built using React & Styled Components, bundled with Vite.

Demo here

Image of live version

Installing and running locally

git clone [email protected]:Casssb/memory-game.git
cd memory-game
npm install
npm run dev

Tech Used

  • React, Styled Components
  • NPM & Vite for build
  • react-parallax-tilt (for card hover effects)
  • Sanitize CSS (for reset)
  • SWC for compiling (supposedly it's 17 times faster than Babel)

Features

  • Asynchronous loading of image assets (with a loading message)
  • Simple dark-mode styling
  • Responsive on PC, Tablet & Mobile

Thoughts

Had a ton of fun building this! The purpose was to get used to using the basic React hooks. I've mainly been working with class based react components for state & lifecycle management up until this point. Moving over to hooks was a total breeze! They seem to fit more clearly into the React teams vision of making it work in a composable way. I especially like how useEffect assumes the job of replacing pretty much all of the previous lifecycle methods.

I also found using CSS as JS fit really well with the style of programming React encourages (splitting everything into as many re-usable modules as possible). I can see how well this sort of structure would scale with a larger team of developers although I can't see why it's a better design pattern then just using post CSS modules? (I've spent many hours reading through discussions about this on Stack and it seems opinions are split).

Possible Improvements

  • The more I learn about Styled Components, the more I realise almost every element is transferable between modules. I'm sure there is more info I missed in the docs that could lead me to optimise.
  • I was looking for a more optimal way to cache the images I use each time the game reloads them (once per level change and on first load). I looked into memoizing (memo) and even creating an API but ended up just going with Promise.all (making use of the JS Image object). I'm sure there was a more optimal way of doing this.
  • I'm not totally happy with the way the 'loading...' message is displayed. Due to how small the image filesizes are (and how effective Vite is as a bundler) the message will mostly appear for just a fraction of a second between levels. I did consider forcing it to remain for a second or 2 (using setTimout). I'm not sure which is a better user experience; faster loading ? Or having the display sometimes appear as if it has a visual bug. I tested it using a a variety of different internet connection speeds (using the browser devtools) and decided to stick with keeping the message as is.
  • As ever I'm not 100% happy with the styling (although I really like the Southpark font, cheers dafont.com!).

Credits

memory-game's People

Contributors

casssb avatar

Watchers

 avatar

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.