npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ng-github-contrib-calendar/calendar-ng5

v1.0.2

Published

GitHub contributions calendar Angular 5 component

Downloads

6

Readme

Angular GitHub Calendar Component

Release Demo and documentation Coverage Status Build Status Greenkeeper badge

Tested on Safari Tested on Chrome Tested on Firefox


Table of Contents

Installation

Frontend

The metadata version for Angular's AOT compiler differs between Angular 4.x and Angular 5.x, therefore two flavours of this library are released:

| Flavour | Angular 4 | Angular 5 | |-----------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | Local | npm install @ng-github-contrib-calendar/calendar-ng4 | npm install @ng-github-contrib-calendar/calendar-ng5 | | CDN | Package | Package |

The UMD global name is ghContribCalendar.

Backend

A CORS-enabled server is required to retrieve and format GitHub data. A public one is configured for the module, but is provided without any guarantees. You can get your own server here - it's ready to deploy to Heroku for free with one click.

Theming

Built-in themes

The library comes with two built-in themes: light, which mimics the default GitHub calendar skin, and dark, which mimics the dark GitHub userstyle. Once installed, these themes are available under dist/styling; alternatively, you can use a CDN version from one of the links in the installation section.

Dark theme Light theme

Building your own

It's easy to build your own theme - simply import the style builder from dist/styling/_style-builder.scss and include the gh-contrib-calendar-skin mixin:

@mixin gh-contrib-calendar-skin(
  $noContributionsColour,
  $level1Colour,
  $level2Colour,
  $level3Colour,
  $level4Colour,
  $backgroundColour,
  $borderColour,
  $textColour
);

For example, here is the light theme's definition:

@import "style-builder";

@include gh-contrib-calendar-skin(
    #eee, // Colour for days without any contributions
    #c6e48b, // Colour for days with very few contributions
    #7bc96f, // Colour for days with few contributions
    #239a3b, // Colour for days with a decent number of contributions
    #196127, // Colour for days with a lot of contributions
    #fff, // The component's background colour
    #d1d5da, // The component's border colour
    #767676 // The component's text colour
);

Types and Polyfills

Ensure that the following is available globally:

  • Promise
  • Object.freeze

Importing the Module

import {NgModule} from "@angular/core";
import {GhContribCalendarModule} from "@ng-github-contrib-calendar/calendar-ng5"; // replace with @ng-github-contrib-calendar/calendar-ng4 if using Angular 4

@NgModule({
  imports: [
    GhContribCalendarModule
  ]
})
export class MyModule {

}

Usage

The bare minimum

This will use the English locale

<gh-contrib-calendar user="your-username"></gh-contrib-calendar>

With a Prebuilt Locale

The component comes with three prebuilt locales:

  • en for English (default)
  • ru for Russian
  • lt for Lithuanian
<gh-contrib-calendar user="your-username" locale="en"></gh-contrib-calendar>

Showing or Hiding Date Controls

Date controls allow the user to move a year into the future or the past on the calendar. You can hide them as such:

<gh-contrib-calendar user="your-username" [show-controls]="false"></gh-contrib-calendar>

Specifying the Cutoff Date

You can specify the last day shown on the calendar, which can be equal to or less than the current date.

Via the to Parameter

If specified via the to parameter, the full date must be used:

<gh-contrib-calendar user="your-username" to="2018-01-05"></gh-contrib-calendar>

Alternatively, a Date object can be used:

<gh-contrib-calendar user="your-username" [to]="someDateProperty"></gh-contrib-calendar>

Via the y, m and d Parameters

The cutoff date may also be provided with each unit separately. The year must be a number whereas the month and date can be a number or a string, with or without the leading zero:

<gh-contrib-calendar user="your-username" [y]="2018" [m]="1" d="05"></gh-contrib-calendar>

Localisation

Custom localisation can be provided via the translations input parameter using a Partial of the TranslationSpec interface (see API docs). Any string that does not have a translation will default to the one provided by the locale.

<gh-contrib-calendar user="your-username" [translations]="myTranslationsProperty"></gh-contrib-calendar>

Using Your Own Server

The component supports custom fetch servers with the use of the ProxyURLFormatterFunction interface (see API docs). The default function takes a username and, optionally, a cutoff date and formats it into a URL that will be AJAX'd to retrieve the data:

function fn(username: string, toYear?: string | number, toMonth?: string, toDay?: string): string {
  let url = `${StaticConf.DEFAULT_PUBLIC_HOST}/${username}`;

  if (toYear && toMonth && toDay) {
    url += `?to=${toYear}-${toMonth}-${toDay}`;
  }

  return url;
}

console.log(fn('Alorel', 2018, '01', '05'));
// https://gh-contrib-parser-public.herokuapp.com/fetch/Alorel?to=2018-01-05

You can supply your own function via the formatter-fn parameter:

<gh-contrib-calendar user="your-username" [formatter-fn]="myOwnFunction"></gh-contrib-calendar>

Error Handling

The component has an error output with Angular's HttpErrorResponse objects:

<gh-contrib-calendar user="your-username" (error)="myErorrHandler($event)"></gh-contrib-calendar>