Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shad1ks committed Jul 3, 2019
1 parent 959ffcc commit 73f340c
Show file tree
Hide file tree
Showing 26 changed files with 11,162 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs
.code
node_modules
dist
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
183 changes: 182 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,182 @@
# ngx-calendar
# ngx-calendar

### Description

Calendar component for Angular.

### Demo

- [StackBlitz](https://stackblitz.com/edit/ngx-calendar-demo)

### Requirements

- [Moment.js](https://momentjs.com/)
- [Angular](https://angular.io/)

### Install

- **NPM**

```
npm install ss-ngx-calendar
```

### Setup

```javascript
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";

import { NgxCalendarModule } from "ngx-calendar";

@NgModule({
imports: [
CommonModule,

NgxCalendarModule
]
})
export class AppModule { }
```

### Usage

```javascript
calendarOptions = {};

calendarValue = null;

onChooseDate(date: any) {
this.calendarValue = date;
}
```

```html
<ngx-calendar [options]="calendarOptions" (onChooseDate)="onChooseDate($event)"></ngx-calendar>
```

### Options

- **Week view (No time.)**<br>Use to switch to week view mode.

```javascript
calendarOptions = { isWeek: true };
```

- **Week view (With time.)**<br>Use to add time to week view mode.

```javascript
calendarOptions = { isWeek: true, isWithTime: true };
```

> **WARNING**: Options described from now will be working just for the week view mode with time.
- **Available date range**<br>Use to hide times, not within this range.
- Also, disables arrow to change a week, if there are no available times.

```javascript
calendarOptions = { isWeek: true, isWithTime: true, fromDate: moment(), toDate: moment().add(1, "M") };

//If you need to set fromDate: moment(), just use isFromNow: true.
```

- **Available time range**<br>Use to hide hours, not within this range.
- Default is from 0 to 23.

```javascript
calendarOptions = { isWeek: true, isWithTime: true, fromHour: 7, toHour: 19 };
```

- **Interval**<br>Use to generate hours with some interval.
- Default is 1 hour.

```javascript
calendarOptions = { isWeek: true, isWithTime: true, hourInterval: 2, minuteInterval: 30 };
```

### Additional

- **Events**<br>Use to highlight the date.
- **WARNING**: Just for month view mode.

```javascript
calendarOptions = {};

calendarEvents = [moment(), "2022-07-12"];
```

```html
<ngx-calendar [options]="calendarOptions" [events]="calendarEvents"></ngx-calendar>
```

- **Get date range**<br>Use to get date range and watch changes after clicking on arrows.

```javascript
calendarOptions = {};

onChangeDate(dateRange: any) {
//dateRange is an object with fromDate and toDate properties as moment objects.
}
```

```html
<ngx-calendar [options]="calendarOptions" (onChangeDate)="onChangeDate($event)"></ngx-calendar>
```

- **Get chosen date**<br>Use to get chosen date after clicking on one.
- Clicking on one date two times will clear it.

```javascript
calendarOptions = {};

onChooseDate(date: any) {
//date is a chosen date as moment object or null.
}
```

```html
<ngx-calendar [options]="calendarOptions" (onChooseDate)="onChooseDate($event)"></ngx-calendar>
```

- **Change view**<br>Use to change view after load.

```javascript
import { NgxCalendarComponent } from "ngx-calendar";

@ViewChild("ngxCalendar") ngxCalendar: NgxCalendarComponent;

calendarOptions = {};

//After the calendar is initialized.
ngAfterViewInit() {
var isMonth = false; //To change to week view mode.

this.ngxCalendar.setView(isMonth);
}

```

```html
<ngx-calendar #ngxCalendar [options]="calendarOptions"></ngx-calendar>
```

- **Refresh**<br>Use to reload options in case of change.

```javascript
import { NgxCalendarComponent } from "ngx-calendar";

@ViewChild("ngxCalendar") ngxCalendar: NgxCalendarComponent;

calendarOptions = {};

//After the calendar is initialized.
ngAfterViewInit() {
this.calendarOptions = { isWeek: true, isWithTime: true, fromHour: 8, toHour: 17 };

this.ngxCalendar.refresh();
}
```

```html
<ngx-calendar #ngxCalendar [options]="calendarOptions"></ngx-calendar>
```
79 changes: 79 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ngx-calendar-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ngx-calendar-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [],
"styles": [
"src/index.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ngx-calendar-app:build"
},
"configurations": {
"production": {
"browserTarget": "ngx-calendar-app:build:production"
}
}
}
}
},
"ngx-calendar": {
"root": "projects/ngx-calendar",
"sourceRoot": "projects/ngx-calendar/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ngx-calendar/tsconfig.lib.json",
"project": "projects/ngx-calendar/ng-package.json"
}
}
}
}
},
"defaultProject": "ngx-calendar-app"
}
Loading

0 comments on commit 73f340c

Please sign in to comment.