Skip to content

Instantly share code, notes, and snippets.

@leny
Last active March 23, 2020 09:55
Show Gist options
  • Save leny/224e5bb721b62f408bfabd91fb25cad8 to your computer and use it in GitHub Desktop.
Save leny/224e5bb721b62f408bfabd91fb25cad8 to your computer and use it in GitHub Desktop.

React: pomodoro

A simple, static, pomodoro timer with React.

Introduction

You will use React to create a simple Pomodoro timer.
It will be static, without the need for a server.

You will also discover some build tools, with Parcel, and will follow some code quality rules, with Prettier and ESLint.

Statement

Following these beautiful wireframes, you will code a pomodoro timer.

Minimal requirements

  • Display a big timer (minutes and seconds).
  • Four buttons:
    • plus (+) and minus (-), they will allow the user to adjust the minutes counter - only when it's stopped.
    • start, to run the timer (it will then change to stop), to serve as a toggle button
    • reset, to… reset the timer to its original value
  • At the end of the timer, show a modal to invite user to take a break. The modal will have two buttons:
    • One to close the modal
    • Another to close the modal and start a new timer

Optional additions

You can add anything to the timer, as long as the minimal requirements are fulfilled.

You can add a sound at the end of the timer, add another timer in the modal to limitate the break time, add animations… feel free to try anything!

Technical concerns

Tooling

Build tool

As you will see, React makes you create and handle many different files.
Keeping track of each of them and reference them in your html file can be a real pain in the a$!%.

We will need a build tool, a bundler, to create a final file from all our components.

There's many build tools around, the most popular (and complete) is webpack.
It's a really complex tool, so we will not use it for your first project (it will be for the next time).

We will use Parcel, which is a build tool "without configuration", which try to guess your needs by looking at your code.

Take a bit of your time to follow the Getting Started section of their documentation.

Code Quality

Even if you're working alone on this project, we need you to enforce your code quality.

You will use Prettier to format your code, and ESLint to ensure your code following good practices.

You will use the BeCode Presets. When your project's package.json file is created, execute the following command: npx @becode/eslint-config --with-hook.

It will install Prettier & ESLint and a git hook to run it before your commits.

⚠️ NOTE: if there's an ESLint error in your code, your commit will not be allowed. Correct the error and retry!

🧨 WARNING: disable ESLint is not an option!

Hosting

We want you to publish your pomodoro online. There's many solutions to host a static website online for free, like github-pages.

We will use a new solution: Netlify.
It's free, easy to setup, and can observe your changes and publish automatically.


Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment