GithubHelp home page GithubHelp logo

github-search's Introduction

Github Search

A simple React app that searches Github.

Demo App

https://github-search-pi.now.sh/

Run

yarn start

Deploy

# Deploy using Vercel / Zeit (https://vercel.com/)
now

Acceptance Criteria

  • Display repository’s id, name, watchers_count.
  • Sort the results by the number of stars.
  • Have a search input that will show results (from all possible repositories) to those that have its name matches the search field.
  • Any 3rd-party libraries can be used if necessary.
  • No need to focus on the UX of the page.

Implementation Steps - Overview

  1. Ensure we can get the right data via the Github API.
  2. Generate a new React app using create-react-app.
  3. Create basic component structure; We'll need a search box, search result list, spinner, etc.
  4. Call API and render result (unstyled).
  5. Implement search.
  6. Implement pagination.
  7. Make things "purrty".

Implementation Details

  1. Do a quick curl call to see we can get the right data.

    We want to make sure we get the search results in the correct order.

curl -s 'https://api.github.com/search/repositories?q=ace&sort=stars&order=desc' | grep stargazers_count

# Output:
#   "stargazers_count": 21482,
#   "stargazers_count": 3568,
#   "stargazers_count": 2458,
#   "stargazers_count": 2165,
#   .. (27 more repos) ..
  1. Generate an app using create-react-app
# TypeScript FTW.
yarn create react-app --typescript github-search

cd github-search

# Boldly upgrade to latest everything (only the brave):
yarn upgrade-interactive --latest

# A must-have:
yarn add styled-components @types/styled-components
  1. Create a "decent" component structure

    • App.tsx holds our main app.
    • components/SearchBox.tsx has our search input field and search button.
    • components/GithubSearchResult.tsx is search result list.
    • components/SpinningOctocat.tsx is our home-made spinner.
    • github.ts contains our Github API access logic, implemented entirely as a reusable React effect hook.

    We use styled-components everywhere! ✌️

  2. Call API and render result (unstyled)

    We just want to make a API call, e.g. inside a React effect hook, and dump the data to the screen.

    This basically just confirms that we're wired up everything correctly.

    It's probably a good idea to save the Github search response to a local file and use the data during development to speed things up a bit, e.g. not having to perform an actual search API call everytime you reload the app.

  3. Implement search.

    We'll create a separate SearchBox and GithubSearchResult components to keep things nice and orderly.

  4. Implement pagination.

    Github returns a link HTTP header containing pagination links for most of it's API endpoints. We'll extract and use those in our app.

  5. Make things "purrty".

    Add some bling to make our app look somewhat less crappy.

github-search's People

Watchers

James Cloos avatar Anri Digholm 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.