UNPKG

10.2 kBMarkdownView Raw
1<h1 align="center">angular 6.0+ calendar</h1>
2
3<div align="center">
4
5[![Sponsorship](https://img.shields.io/badge/funding-github-%23EA4AAA)](https://github.com/users/mattlewis92/sponsorship)
6[![Build Status](https://travis-ci.org/mattlewis92/angular-calendar.svg?branch=master)](https://travis-ci.org/mattlewis92/angular-calendar)
7[![codecov](https://codecov.io/gh/mattlewis92/angular-calendar/branch/master/graph/badge.svg)](https://codecov.io/gh/mattlewis92/angular-calendar)
8[![npm version](https://badge.fury.io/js/angular-calendar.svg)](http://badge.fury.io/js/angular-calendar)
9[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10[![Twitter Follow](https://img.shields.io/twitter/follow/mattlewis92_.svg)](https://twitter.com/mattlewis92_)
11
12</div>
13
14<h2 align="center">Demo</h2>
15
16<div align="center">
17
18https://mattlewis92.github.io/angular-calendar/
19
20</div>
21
22<h2 align="center">Sponsors</h2>
23
24<div align="center">
25<a href="https://github.com/sponsors/mattlewis92">Become a silver or gold sponsor<a> and get your logo on this README on Github with a link to your site.
26</div>
27
28## Table of contents
29
30- [About](#about)
31- [Getting started](#getting-started)
32- [Documentation](#documentation)
33- [Breaking changes](#breaking-changes)
34- [FAQ](#faq)
35- [Angular 1 version](#angular-1-version)
36- [Development](#development)
37- [License](#license)
38
39<h2 align="center">About</h2>
40
41A calendar component for Angular 6.0+ that can display events on a month, week or day view. The successor of [angular-bootstrap-calendar](https://github.com/mattlewis92/angular-bootstrap-calendar).
42
43<h2 align="center">Getting started</h2>
44
45### ng add (recommended)
46
47```sh
48ng add angular-calendar
49```
50
51### Manual setup (ng add will do this all for you)
52
53First install through npm:
54
55```bash
56npm install --save angular-calendar date-fns
57```
58
59Next include the CSS file in the global (not component scoped) styles of your app:
60
61```
62/* angular-cli file: src/styles.css */
63@import "../node_modules/angular-calendar/css/angular-calendar.css";
64```
65
66Finally import the calendar module into your apps module:
67
68```typescript
69import { NgModule } from '@angular/core';
70import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
71import { CalendarModule, DateAdapter } from 'angular-calendar';
72import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';
73
74@NgModule({
75 imports: [
76 BrowserAnimationsModule,
77 CalendarModule.forRoot({
78 provide: DateAdapter,
79 useFactory: adapterFactory,
80 }),
81 ],
82})
83export class MyModule {}
84```
85
86In order to allow the most flexibility for all users there is a substantial amount of boilerplate required to get up and running. Please see the [demos list](https://mattlewis92.github.io/angular-calendar/) for a series of comprehensive examples of how to use this library within your application.
87
88Once you are up and running, to access a full list of options for each component, the individual APIs are documented here: [`mwl-calendar-month-view`](https://mattlewis92.github.io/angular-calendar/docs/components/CalendarMonthViewComponent.html), [`mwl-calendar-week-view`](https://mattlewis92.github.io/angular-calendar/docs/components/CalendarWeekViewComponent.html) and [`mwl-calendar-day-view`](https://mattlewis92.github.io/angular-calendar/docs/components/CalendarDayViewComponent.html).
89
90If you would like a one on one consultation with me where I can show you the best way to integrate and customise this calendar within your application, then you can get this by becoming a Platinum Sponsor on [GitHub](https://github.com/users/mattlewis92/sponsorship).
91
92> Please note: angular-calendar uses [Scarf](https://scarf.sh/) to collect anonymized installation analytics. These analytics help support the maintainers of this library. However, if you'd like to opt out, you can do so by setting `scarfSettings.enabled = false` in your project's package.json. Alternatively, you can set the environment variable `SCARF_ANALYTICS=false` before you install.
93
94### Module bundlers
95
96You can find quick start examples for all common module bundlers in the [build-tool-examples](https://github.com/mattlewis92/angular-calendar/tree/master/build-tool-examples) folder.
97
98<h2 align="center">Documentation</h2>
99
100To see all available API options, take a look at the auto generated [documentation](https://mattlewis92.github.io/angular-calendar/docs/). You may find it helpful to view the examples on the demo page.
101
102<h2 align="center">Breaking changes</h2>
103
104Where possible this library will strictly adhere to [semver](http://semver.org/) and only introduce API breaking changes in 0.x releases or new major versions post 1.0. The only exception to this is if you are using custom templates or extending the base components to add additional functionality, whereby critical bug fixes may introduce breakages as the internal API changes.
105
106<h2 align="center">FAQ</h2>
107
108### Is this library AoT and universal compatible?
109
110Yes.
111
112### What major versions of angular does this library support?
113
114| Angular major | Last supported angular-calendar version |
115| -------------- | ---------------------------------------------------------------------- |
116| 6.x and higher | latest version |
117| 5.x | [0.24.1](https://github.com/mattlewis92/angular-calendar/tree/v0.24.1) |
118| 4.x | [0.22.3](https://github.com/mattlewis92/angular-calendar/tree/v0.22.3) |
119| 2.x | [0.9.1](https://github.com/mattlewis92/angular-calendar/tree/v0.9.1) |
120
121### How do I use this with my favourite module bundler?
122
123See the [examples list](https://github.com/mattlewis92/angular-calendar/tree/master/build-tool-examples).
124
125### No styles are appearing?
126
127No component styles are included with each component to make it easier to override them (otherwise you’d have to use `!important` on every rule that you customised). Thus you need to import the CSS file separately from `node_modules/angular-calendar/css/angular-calendar.css`.
128
129### How come there are so many dependencies?
130
131When building the calendar some parts were found to be reusable so they were split out into their own modules. Only the bare minimum that is required is included with the calendar, there is no extra code than if there were no dependencies. `date-fns` especially only imports directly the functions it needs and not the entire library.
132
133### The month, week or day view doesn’t meet my project requirements, but the other views do.
134
135Build your own component to replace that view, and use it in place of the one this library provides. It’s impossible to provide a calendar component that meets everyones use cases, hopefully though at least some of the day / week / month view components provided can be customised with the calendars API enough to be of some use to most projects.
136
137### How come there’s no year view like the ng1 version?
138
139As there are so many events to show on each month, it doesn’t provide a lot of value and is just an extra burden to maintain. There is nothing to stop someone from building a new lib like `angular-calendar-year-view` though ;)
140
141### Does this calendar work with mobile?
142
143This library is not optimised for mobile. Due to the complex nature of a calendar component, it is non trivial to build a calendar that has a great UX on both desktop and mobile. It is recommended to build your own calendar component for mobile that has a dedicated UX. You may be able to get some degree of mobile support by setting some custom CSS rules for smaller screens on the month view and showing less days on the [week view](https://mattlewis92.github.io/angular-calendar/#/responsive-week-view).
144
145### How do I use a custom template?
146
147All parts of this calendar can be customised via the use of an `ng-template`. The recipe for applying one is as follows:
148
149- Find the template you would like to customise for the month, week or day view component. You can find all available custom templates by reading the [documentation](https://mattlewis92.github.io/angular-calendar/docs/) for each component. For this example we will pick the [`cellTemplate`](https://mattlewis92.github.io/angular-calendar/docs/components/CalendarMonthViewComponent.html#cellTemplate) from the month view.
150- Next find the corresponding child component that will render the template by viewing the source. For our example of the month view cell it is [this component](https://github.com/mattlewis92/angular-calendar/blob/a5fe1f975ecf332c96797326f48081e5d02d264d/projects/angular-calendar/src/modules/month/calendar-month-cell.component.ts)
151- Now copy the [template source](https://github.com/mattlewis92/angular-calendar/blob/a5fe1f975ecf332c96797326f48081e5d02d264d/projects/angular-calendar/src/modules/month/calendar-month-cell.component.ts#L15-L51) for your chosen template into your own component and modify as your see fit.
152- Finally pass the template to the components input: `<mwl-calendar-month-view [cellTemplate]="cellTemplateId" />`
153- You can see an e2e working example of this [here](https://mattlewis92.github.io/angular-calendar/#/custom-templates)
154
155### What is the browser compatibility?
156
157All browsers supported by angular, apart from IE9 as it doesn't support flexbox.
158
159### Does this library require bootstrap?
160
161No! While the demo site uses bootstrap, it isn't a requirement of this library. The styling is designed to adapt to whatever global styling your app has.
162
163<h2 align="center">Angular 1 version</h2>
164
165<div align="center">
166
167https://github.com/mattlewis92/angular-bootstrap-calendar
168
169</div>
170
171<h2 align="center">Development</h2>
172
173### Prepare your environment
174
175- Install [Node.js](http://nodejs.org/) and NPM (should come with)
176- Install local dev dependencies: `npm install` while current directory is this repo
177
178### Development server
179
180Run `npm start` to start a development server on port 8000 with auto reload + tests.
181
182### Testing
183
184Run `npm test` to run tests once or `npm run test:watch` to continually run tests.
185
186### Release
187
188- Bump the version in package.json (once the module hits 1.0 this will become automatic)
189
190```bash
191npm run release
192```