Coder Social home page Coder Social logo

trending-repos's Introduction

Trending Repos

Intro

An app which shows the most popular repos from github, ranked in descending order according to the number of awarded stars.

Run

Tech

  • React
  • Redux
  • Styled Components
  • Jest

How it Works

In ./srccomponents/app/index.js, a React hook:

  • fetches data from GitHub's api
  • unnecessary data is trimmed
  • properties such as 'starred' are added
  • localStorage is checked to see if any stored items with respect to starring is present, in which case the data is updated accordingly
  • the data is save to a Redux Store

Features

Starring

When pressing a repo's star, the repo gets starred/de-starred. The star count increments/decrements accordingly.

This app does not post the 'star' vote to github.

Instead it records all the 'starred' repos in localStorage

It has to be ascertained that localStorage is updated only after the starring is successful, i.e., it has reached the store.

To achieve this, a useEffect monitors a property stored in state which changes when a repo is starred / de-starred:

useEffect(() => {
	...
			
    localStorage.setItem('starred', starred)
    }				
}, [starringChanged])

When the app loads or the browser is refreshed, 'localStorage' is checked for any stored starred repos, the respective repos data gets updated with a 'starred' flag, and the number of stars get incremented.

Starred repos can be filtered by pressing the star at the top-right.

Repo Languages

Repos can be filtered by programming language.

However, the languages had to be mocked, since github limits api queries for unauthenticated users to 60 per hour, and fetching the languages per repo, 30 in all, requires a seperate query each.

Thus to get the languages for 30 repos requires 31 api calls. Therefore, using github's api, obtaining the languages per repo can only be run once per hour.

Therefore languages are mocked by assigning three random languages to each repo.

trending-repos's People

Contributors

salis010 avatar

Watchers

 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.