Code Monkey home page Code Monkey logo

etch-a-sketch's Introduction

Etch-A-Sketch

This project was to build a cross between sketch pad and etch-a-sketch toy. User can draw by holding left mouse click and hovering over grid element, choosing between number of pen options and adding grid gap for better precision and resizing grid. Goal of the project is to get comfortable with creating and manipulating DOM elements.

This project is part of The Odin Project Curriculum. This was a challenging project, but fun with a lot of parts and opportunities for learning.

View live preview of Etch-A-Sketch project via GitHub pages!

What have I learned

  • Planning and pseudo code - before any line of code I would draw a diagram and page design on a piece of paper. All code was first written as pseudo code on the paper then as comments in js file.
  • Comments - after writing the initial working code, I refactored the code and simplified it until there was no need for comments. Left comments are only to divide sections and as a note why did i do logic, when it is not clear on first scan.
  • Slicing functions - dividing logic from functions to simple units. Smaller functions to do one simple thing. Trying to have pure function without side effects.
  • CSS Grid - using CSS Grid repeat function was a simple and clean way of drawing the entire grid.
  • Dynamically filling the grid with JS - instead making initial grid of n x n div elements.
  • Event listers overlap - the biggest problem of building this project was making lines on drawing grid by holding mouse and hovering. I found the solution using global flag variable that listens for on mouse down and making it true, by realising mouse flag is false and stops drawing by mouseenter listener.
  • insertAdjustedElement method - until now I used appendChild method.
  • Making custom buttons and custom radio buttons- instead using button elements for challenge I used span elements and dataset attributes for custom buttons.
  • Responsive design- making responsive page was bit of challenging due to bad planning in the initial phase. After refactoring with grid flex display option I was able to make it as planned.

etch-a-sketch's People

Contributors

mojotron avatar

Stargazers

 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.