Giter Club home page Giter Club logo

fcc-frontendprojects's People

Contributors

dvbsknd avatar

Watchers

 avatar

fcc-frontendprojects's Issues

Break up controlClock into separate handlers

https://github.com/dvbsknd/freeCodeCamp-frontEndProjects/blob/eec107c94008e5eee81b0eb59be6cf9b43098b22/challenges/pomodoro-clock/app.js#L207

There's no need to encapsulate all the logic in one function. It can be separated into multiple handlers. For example:

const handleDecrement = () => ({state , breakLength}) => {
  let newTime = breakLength <= 60 ? 60 : breakLength - 60;
  if (state === STATE.stopped) changeBreak(newTime);
}

<button type='button' id='break-decrement' onClick={handleDecrement({state, breakLength})}>
  <i className="fas fa-arrow-alt-circle-left"></i>
</button>

BTW

const handleDecrement = () => ({state , breakLength}) => {

// is equivalent to 
function handleDecrement({state , breakLength}) {

// if
<button type='button' id='break-decrement' onClick={() => handleDecrement({state, breakLength})}>

// we just 'curry' the first function invocation.

Props should be as "dumb" as possible

https://github.com/dvbsknd/freeCodeCamp-frontEndProjects/blob/eec107c94008e5eee81b0eb59be6cf9b43098b22/challenges/pomodoro-clock/app.js#L181

When passing in props to a component, it's good to think of them as being as benign to a component as possible. The reason for this is that any special logic should be handled prior to send it down the wire. The component's responsibility should be to to just render the output.

In lines 181-185 it's best to just pass in the variables and let the components deal with how they get rendered (in this case, they use a formatTime utility function). Make sense?

Namespace variables

There are only two hard things in Computer Science: cache invalidation and naming things.
-- Martin Fowler quoting Phil Karlton

In this case, a worthy fix is to namespace the concepts:

https://github.com/dvbsknd/freeCodeCamp-frontEndProjects/blob/eec107c94008e5eee81b0eb59be6cf9b43098b22/challenges/pomodoro-clock/app.js#L38

STATE can become CLOCK_STATE

https://github.com/dvbsknd/freeCodeCamp-frontEndProjects/blob/eec107c94008e5eee81b0eb59be6cf9b43098b22/challenges/pomodoro-clock/app.js#L46

MODE can become CLOCK_MODE

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.