|
1 | | -# MyWorkspace |
| 1 | +# Material Calendar |
| 2 | +Please read this **before** usage! |
| 3 | +This material calendar is just beginning. As in the angular material components, a beautiful calendar is to be generated by simple integration. Cooperation is welcome. |
2 | 4 |
|
3 | | -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.7. |
| 5 | +### Live demo |
| 6 | +[Open demo on Stackblitz](https://stackblitz.com/github/e-netsupport/material-calendar-demo) |
4 | 7 |
|
5 | | -## Development server |
| 8 | +## Installing |
| 9 | +`npm i material-calendar` |
6 | 10 |
|
7 | | -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. |
| 11 | +## Usage |
| 12 | +app.module.ts |
| 13 | +``` typescript |
| 14 | +import { BrowserModule } from '@angular/platform-browser'; |
| 15 | +import { NgModule, LOCALE_ID } from '@angular/core'; |
| 16 | + |
| 17 | +import { AppComponent } from './app.component'; |
| 18 | +import { MaterialCalendarModule } from 'material-calendar'; |
| 19 | + |
| 20 | +@NgModule({ |
| 21 | + declarations: [ |
| 22 | + AppComponent |
| 23 | + ], |
| 24 | + imports: [ |
| 25 | + BrowserModule, |
| 26 | + MaterialCalendarModule |
| 27 | + ], |
| 28 | + providers: [ |
| 29 | + {provide: LOCALE_ID, useValue: 'de-DE' } |
| 30 | + ], |
| 31 | + bootstrap: [AppComponent] |
| 32 | +}) |
| 33 | +export class AppModule { } |
| 34 | +``` |
| 35 | +import the `MaterialCalendarModule` and optional provide your location. |
| 36 | +In my case: `{provide: LOCALE_ID, useValue: 'de-DE' }` |
| 37 | + |
| 38 | +In your html: |
| 39 | +``` html |
| 40 | +<calendar-panels></calendar-panels> |
| 41 | +``` |
| 42 | +and you are good to go ;) |
| 43 | + |
| 44 | +>If only a one-month layout is required, the following tag can also be used: |
| 45 | +>``` html |
| 46 | +><calendar-panel [placeholderDay]="placeholder" year="2020" month="5" [config]="calendarConfig"> |
| 47 | +></calendar-panel> |
| 48 | +>``` |
| 49 | +>. |
| 50 | +
|
| 51 | +
|
| 52 | +All options are shown here: |
| 53 | +
|
| 54 | +``` html |
| 55 | +<calendar-panels |
| 56 | + [mode]="mode" |
| 57 | + [placeholderDay]="placeholder" |
| 58 | + year="2020" |
| 59 | + month="3" |
| 60 | + monthsBefore="1" |
| 61 | + monthsAfter="1" |
| 62 | + [config]="calendarConfig"> |
| 63 | +</calendar-panels> |
| 64 | +<!-- |
| 65 | + default placeholderDay = false |
| 66 | + default year = current year |
| 67 | + default month = current month |
| 68 | + default monthsBefore = 1 |
| 69 | + default monthsAfter = 1 |
| 70 | +--> |
| 71 | +``` |
| 72 | +``` typescript |
| 73 | +import { CalendarConfig } from 'material-calendar'; |
| 74 | + |
| 75 | +placeholder = false // boolean |
| 76 | +mode = 'monthly' // 'annual' | 'monthly' |
| 77 | + |
| 78 | +calendarConfig: CalendarConfig = { |
| 79 | + panelBgColor: '#00677f', // use only hex or rbg colors |
| 80 | + autoTextColor: true, |
| 81 | + textColor: '#fff', // use only hex or rbg colors |
| 82 | + useHolidays: false, |
| 83 | + holidayColor: 'rgb(253, 173, 0)', // use only hex or rbg colors |
| 84 | + holidayTextColor: 'rgb(253, 173, 0)', // use only hex or rbg colors |
| 85 | + displayYear: true, |
| 86 | + firstDayOfWeekMonday: true, |
| 87 | + todayColor: '#fff', |
| 88 | + panelWidth: '100%', |
| 89 | + calendarWeek: true, |
| 90 | + switches: false, |
| 91 | +} |
| 92 | +``` |
| 93 | +``` javascript |
| 94 | +/** |
| 95 | +* @param {boolean} autoTextColor Sets the text color automatically, based on the backgroud colors |
| 96 | +* @param {boolean} calendarWeek display the calendar week |
| 97 | +* @param {boolean} useHolidays use holidays, only german (for now) |
| 98 | +* @param {boolean} displayYear displays the year next to the Month name |
| 99 | +* @param {boolean} switches not fullt implemented! |
| 100 | +* @param {string} panelBgColor sets the background color of the panel |
| 101 | +* @param {string} textColor if autoTextColor false this must be set to a custom color |
| 102 | +* @param {string} holidayColor sets the background color of the holiday field |
| 103 | +* @param {string} holidayTextColor sets the text color of the holiday field |
| 104 | +* |
| 105 | +*/ |
| 106 | +``` |
| 107 | + |
| 108 | +## Planned features |
| 109 | + |
| 110 | +- insert your own calendar data and render the new template |
| 111 | +- multiselect days optional (returns the daily span) |
| 112 | + |
| 113 | +and many more... |
8 | 114 |
|
9 | 115 | ## Code scaffolding |
10 | 116 |
|
11 | | -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. |
| 117 | +For code scaffolding, the project can be checked out from the public repository and pull requests can be made. |
| 118 | + |
12 | 119 |
|
13 | 120 | ## Build |
14 | 121 |
|
15 | | -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. |
| 122 | + |
| 123 | +Run `ng build material-calendar` to build the project. The build artifacts will be stored in the `dist/` directory. |
| 124 | + |
| 125 | +## Publishing |
| 126 | + |
| 127 | +After building your library with `ng build material-calendar`, go to the dist folder `cd dist/material-calendar` and run `npm publish`. |
| 128 | + |
| 129 | + |
16 | 130 |
|
17 | 131 | ## Running unit tests |
18 | 132 |
|
19 | | -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). |
| 133 | + |
20 | 134 |
|
21 | | -## Running end-to-end tests |
| 135 | +Run `ng test material-calendar` to execute the unit tests via [Karma](https://karma-runner.github.io). |
22 | 136 |
|
23 | | -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). |
| 137 | + |
24 | 138 |
|
25 | 139 | ## Further help |
26 | | - |
27 | | -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
| 140 | +For feature requests or problems, please open a ticket in the issue tracker. |
0 commit comments