-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(month picker): month picker POC #3126
- Loading branch information
Showing
5 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
projects/igniteui-angular/src/lib/month-picker/month-picker.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div *ngIf="isDefaultView" [@animateView]="activeView" class="igx-calendar__body"> | ||
<div class="igx-calendar-picker"> | ||
<div class="igx-calendar-picker__prev" (click)="previousYear()"> | ||
<igx-icon fontSet="material">keyboard_arrow_left</igx-icon> | ||
</div> | ||
<div> | ||
<span (click)="activeViewDecade()" class="igx-calendar-picker__date"> | ||
{{ formattedYear(viewDate) }} | ||
</span> | ||
</div> | ||
<div class="igx-calendar-picker__next" (click)="nextYear()"> | ||
<igx-icon fontSet="material">keyboard_arrow_right</igx-icon> | ||
</div> | ||
</div> | ||
|
||
<igx-months-view [@animateChange]="animateAction" #months style="height: 308px" | ||
[date]="viewDate" | ||
[locale]="locale" | ||
[monthFormat]="_formatOptions.month" | ||
(onMonthSelection)="selectMonth($event)" > | ||
</igx-months-view> | ||
</div> | ||
<igx-years-view *ngIf="isDecadeView" [@animateView]="activeView" #decade | ||
[date]="viewDate" | ||
[locale]="locale" | ||
[yearFormat]="_formatOptions.year" | ||
(onYearSelection)="selectYear($event)"> | ||
</igx-years-view> |
80 changes: 80 additions & 0 deletions
80
projects/igniteui-angular/src/lib/month-picker/month-picker.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { | ||
Component, | ||
NgModule | ||
} from '@angular/core'; | ||
import { IgxCalendarModule, CalendarView, IgxCalendarComponent } from '../calendar/index'; | ||
import { IgxIconModule } from '../icon/index'; | ||
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; | ||
import { CommonModule } from '@angular/common'; | ||
import { trigger, transition, useAnimation } from '@angular/animations'; | ||
import { fadeIn, scaleInCenter, slideInLeft, slideInRight } from '../animations/main'; | ||
|
||
@Component({ | ||
providers: [ | ||
{ | ||
multi: true, | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: IgxMonthPickerComponent | ||
} | ||
], | ||
animations: [ | ||
trigger('animateView', [ | ||
transition('void => 0', useAnimation(fadeIn)), | ||
transition('void => *', useAnimation(scaleInCenter, { | ||
params: { | ||
duration: '.2s', | ||
fromScale: .9 | ||
} | ||
})) | ||
]), | ||
trigger('animateChange', [ | ||
transition('* => prev', useAnimation(slideInLeft, { | ||
params: { | ||
fromPosition: 'translateX(-30%)' | ||
} | ||
})), | ||
transition('* => next', useAnimation(slideInRight, { | ||
params: { | ||
fromPosition: 'translateX(30%)' | ||
} | ||
})) | ||
]) | ||
], | ||
selector: 'igx-month-picker', | ||
templateUrl: 'month-picker.component.html' | ||
}) | ||
export class IgxMonthPickerComponent extends IgxCalendarComponent implements ControlValueAccessor { | ||
|
||
public animateAction = ''; | ||
|
||
public previousYear() { | ||
this.animateAction = 'prev'; | ||
this.viewDate = this.calendarModel.timedelta(this.viewDate, 'year', -1); | ||
} | ||
|
||
public nextYear() { | ||
this.animateAction = 'next'; | ||
this.viewDate = this.calendarModel.timedelta(this.viewDate, 'year', 1); | ||
} | ||
|
||
public selectMonth(event: Date) { | ||
this.viewDate = new Date(event.getFullYear(), event.getMonth(), event.getDate()); | ||
this._onChangeCallback(this.viewDate); | ||
} | ||
|
||
public selectYear(event: Date) { | ||
this.viewDate = new Date(event.getFullYear(), event.getMonth(), event.getDate()); | ||
this.activeView = CalendarView.DEFAULT; | ||
|
||
requestAnimationFrame(() => { | ||
this.monthsView.el.nativeElement.focus(); | ||
}); | ||
} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [IgxMonthPickerComponent], | ||
exports: [IgxMonthPickerComponent], | ||
imports: [CommonModule, IgxIconModule, IgxCalendarModule] | ||
}) | ||
export class IgxMonthPickerModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters