Skip to content

Commit 0008a83

Browse files
author
Matt Lewis
committed
fix(monthView): add helper classes to the month view header
Closes #152
1 parent 36a53d3 commit 0008a83

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/components/month/calendarMonthView.component.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ import { CalendarEventTimesChangedEvent } from '../../interfaces/calendarEventTi
4646
template: `
4747
<div class="cal-month-view">
4848
<div class="cal-cell-row cal-header">
49-
<div class="cal-cell" *ngFor="let header of columnHeaders">
49+
<div
50+
class="cal-cell"
51+
*ngFor="let header of columnHeaders"
52+
[class.cal-past]="header.isPast"
53+
[class.cal-today]="header.isToday"
54+
[class.cal-future]="header.isFuture"
55+
[class.cal-weekend]="header.isWeekend">
5056
{{ header.date | calendarDate:'monthViewColumnHeader':locale }}
5157
</div>
5258
</div>

test/calendarMonthView.component.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,19 @@ describe('calendarMonthView component', () => {
414414
expect(dayClickedFired).to.be.false;
415415
});
416416

417+
it('should add helper classes to the header cells', () => {
418+
const fixture: ComponentFixture<CalendarMonthViewComponent> = TestBed.createComponent(CalendarMonthViewComponent);
419+
fixture.componentInstance.viewDate = new Date('2016-06-27');
420+
fixture.componentInstance.ngOnChanges({viewDate: {}});
421+
fixture.detectChanges();
422+
const headerCells: HTMLElement[] = fixture.nativeElement.querySelectorAll('.cal-header .cal-cell');
423+
expect(headerCells[0].classList.contains('cal-past')).to.be.true;
424+
expect(headerCells[0].classList.contains('cal-today')).to.be.false;
425+
expect(headerCells[0].classList.contains('cal-future')).to.be.false;
426+
expect(headerCells[0].classList.contains('cal-weekend')).to.be.true;
427+
expect(headerCells[1].classList.contains('cal-weekend')).to.be.false;
428+
expect(headerCells[6].classList.contains('cal-weekend')).to.be.true;
429+
fixture.destroy();
430+
});
431+
417432
});

0 commit comments

Comments
 (0)