Code Monkey home page Code Monkey logo

toyrobotsimulator's Introduction

TOY ROBOT SIMULATOR

Toy Robot Simulator is a react app built with redux, hooks, styled components and is tested using jest and enzyme. The design pattern loosely follows the Domain or Ducks style for file structure.

ParcelJs is used as the build tool. The prod build is ready to be served on a web server

Styled components Are used as a css in js solution

Approach

  • TDD
  • Container/presentational components
  • Small action creators
  • Business logic in the reducer
  • Feature first
  • Tests next to code
  • Domain or Ducks approach
  • Css in js theme for colours and breakpoint

Design decisions

  • 2 top level components or domains: TableTop and UiControls
  • Actions, Css and Utils have been split out into seperate modules per component

TableTop

  • TableTop connects to the state to get the current robot position and renders the TableTopSquares
  • TableTopSquares display the robot based on the robot position props stored in the state
  • Easy to do this then move a div around a fluid grid
  • Used css grid

UiControls

  • UiControls renders the 3 ui components, Place, Rotate and Move.
  • It holds the ui controls reducer which updates the robotPosition in the state
  • PlaceUi component uses hooks for local state of the user input
  • Each ui component dispatch's actions for updating state

Static build for browser

I have included a folder with a build fit for opening directly in the browser. This can be found in /staticBuild. The only difference is that the script location is relative so as not to cause a 404. The best way to view is by running the start command

What could be improved

  1. The app could be optimized for accessability.
  2. Further unit testing coud be completed and also optimized for the PlaceUi component. Turns out using Hooks is a little difficult to test at the moment and you cant test them with enzyme at all!
  3. Create a few more low level shared components ie: buttons, headings etc
  4. Jest snapshots could be used as a baseline test for all components
  5. Typescript could be implemented
  6. Could have used styled-system for theming

Installation

yarn install
OR
npm install

Dev build

yarn start
OR
npm start

Production build

yarn prod
OR
npm prod

Test build

yarn test
OR
npm test

toyrobotsimulator's People

Stargazers

feathers avatar

Watchers

Andrew Noble 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.