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

custom-timetable

v1.0.12

Published

A simple timetable component

Downloads

2

Readme

custom-timetable

Custom timetable is a simple but highly customizable UI element showing a timetable for a week. The events are displayed by day and sorted in the following way:

  • Events that happen all day are before ones that don't
  • Events that don't happen all day are sorted by starting hour
  • Events that start at the same hour are sorted by ending hour
  • Events that happen all day, or start and end at the same hours are sorted alphabetically by title

Install

Add custom-timteable to your project:

npm i custom-timetable

Or load the ES module directly through unpkg

<script type="module" src="https://unpkg.com/custom-timetable"></script>

Usage

Import into your module script:

import { CustomTimetable } from "custom-timetable"

or add to your html page:

<script type="module" src="path/to/custom-timetable.bundled.js]"></script>

Use it in your HTML

<custom-timetable></custom-timetable>

Component API

Properties

headertext

The text to use in the header. Default is 'Timetable'

<custom-timetable headertext="My Schedule"></custom-timetable>

refresh-enabled

Whether or not to show the refresh button. Default is false

<custom-timetable refresh-enabled></custom-timetable>

weekends

Whether or not to show weekends. Default is false

<custom-timetable weekends></custom-timetable>

long-names

Whether to show the weekday names in a long format. Default is false (short format)

<custom-timetable long-names></custom-timetable>

start-with-sunday

Whether or not to start the week on Sunday. Default is false (starting with Monday). If weekends is false, this value is ignored (since Sunday is not displayed).

<custom-timetable start-with-sunday></custom-timetable>

all-caps-headers

Whether or not to show the headers in all caps. Default is false

<custom-timetable all-caps-headers></custom-timetable>

displayed-events

Events to display by default, in JSON Array format. Default is empty

<custom-timetable displayed-events='[{"id": 1, "color": "#ff0", "title": "event title", "weekday": "Monday", "allDay": true, "participants":["George"], "location": "Somewhere"}]'></custom-timetable>

Object format that needs to be sent:

{
  id: number, // Unique id
  color: string, // Background color to be displayed
  title: string, // Title of the event
  weekday: string, // Weekday when the event happens, needs to be one of the following: 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'
  allDay: boolean, // Whether or not this event happens all day
  startingHour: string | undefined, // If allDay is false, the hour at which the event starts
  endingHour: string | undefined, // If allDay is false, the hour at which the event ends
  participants: Array<string>, // A list of participants
  location: string // The location where the event happens
}

style-src

Source of style file that can change this component. Default is none

<custom-timetable style-src="style.css"></custom-timetable>

Events

retrieveEvents

This event is fired if refreshing events is enabled, when the component is added to the DOM and whenever the refresh button included in the component is pressed. The event contains a detail object, containing a setEvents function that takes as an argument a list of TimetableEvents as defined prior. Here is an example of how to handle this event in a simplistic manner

function handleRetrieveEvents(event) {
        event.detail.setEvents([{
          id: 1,
          color: "#f00",
          title: "Test Title",
          weekday: "Monday",
          allDay: false,
          startingHour: "18:00",
          endingHour: "20:00",
          participants: ["George", "Mihai"],
          location: "In town"
        }]);
      }
      window.addEventListener("retrieveEvents", handleRetrieveEvents);

Credits

custom-timetable was built using Lit.

License

BSD 3-Clause License