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

bar-calendar

v0.0.6

Published

A simple calendar displaying multiple months as columns

Downloads

7

Readme

Bar Calendar


Bar calendar displays multiple months as columns. Events can take be represented in two ways:

  • bars: full-day or multiple days events

  • dots: short events contained in a single day

This calendar is aimed to be used to give an overview of a middle-term planning with few events per a week.

See the repository and report there any issue

Requirements

  • Bootstrap CSS 3 or greater
  • jQuery 3 or greater
  • Moment 2 or greater

Getting Started

  • Install the plug in
npm install --save bar-calendar
  • Include CSS
<link href="path/to/bootstrap.min.css" rel="stylesheet">
<link href="path/to/bar-calendar.css" rel="stylesheet">
  • Include JS
<script src="path/to/jquery.min.js"></script>
<script src="path/to/moment.min.js"></script>
<script src="path/to/bar-calendar.js"></script>

Then

$("#my-calendar").barCalendar({
  schedule: [                             // list of events scheduled in the planning
    {
      title: "Event 1",
      startDate: "2017-06-10",      // mandatory, "yyyy-MM-dd" or Date
      endDate: "2017-07-06",        // optional,  "yyyy-MM-dd" or Date
      type: "busy"
    },
    {title: "Event 2", startDate: "2017-06-10", endDate: "2017-06-10", type: "vacancy"},
    ...
  ],
  height: 400, // height in px, default is 400
  onClick: function(el, params) {         // triggered on click on the event
    // el: target jQuery element
    // params: schedule's event
  },
  monthsNames: ["Janvier", "Février", "Mars", ...],   // default full names with moment locale
  onMouseEnter: function(el, params) {},  // triggered on mouseenter on the event
  onMouseLeave: function(el, params) {},  // triggered on mouseleave on the event
  onDateChange: function(newDate, oldDate) {},  // triggered when focus date changes
  onRefresh: function() {}                // triggered when calendar is refreshed
});

Examples

You just need to install examples dependencies:

cd node_modules/bar-calendar
npm install

Browse the examples/ directory and open files in your browser

Methods

  • Schedule
$("#my-calendar").barCalendar('schedule');                // returns the current schedule
$("#my-calendar").barCalendar('schedule', newSchedule);   // sets newSchedule as current schedule

Handling events

Click and hover events are caught but not handled by the barCalendar in order to let you use your own UI library.

Define your handlers as barCalendar options. Listeners will give you the selected elements in order to let you place popovers or tooltips.

Don't forget to clean popovers by listening onDateChange.

Angular integration

[Todo] Test or make another package

Calendar detail

Display structure

#my-calendar
  |
  |-- .cal-nav      # buttons on top of the calendar
  |
  |-- .cal-head     # months labels
  |
  |-- .cal-body     # buttons on top of
        |
        |-- .cal-body-head      # days labels
        |
        |-- .cal-body-content   # events wrapper
              |
              |-- .body-layer-bg        # background layer
              |
              |-- .body-layer-months    # months wrapper
                    |
                    |-- .month .month-content    # events wrapper
                          |
                          |-- .cal-bars-wrapper     # all events of type 'bar' wrapped together
                                |
                                |-- .cal-bar        # single bar event
                          |
                          |-- .cal-dots-wrapper     # events of type 'dot', wrapped by day
                                |
                                |-- .cal-dot        # single dot event

Display rules

Events start and end dates can either be javascript Date objects or strings under yyyy-MM-dd format

In the calendar, they are all handled as yyyy-MM-dd strings. Here are the current rules used to display the events:

  • if there is no endDate or endDate has the same value under yyyy-MM-dd format as startDate, it is handled as a dot event
  • events are always ordered from the earliest to the oldest
  • in the same month, events starting earlier are on the right
  • if two events at start the same day, we compare the end date. In this case, the event with the greatest endDate is considered as earliest
  • dot events in the same day are ordered from left (earliest) to right (oldest)

Customize

  • event's type

You are free to use any value for type. A class type-[type] will be generated over the bar-wrapper or dot element. Then override colors and sizes in your own stylesheets.