Skip to content

Commit abf02d8

Browse files
author
Matt Lewis
committed
feat(monthView): allow a css class to be added to a column header
1 parent c9a2366 commit abf02d8

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"dependencies": {
144144
"angular-draggable-droppable": "^1.0.1",
145145
"angular-resizable-element": "^1.1.1",
146-
"calendar-utils": "0.0.55",
146+
"calendar-utils": "0.0.56",
147147
"date-fns": "^1.28.5",
148148
"positioning": "^1.0.4"
149149
}

src/components/month/calendarMonthViewHeader.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { WeekDay } from 'calendar-utils';
1212
[class.cal-past]="day.isPast"
1313
[class.cal-today]="day.isToday"
1414
[class.cal-future]="day.isFuture"
15-
[class.cal-weekend]="day.isWeekend">
15+
[class.cal-weekend]="day.isWeekend"
16+
[ngClass]="day.cssClass">
1617
{{ day.date | calendarDate:'monthViewColumnHeader':locale }}
1718
</div>
1819
</div>

test/calendarMonthView.component.spec.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('calendarMonthView component', () => {
119119
fixture.destroy();
120120
});
121121

122-
it('should add a custom CSS class to days via the day modifier', () => {
122+
it('should add a custom CSS class to days via the beforeViewRender output', () => {
123123
const fixture: ComponentFixture<CalendarMonthViewComponent> = TestBed.createComponent(CalendarMonthViewComponent);
124124
fixture.componentInstance.viewDate = new Date('2016-06-27');
125125
fixture.componentInstance.beforeViewRender.take(1).subscribe(({body}) => {
@@ -131,6 +131,18 @@ describe('calendarMonthView component', () => {
131131
fixture.destroy();
132132
});
133133

134+
it('should add a custom CSS class to headers via the beforeViewRender output', () => {
135+
const fixture: ComponentFixture<CalendarMonthViewComponent> = TestBed.createComponent(CalendarMonthViewComponent);
136+
fixture.componentInstance.viewDate = new Date('2016-06-27');
137+
fixture.componentInstance.beforeViewRender.take(1).subscribe(({header}) => {
138+
header[0].cssClass = 'foo';
139+
});
140+
fixture.componentInstance.ngOnChanges({viewDate: {}, events: {}});
141+
fixture.detectChanges();
142+
expect(fixture.nativeElement.querySelector('.cal-header .cal-cell').classList.contains('foo')).to.equal(true);
143+
fixture.destroy();
144+
});
145+
134146
it('should not remove other classes when removing the cssClass', () => {
135147
const fixture: ComponentFixture<CalendarMonthViewComponent> = TestBed.createComponent(CalendarMonthViewComponent);
136148
fixture.componentInstance.viewDate = new Date('2016-06-27');

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,9 @@ cachedir@^1.1.0:
825825
dependencies:
826826
os-homedir "^1.0.1"
827827

828-
829-
version "0.0.55"
830-
resolved "https://registry.yarnpkg.com/calendar-utils/-/calendar-utils-0.0.55.tgz#5a46351591c7f8c60bd1eb545cf7a7faa1b11c8b"
828+
829+
version "0.0.56"
830+
resolved "https://registry.yarnpkg.com/calendar-utils/-/calendar-utils-0.0.56.tgz#db6dbbbca8eceeb2107d86e0fd1f80c55a3abfa4"
831831

832832
833833
version "1.0.0"

0 commit comments

Comments
 (0)