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

ngx-simple-calendar

v1.0.3

Published

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.4.

Downloads

128

Readme

NgxSimpleCalendar

This library was generated with Angular CLI version 8.2.4.

Introduction

Ngx-simple-calendar is an open source, light-weight, highly customizable calendar component for Angular. Allows users to customize day, month templates with event objects of their choosing, providing a simple API.

StackBlitz sample project example: https://stackblitz.com/edit/angular-ngx-simple-calendar

Usage

First install the package with yarn or npm

npm install ngx-simple-calendar

Then import the NgxSimpleCalendarModule

import { BrowserModule } from '@angular/platform-browser';  
import { NgModule } from '@angular/core';  
  
import { AppComponent } from './app.component';  
import {NgxSimpleCalendarModule} from 'ngx-simple-calendar'; 
  
@NgModule({  
  declarations: [AppComponent],  
  imports: [BrowserModule, NgxSimpleCalendarModule],  
  providers: [],  
  bootstrap: [AppComponent]  
})  
export class AppModule { }

Use in your components

---app.component.html

<div class="container">  
 <ngx-simple-calendar></ngx-simple-calendar>  
</div>

----app.component.scss---

.container {  
  position: relative;  
  height: 40rem;  
  width: 40rem;  
  margin: 2rem;  
}

IMPORTANT : For Positioning and dimentions: The wrapper component must have relative positioning, and have determined dimensions.

Custom templates

Here I will list the possibility of customized templates for certain features of the calendar. These are all optional and override the default templates in the component, giving the variables provided by the component for that day.

For days in month

Defining an ng-template with #day inside the component lets you have access to the following properties, which will allow you to make your own custom templates, with custom components as well, as days in the calendar.

| |Type |Meaning | |-------------|-------|-----------------------------------------------------------------| |number |number |The number of the day in current month view | |month |number |The number of the month in the year. 0-indexed. | |year |number |The year of the current month view | |today |boolean|Is this day in the month, today's date ? | |weekend |boolean|Is this day in the month, a weekend day ? | |activeMonth |boolean|Does this day in the month view, belong to current month viewed ?| |startDateTime|Date |Date javascript object of day start | |endDateTime |Date |Date javascript object of day end |

---app.component.html----

 <ngx-simple-calendar [options]="options2" [events]="events">  
	     <ng-template #day 
	     let-date="number" let-events="events" let-active="today" let-weekend="weekend"> 
	      
			 <div class="round-date" [class.active]="active" [class.weekend]="weekend">  
			     <span>{{date}}</span>  
			     <div class="events">  
				     <div class="event" 
				     [style.background-color]="event.data.color" 
				     *ngFor="let event of events" 
				     [title]="event.data.name + event.data.description"></div>  
				 </div>  
			</div>  
			
	     </ng-template>  
 </ngx-simple-calendar>

---app.component.scss---

.round-date {
	  position: absolute;  // The wrapper is positioned relative, so...
      top: 0;  
      bottom: 0;  
      left: 0;  
      right: 0;  
      display: flex;  
      flex-direction: column;   
      background-color: #f5f5f5;  
      border: 1px solid #dedede;  
      border-radius: 25%;  
      padding: 0.55rem; 
      margin: 0.5rem; 
      &.active {  
	      border: 2px dashed #adadad;  
	      background: #eaeaea;  
     }  
     &.weekend {  
	      background: #ffe8e8;  
     }
 }  
 .....

For Days of the week

Defining an ng-template with #weekDays inside the component lets you have access to the following properties:

| |Type |Meaning | |--------------|-------|----------------------------------------| |id|number |Id of day of the week. 0-Sunday...6-Saturday | |translationKey|string|Translation key for translating | |name|string|Name in english |

For Top bar with month-year and navigating functions

Defining an ng-template with #topBar inside the component lets you have access to the following properties:

| |Type |Meaning | |--------------|-------|----------------------------------------| |month|CalendarMonth|Month of currentView properties as listed above | |year|number|Year | |setNextMonth|Function|Function to call when wanting to change current month view to the next | |setPreviousMonth|Function|Function to call when wanting to change current month view to the previous|

Options

The following keys on the Input property options add customizations to the calendar.

| |Type |Meaning | |--------------|-------|----------------------------------------| |outline|boolean |Have bordered days in calendar | |evenDayDimensions|boolean|The days on the calendar to be 1:1 aspect ratio. |

Events

The following keys on the Input property array events add events to the calendar.

| |Type | Meaning | required | |--------------|-------|----------------------------------------|----| |startDateTime|Date|Start date-time of event | yes| |endDateTime|Date|End date-time of event |no | |data|any|Any data that is to be associated to event |no |

How to use events:

Events binds to an array of CalendarEvent objects defined above.

  • startDateTime is required and signifies the start of the event
  • endDateTime is not required, and when it is not given, when the event will only be added to the day (accessible through template of #day ) that holds the given startDateTime (Like a whole day event)
  • When both are given the event is added to the given interval of day, meaning if the interval is between more days, it will be added on all days on which it is a part of (accessible through template of #day )
  • When wanting to update events, just reassign events on the binded property, then the calendar will update it's view and data. Check stackblitz example for help..

Plans for Future Versions

  • Extended API for non-template/default variation. ( For events first and foremost)
  • Year picker, today navigation.
  • Aspect ratio API and Positioning and dimensions (Mainly for ease of use)
  • General API improvements and extensions. (Backwards compatible, without breaking-changes)