Giter Club home page Giter Club logo

completing.me's Introduction

Search for a city from a provided list with React.

This project was bootstrapped with Create React App and uses Material-UI for a material design aesthetic. The application is hosted on Github Pages with Amazon Web Service's Route 53 domain registration and DNS services.

Please install React if you do not yet have it installed.

npm install react

To run the application, simply execute npm start.

Challenge

With a provided list (formatted as a JavaScript array), users should be able to search for a city on the list, with results updated live as soon as a user types in three characters. Error messages should be shown when fewer than three characters are entered or when no matches are found. My application is formatted in three parts: a title bar, a search bar, and a dynamic list showing cities and error messages. The search results are displayed by a handleChange() method, which sets style.display to block or none depending on whether a city or error message should be displayed.

Title Bar

The title bar was implemented with Material UI's AppBar. The default menu icon button was manually removed for simplicity.

Search Bar

The search bar is a Material UI TextField. .focus() is called to load the search field automatically. Every time the text in the search bar changes, handleChange() is called to update the list and error messages.

List and Error Messages

Both the list of cities and error messages reside within a Material UI List. Items on the list are hidden by default and revealed when handleChange() deems it appropriate to do so. Custom styling was required on the error messages to ensure that they contrast enough with actual results.

Future Improvements

  • Support for loading cities from an external source (CSV, JSON, SQL database, etc.,)
  • Continuous integration and automated tests for the handleChange() function (and others).
  • Migrate from Github Pages to AWS for administrative flexibility and richer analytics.
  • The current runtime complexity of handleChange() is O(np) where n is the length of the list and p is the number of total characters typed. The efficiency of handleChange() could be improved by sorting the list or implementing a hash table.

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.