Code Monkey home page Code Monkey logo

countdown's Introduction

Countdown

Improved countdown

The below component was designed to count down the days until our CTO's birthday, but it still needs some work. How can you make the implementation better?

Do a critique: The current implementation isn't perfect. How could it be improved?

  • Pick an area of improvement to implement.
    • Improve the general date calculations
    • Make the presentation more dynamic
    • Change the Countdown component to be hooks oriented
    • Abstract redudant pieces of HTML into their own components.
    • Added an input to put in any Birthdate
    • Added flex to make the layout responsive to smaller screens
  • What would happen to the current code if the date were changed, the page layout was changed or the format was changed?
    • The date was not flexible, along with having the wrong year, and the layout was not responsive. I contained the Countdown in a simple flex container so that each block will wrap as the screen size changes
  • Does the current implementation follow best practices for HTML, CSS, JS and React?
    • The CSS was pretty barebones and generally functional as it was, but did not have any infrastructure related content to containers or wrappers.
    • Some of the JS were purely utility functions that did not need to live within a components scope. I moved them to their own utils.js file to clean up the flow.
    • There was redundancy, especially with each time block that React accels at eating up using components-- so I broke those out into presentational CountdownItem components that simply take the title and current count.
    • I made the layout more data driven by looping through the countdown state for producing each CountdownItem
    • The calculations for the countdown included a series of conditionals that continually mutate a variable tracking the time remaining in seconds and creating the mapping for the countdown state. This is not an inherenly flawed approach, but it is ripe for generating bugs wrapped into either interaction. This approach also left out calculating remaining months, which is trickier to calculate than merely multiplying measures of time, so I decided to avoid reinventing the wheel and used the date-fns library to drastically clean up the code and make it easily immutable.

Spice it up: Let's be honest, this countdown could be a whole lot more exciting.

  • What could you do to create a greater sense of urgency?
    • I added some color and emboldened the fonts. I could do more if desired, but I kept it simple
  • How would you make this countdown more aesthetically pleasing?
    • Fonts and some slightly creative layout of title and number were my approach
  • Trust your design instincts, and explain how your design choices impact the user experience
    • I think the color and fonts make it feel more interesting and compelling.
    • The loading animation pulls the user in a little more and communicates the dynamic nature of the view

countdown's People

Contributors

leftfieldadam avatar aklevecz 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.