Giter Site home page Giter Site logo

react-events-crash-course-lab's Introduction

React Events Crash Course Lab

Objectives

  1. Practice affixing and handling Synthetic Events in React

Introduction

Meet Chrome Boi! He's a Boi dressed as Google Chrome, and he's going to be joining you in this lab!

We're going to jump right into a React application and add event capturing + handling functionality. We have a simple single component application that renders a 900x600 canvas. All of our work will be done in src/ChromeBoisDomain.js.

For this lab, minimal guidance will be given. If you run into trouble, you are expected to reference the React Crash Course ReadMe lesson and React documentation on events:

Deliverables

  • Finish implementing the handleMouseMove method. This method should capture the x and y coordinates of the mouse from the event and use them to invoke the drawChromeBoiAtCoords function that has been provided and is already imported (drawChromeBoiAtCoords expects two arguments, an x and a y coordinate)
  • Add an event listener to the <canvas> element to capture a click. Create an event handler which, when fired, invokes the provided toggleCycling function (with no arguments)
  • Add an event listener to the <canvas> element to capture when a key is pressed. When a key is pressed, an event handler should invoke the provided resize function with a single argument of either '+' or '-':
    • If the key pressed was 'a', then it should invoke resize and pass in '+'.
    • If the key pressed was 's', then it should invoke resize and pass in '-'.
    • You'll only be able to register a Keyboard event if the canvas is in focus. So on load of the page, either click the canvas for press the tab key to test out this feature.

Hints:

  • You do not need any state in this application to make it work. The focus of this lab is practicing event handling in React.
  • The functions drawChromeBoiAtCoords, toggleCycling, and resize are NOT props. They are functions exported from the canvasHelpers.js file, so you can't call them off this.props; just invoke them like a regular function.

Once Finished

npm start and assert the following expected behavior:

  • As the mouse moves around the canvas element in the browser, ChromeBoi is constantly drawn to the screen
  • If the user clicks on the canvas, ChromeBoi begins cycling colors as he is drawn
  • If the user presses either 'a' or 's' (while the canvas is on focus), ChromeBoi begins drawing either larger or smaller

Resources

react-events-crash-course-lab's People

Contributors

danielseehausen avatar dependabot[bot] avatar geluso avatar ihollander avatar lizbur10 avatar maxwellbenton avatar rrcobb avatar sylwiavargas avatar thuyanduong-flatiron avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-events-crash-course-lab's Issues

No visible results

Canvas Link

https://learning.flatironschool.com/courses/1883/assignments/125693?module_item_id=259615

Concern

I'm unsure of the issue, but after completing all of the tests for this lab, I see no visible results. Based on the code, I would assume that an image will be stamped onto the canvas in cyclical RGB patterns. However, after executing my event handlers properly enough to pass tests, I see nothing on the final page...

Additional Context

No response

Suggested Changes

No response

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.