Skip to content

Commit 5027de3

Browse files
committed
chore: updates regarding review
use correct color scheme for views use blue scheme from existing demos apply fallback color if none specified when toggling daylight remove default.scss apply currentColor to links within cal-event-title
1 parent 136f551 commit 5027de3

10 files changed

+85
-18
lines changed

demos/demo-modules/exclude-days/component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export class DemoComponent {
2828
{
2929
start: new Date('2016-01-01'),
3030
end: new Date('2016-01-09'),
31-
title: 'Multiple weeks event',
32-
color: colors.blue
31+
title: 'Multiple weeks event'
3332
}
3433
];
3534

src/angular-calendar.scss

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
@import './modules/week/calendar-week-view';
33
@import './modules/day/calendar-day-view';
44
@import './modules/common/calendar-tooltip';
5-
@import './defaults';

src/defaults.scss

-6
This file was deleted.

src/modules/day/calendar-day-view.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,20 @@
4848
}
4949

5050
.cal-event {
51-
border: solid 1px;
5251
padding: 5px;
5352
font-size: 12px;
5453
overflow: hidden;
5554
text-overflow: ellipsis;
5655
white-space: nowrap;
5756
height: 100%;
5857
box-sizing: border-box;
58+
background-color: #D1E8FF;
59+
border: 1px solid #1e90ff;
60+
color: #1e90ff;
61+
}
62+
63+
.cal-event-title:link {
64+
color: currentColor;
5965
}
6066

6167
.cal-draggable {

src/modules/month/calendar-month-view.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ export class CalendarMonthViewComponent
312312
toggleDayHighlight(event: CalendarEvent, isHighlighted: boolean): void {
313313
this.view.days.forEach(day => {
314314
if (isHighlighted && day.events.indexOf(event) > -1) {
315-
day.backgroundColor = event.color.secondary;
315+
day.backgroundColor =
316+
(event.color && event.color.secondary) || '#D1E8FF';
316317
} else {
317318
delete day.backgroundColor;
318319
}

src/modules/month/calendar-month-view.scss

+3-4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
border-radius: 50%;
9898
display: inline-block;
9999
margin: 2px;
100+
background-color: #1e90ff;
101+
border-color: #D1E8FF;
102+
color: #fff;
100103
}
101104

102105
.cal-day-cell.cal-in-month.cal-has-events {
@@ -136,10 +139,6 @@
136139
top: 2px;
137140
}
138141

139-
.cal-event-title {
140-
color: white;
141-
}
142-
143142
.cal-out-month {
144143
.cal-day-badge,
145144
.cal-event {

src/modules/week/calendar-week-view.scss

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
margin-right: 2px;
4545
height: 30px;
4646
line-height: 30px;
47+
background-color: #D1E8FF;
48+
border: 1px solid #1e90ff;
49+
color: #1e90ff;
50+
}
51+
52+
.cal-event-title:link {
53+
color: currentColor;
4754
}
4855

4956
.cal-draggable {

test/calendar-day-view.component.spec.ts

+31
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,37 @@ describe('CalendarDayViewComponent component', () => {
7272
expect(fixture.componentInstance.hours.length).to.equal(24);
7373
});
7474

75+
it('should generate the week view with default colors for events', () => {
76+
const fixture: ComponentFixture<
77+
CalendarDayViewComponent
78+
> = TestBed.createComponent(CalendarDayViewComponent);
79+
fixture.componentInstance.ngOnInit();
80+
fixture.componentInstance.viewDate = new Date('2016-06-01');
81+
fixture.componentInstance.events = [
82+
{
83+
start: new Date('2016-05-30'),
84+
end: new Date('2016-06-02'),
85+
title: 'foo'
86+
}
87+
];
88+
fixture.componentInstance.ngOnChanges({ viewDate: {}, events: {} });
89+
fixture.detectChanges();
90+
91+
const computedStyles: CSSStyleDeclaration = window.getComputedStyle(
92+
fixture.nativeElement.querySelector('.cal-event')
93+
);
94+
expect(computedStyles.getPropertyValue('background-color')).to.equal(
95+
'rgb(209, 232, 255)'
96+
);
97+
expect(computedStyles.getPropertyValue('border-color')).to.equal(
98+
'rgb(30, 144, 255)'
99+
);
100+
expect(computedStyles.getPropertyValue('color')).to.equal(
101+
'rgb(30, 144, 255)'
102+
);
103+
fixture.destroy();
104+
});
105+
75106
it(
76107
'should call the event clicked callback',
77108
async(() => {

test/calendar-month-view.component.spec.ts

+31
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,37 @@ describe('calendarMonthView component', () => {
7171
fixture.destroy();
7272
});
7373

74+
it('should generate the week view with default colors for events', () => {
75+
const fixture: ComponentFixture<
76+
CalendarMonthViewComponent
77+
> = TestBed.createComponent(CalendarMonthViewComponent);
78+
fixture.componentInstance.ngOnInit();
79+
fixture.componentInstance.viewDate = new Date('2016-06-01');
80+
fixture.componentInstance.events = [
81+
{
82+
start: new Date('2016-05-30'),
83+
end: new Date('2016-06-02'),
84+
title: 'foo'
85+
}
86+
];
87+
fixture.componentInstance.ngOnChanges({ viewDate: {}, events: {} });
88+
fixture.detectChanges();
89+
90+
const computedStyles: CSSStyleDeclaration = window.getComputedStyle(
91+
fixture.nativeElement.querySelector('.cal-event')
92+
);
93+
expect(computedStyles.getPropertyValue('background-color')).to.equal(
94+
'rgb(30, 144, 255)'
95+
);
96+
expect(computedStyles.getPropertyValue('border-color')).to.equal(
97+
'rgb(209, 232, 255)'
98+
);
99+
expect(computedStyles.getPropertyValue('color')).to.equal(
100+
'rgb(255, 255, 255)'
101+
);
102+
fixture.destroy();
103+
});
104+
74105
it('should generate the month view without from week excluded days', () => {
75106
const fixture: ComponentFixture<
76107
CalendarMonthViewComponent

test/calendar-week-view.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ describe('calendarWeekView component', () => {
112112
fixture.nativeElement.querySelector('.cal-event')
113113
);
114114
expect(computedStyles.getPropertyValue('background-color')).to.equal(
115-
'rgb(0, 98, 204)'
115+
'rgb(209, 232, 255)'
116116
);
117117
expect(computedStyles.getPropertyValue('border-color')).to.equal(
118-
'rgb(0, 92, 191)'
118+
'rgb(30, 144, 255)'
119119
);
120120
expect(computedStyles.getPropertyValue('color')).to.equal(
121-
'rgb(255, 255, 255)'
121+
'rgb(30, 144, 255)'
122122
);
123123
fixture.destroy();
124124
});

0 commit comments

Comments
 (0)