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

@nicolai8/add-to-calendar

v1.1.1

Published

customizable JavaScript widget 'Add to Calendar' for event page.

Downloads

11

Readme

https://github.com/AddToCalendar/addtocalendar is now part of https://www.addevent.com/ and in future will be suspended at all. So, this is almost complete rewrite of that library.

Setup

Auto applying

  1. add JS to the page
  2. add addtocalendar class to element in which you want to add calendar button
  3. add event parameters as a child of .addtocalendar

Options

Default

  • language is assumed as browser locale, but if it's not among predefined languages defaultLanguage will be used, i.e. en
  • calendars calendars to show. Is and array. Possible values are: iCalendar, googleCalendar, outlook, yahoo
  • translations key/value object containing translations. If some translation is missing default (en) will be used
Translations

Default keys are:

  • buttonText
  • iCalendar
  • googleCalendar
  • outlook
  • yahoo
Override Options
  1. via global vatiables atcOverrides
  2. via data-atc-* attributes

Notes

Options are applied in the following way: settings = Object.assign(default, global variable, data-atc-*)

Event Parameters

  • date_start in case it's passed via html element it should be in ISO 8601 format; otherwise it's passed as regular Date
  • date_end in case it's passed via html element it should be in ISO 8601 format; otherwise it's passed as regular Date
  • title
  • description
  • location

Examples

Auto

in this case plugin will automatically find .addtocalendar elements then will parse event and show it:

  1. Add JS
<script src="add-to-calendar.min.js" async></script>

or if you're using ES6:

import 'add-to-calendar';
  1. Add styles
<link href="add-to-calendar.css" rel="stylesheet" type="text/css">
<link href="themes/blue.css" rel="stylesheet" type="text/css">
  1. Place html
<span class="addtocalendar atc-style-blue">
  <var class="atc_event">
    <var class="atc_date_start">2018-09-05T12:00:00.000Z</var>
    <var class="atc_date_end">2018-09-05T18:00:00.000Z</var>
    <var class="atc_timezone">Europe/London</var>
    <var class="atc_title">Star Wars Day Party</var>
    <var class="atc_description">May the force be with you</var>
    <var class="atc_location">Tatooine</var>
    <var class="atc_organizer">Luke Skywalker</var>
    <var class="atc_organizer_email">[email protected]</var>
  </var>
</span>

Manually (ES6)

  1. Install dependency
npm i @nicolai8/add-to-calendar
  1. Import method
import { createCalendar } from 'add-to-calendar';
  1. Call it with element, settings and eventParams
const element = document.getElementById('addToCalendarButton');
const settings = {
  language: 'jp',
};
const event = {
  title: 'Event title',
  date_start: new Date(),
  date_end: new Date(),
};
createCalendar(element, settings, event);

Browser Support

* IE11 (.ics is working via Blob) (requires `startsWith` polyfill)
* last 2 versions of major browsers

Notes

Built on top of https://github.com/google/web-starter-kit with some updates to latest versions And also inspired by https://github.com/carlsednaoui/add-to-calendar-buttons