GithubHelp home page GithubHelp logo

contributions-prettier's Introduction

Contributions prettier

The objective of this project is to re-create a contributions calendar, as GitHub one does, but use it as playground for draw forms over it.

I will use this functionality to create an Electron app, where you can simulate this board into different ways and colors. Much more comes to my mind but let's see what happens. I use this project to learn and practice more, from algorithms to new enviroments such as Desktop apps.

GitHubCalendar Class

Parameters

Name Type Description
parent HTMLElement Parent element to render inside.
contributions Object List to turn calendar dates on. eg. { "4/27/2021": 4, "4/25/2021": 2, }, where numeric value comes from range [0-4] to indicate changes proportion and color intensity.

Methods

  • setContributions(contributions): void

    It will replace contributions with entered through new object parameter.

    Parameter Type Description
    contributions Object List to turn calendar dates on. eg. { "4/27/2021": 4, "4/25/2021": 2, }, where numeric value comes from range [0-4] to indicate changes proportion and color intensity.

Progress demo

Progress demo

This is a copy my contributions board status.

You can try it out by following bellow steps:

  1. Go to a GitHub profile page.
  2. Open browser inspector by pressing F12 in your keyboard, also using shortcuts such as fn + F12 or Ctrl + Shift + i.
  3. Copy/paste code below to your browser console. The object will be copied automatically.
  4. Replace copied object in file ./src/js/contributions.js.
  5. Build and run desktop app through command npm start.
    const calendar = document.querySelector(".js-calendar-graph-svg");
    const wrapper = calendar.children[0];
    const contributions = {};

    for(let i = 0; i < wrapper.children.length; i++) {
        const child = wrapper.children[i];
        
        if (child.tagName !== "g") continue;
        
        for(let j = 0; j < child.children.length; j++) {
            const date = child.children[j];
            const year = +date.getAttribute("data-date").split("-")[0];
            const month = +date.getAttribute("data-date").split("-")[1];
            const day = +date.getAttribute("data-date").split("-")[2];
            const formattedDate = new Date(year, month - 1, day);
            const level = +date.getAttribute("data-level");

            if (level === 0) continue;
            
            contributions[formattedDate.toLocaleDateString("EN")] = level;
        }
    }

    copy(JSON.stringify(contributions));
    console.warn("COPIED!");

Project stack (What do I use?)

  • Electron
  • JavaScript
  • CSS Grid

Any feedback?? ๐Ÿค” If so, leave an issue or PR ๐Ÿ˜

I will appreciate any feedbacks you could give me. Thanks

contributions-prettier's People

Contributors

nogreg avatar

Stargazers

Larizza Tueros avatar  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.