Skip to content

Commit ea35472

Browse files
John Crowsonbrandonroberts
authored andcommitted
docs: update events page with upcoming events, automatically move past events (#1617)
Closes #1615
1 parent 5e8c97b commit ea35472

File tree

12 files changed

+555
-70
lines changed

12 files changed

+555
-70
lines changed

projects/ngrx.io/content/marketing/events.html

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,5 @@
22
<h1 class="banner-headline no-toc no-anchor">Events</h1>
33
</header>
44
<article>
5-
<p>Upcoming Events presenting about NgRx:</p>
6-
<table class="is-full-width">
7-
<thead>
8-
<tr>
9-
<th>Event</th>
10-
<th>Location</th>
11-
<th>Date</th>
12-
</tr>
13-
</thead>
14-
<tbody>
15-
<tr>
16-
<th><a href="http://ng-atl.org/" title="ngAtlanta">ngAtlanta</a></th>
17-
<td>Atlanta, Georgia</td>
18-
<td>January 9 - 12, 2019</td>
19-
</tr>
20-
<tr>
21-
<th><a href="https://www.ng-ind.com" title="ng-India">ng-India</a></th>
22-
<td>Gurgaon, India</td>
23-
<td>February 23, 2019</td>
24-
</tr>
25-
<tr>
26-
<th><a href="https://www.ng-conf.org" title="ng-conf">ng-conf</a></th>
27-
<td>Salt Lake City, Utah</td>
28-
<td>May 1 - 3, 2019</td>
29-
</tr>
30-
</tbody>
31-
</table>
32-
<p>Past Events:</p>
33-
<table class="is-full-width">
34-
<thead>
35-
<tr>
36-
<th>Event</th>
37-
<th>Location</th>
38-
<th>Date</th>
39-
</tr>
40-
</thead>
41-
<tbody>
42-
<tr>
43-
<th><a href="http://www.ngcolombia.com" title="NgColombia">NgColombia</a></th>
44-
<td>Medellín, Colombia</td>
45-
<td>September 6 - 7th, 2018</td>
46-
</tr>
47-
<tr>
48-
<th><a href="http://devfestatl.com" title="DevFestATL">DevFestATL</a></th>
49-
<td>Atlanta, GA</td>
50-
<td>September 22nd, 2018</td>
51-
</tr>
52-
<tr>
53-
<th><a href="http://frameworksummit.com" title="Framework Summit">Framework Summit</a></th>
54-
<td>Park City, UT</td>
55-
<td>September 22nd, 2018</td>
56-
</tr>
57-
<tr>
58-
<th><a href="http://devfestatl.com" title="DevFestATL">DevFestATL</a></th>
59-
<td>Atlanta, GA</td>
60-
<td>October 2 - 3rd, 2018</td>
61-
</tr>
62-
<tr>
63-
<th><a href="http://www.angularmix.com" title="AngularMix">AngularMix - Use the discount code "RYAN" or "ROBERTS" to receive $50 off your registration!</a></th>
64-
<td>Orlando, FL</td>
65-
<td>October 10 - 12th, 2018</td>
66-
</tr>
67-
<tr>
68-
<th><a href="http://www.angularconnect.com" title="AngularConnect">AngularConnect</a></th>
69-
<td>Excel, London</td>
70-
<td>November 6 - 7th, 2018</td>
71-
</tr>
72-
</tbody>
73-
</table>
5+
<aio-event-list></aio-event-list>
746
</article>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[
2+
{
3+
"name": "NgColombia",
4+
"url": "http://www.ngcolombia.com",
5+
"location": "Medellín, Colombia",
6+
"startDate": "2018-09-06",
7+
"endDate": "2018-09-07"
8+
},
9+
{
10+
"name": "DevFestATL",
11+
"url": "http://devfestatl.com",
12+
"location": "Atlanta, Georgia",
13+
"endDate": "2018-09-22"
14+
},
15+
{
16+
"name": "Framework Summit",
17+
"url": "http://frameworksummit.com",
18+
"location": "Park City, Utah",
19+
"endDate": "2018-09-22"
20+
},
21+
{
22+
"name": "DevFestATL",
23+
"url": "http://devfestatl.com",
24+
"location": "Atlanta, Georgia",
25+
"startDate": "2018-10-02",
26+
"endDate": "2018-10-03"
27+
},
28+
{
29+
"name": "AngularMix",
30+
"url": "http://www.angularmix.com",
31+
"location": "Orlando, Florida",
32+
"startDate": "2018-10-10",
33+
"endDate": "2018-10-12"
34+
},
35+
{
36+
"name": "AngularConnect",
37+
"url": "https://www.angularconnect.com",
38+
"location": "Excel, London",
39+
"startDate": "2018-11-06",
40+
"endDate": "2018-11-07"
41+
},
42+
{
43+
"name": "ngAtlanta",
44+
"url": "http://ng-atl.org/",
45+
"location": "Atlanta, Georgia",
46+
"startDate": "2019-01-09",
47+
"endDate": "2019-01-12"
48+
},
49+
{
50+
"name": "ng-India",
51+
"url": "https://www.ng-ind.com",
52+
"location": "Gurgaon, India",
53+
"endDate": "2019-02-23"
54+
},
55+
{
56+
"name": "Open Source 101",
57+
"url": "https://opensource101.com/",
58+
"location": "Columbia, South Carolina",
59+
"endDate": "2019-04-18"
60+
},
61+
{
62+
"name": "NG-Conf",
63+
"url": "https://www.ng-conf.org",
64+
"location": "Salt Lake City, Utah",
65+
"startDate": "2019-05-01",
66+
"endDate": "2019-05-03"
67+
},
68+
{
69+
"name": "ngVikings",
70+
"url": "https://ngvikings.org/",
71+
"location": "Copenhagen, Denmark",
72+
"startDate": "2019-05-26",
73+
"endDate": "2019-05-28"
74+
},
75+
{
76+
"name": "REFACTR.TECH",
77+
"url": "https://refactr.tech/",
78+
"location": "Atlanta, Georgia",
79+
"startDate": "2019-06-05",
80+
"endDate": "2019-06-07"
81+
},
82+
{
83+
"name": "AngularUP",
84+
"url": "https://angular-up.com/",
85+
"location": "Tel Aviv, Israel",
86+
"endDate": "2019-06-12"
87+
},
88+
{
89+
"name": "NG-MY",
90+
"url": "https://ng-my.org/",
91+
"location": "Kuala Lumpur, Malaysia",
92+
"startDate": "2019-07-06",
93+
"endDate": "2019-07-07"
94+
},
95+
{
96+
"name": "ngDenver",
97+
"url": "http://angulardenver.com/",
98+
"location": "Denver, Colorado",
99+
"startDate": "2019-08-01",
100+
"endDate": "2019-08-02"
101+
},
102+
{
103+
"name": "AngularConnect",
104+
"url": "https://www.angularconnect.com/",
105+
"location": "London, United Kingdom",
106+
"startDate": "2019-09-19",
107+
"endDate": "2019-09-20"
108+
},
109+
{
110+
"name": "NG-Rome",
111+
"url": "https://ngrome.io/",
112+
"location": "Rome, Italy",
113+
"endDate": "2019-10-07"
114+
}
115+
]

projects/ngrx.io/src/app/custom-elements/element-registry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export const ELEMENT_MODULE_PATHS_AS_ROUTES = [
1717
selector: 'aio-contributor-list',
1818
loadChildren: './contributor/contributor-list.module#ContributorListModule',
1919
},
20+
{
21+
selector: 'aio-event-list',
22+
loadChildren: './events/event-list.module#EventListModule',
23+
},
2024
{
2125
selector: 'aio-file-not-found-search',
2226
loadChildren:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { EventDateRangePipe } from './event-date-range.pipe';
2+
import { Event } from './event.model';
3+
4+
describe('Pipe: Event Date Range', () => {
5+
let pipe: EventDateRangePipe;
6+
7+
beforeEach(() => {
8+
pipe = new EventDateRangePipe();
9+
});
10+
11+
it('providing no startDate should format only the endDate in MM DD, YYYY', () => {
12+
const event: Event = {
13+
name: '',
14+
url: '',
15+
location: '',
16+
endDate: new Date('2019-01-01')
17+
};
18+
expect(pipe.transform(event)).toBe('January 1, 2019');
19+
});
20+
21+
it('providing the same startDate and endDate should format only one in MM DD, YYYY', () => {
22+
const event: Event = {
23+
name: '',
24+
url: '',
25+
location: '',
26+
startDate: new Date('2019-01-01'),
27+
endDate: new Date('2019-01-01')
28+
};
29+
expect(pipe.transform(event)).toBe('January 1, 2019');
30+
});
31+
32+
it('providing different days in the same month and year should format in MM DD - DD, YYYY format', () => {
33+
const event: Event = {
34+
name: '',
35+
url: '',
36+
location: '',
37+
startDate: new Date('2019-01-01'),
38+
endDate: new Date('2019-01-02')
39+
};
40+
expect(pipe.transform(event)).toBe('January 1 - 2, 2019');
41+
});
42+
43+
it('providing different days and months in the same year should format in MM DD - MM DD, YYYY format', () => {
44+
const event: Event = {
45+
name: '',
46+
url: '',
47+
location: '',
48+
startDate: new Date('2019-01-01'),
49+
endDate: new Date('2019-01-02')
50+
};
51+
expect(pipe.transform(event)).toBe('January 1 - 2, 2019');
52+
});
53+
54+
it('providing different days, months, and years should format in MM DD, YYYY - MM DD, YYYY format', () => {
55+
const event: Event = {
56+
name: '',
57+
url: '',
58+
location: '',
59+
startDate: new Date('2018-12-31'),
60+
endDate: new Date('2019-01-01')
61+
};
62+
expect(pipe.transform(event)).toBe('December 31, 2018 - January 1, 2019');
63+
});
64+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { Event } from './event.model';
3+
4+
/**
5+
* Transforms the startDate and endDate for a given event into a dange range string.
6+
* undefined until '01-01-2019' -> 'January 1, 2019'
7+
* '01-01-2019' until '01-01-2019' -> 'January 1, 2019'
8+
* '01-01-2019' until '01-02-2019' -> 'January 1 - 2, 2019'
9+
* '01-28-2019' until '02-01-2019' -> 'January 28 - February 1, 2019'
10+
* '12-31-2018' until '01-01-2019' -> 'December 31, 2018 - January 1, 2019'
11+
*/
12+
@Pipe({name: 'eventDateRange'})
13+
export class EventDateRangePipe implements PipeTransform {
14+
transform(event: Event): string {
15+
const startDate = event.startDate;
16+
const endDate = event.endDate;
17+
if (!startDate || startDate.getTime() === endDate.getTime()) {
18+
return getDateString(endDate);
19+
} else {
20+
if (getMonth(startDate) === getMonth(endDate) && getYear(startDate) === getYear(endDate)) {
21+
return getMonth(startDate)
22+
+ ' ' + getDay(startDate) + ' - ' + getDay(endDate)
23+
+ ', ' + getYear(startDate);
24+
} else if (getYear(startDate) === getYear(endDate)) {
25+
return getMonth(startDate)
26+
+ ' ' + getDay(startDate)
27+
+ ' - ' + getMonth(endDate)
28+
+ ' ' + getDay(endDate)
29+
+ ', ' + getYear(startDate);
30+
} else {
31+
return getDateString(startDate)
32+
+ ' - ' + getDateString(endDate);
33+
}
34+
}
35+
}
36+
}
37+
38+
const getDay = (date: Date) => date.getUTCDate();
39+
const getMonth = (date: Date) => months[date.getUTCMonth()];
40+
const getYear = (date: Date) => date.getUTCFullYear();
41+
const getDateString = (date: Date) => getMonth(date) + ' ' + getDay(date) + ', ' + getYear(date);
42+
const months = [
43+
'January',
44+
'February',
45+
'March',
46+
'April',
47+
'May',
48+
'June',
49+
'July',
50+
'August',
51+
'September',
52+
'October',
53+
'November',
54+
'December'
55+
];
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { EventListComponent } from './event-list.component';
3+
import { of } from 'rxjs';
4+
import { EventService } from './event.service';
5+
import { Event } from './event.model';
6+
import { EventDateRangePipe } from './event-date-range.pipe';
7+
8+
const mockUpcomingEvents: Event[] = [
9+
{
10+
name: 'NG-Rome',
11+
url: 'https://ngrome.io/',
12+
location: 'Rome, Italy',
13+
endDate: new Date('2019-10-07')
14+
}
15+
];
16+
17+
const mockPastEvents: Event[] = [
18+
{
19+
name: 'DevFestATL',
20+
url: 'http://devfestatl.com',
21+
location: 'Atlanta, Georgia',
22+
endDate: new Date('2018-09-22')
23+
}
24+
];
25+
26+
class TestEventService {
27+
upcomingEvents$ = of(mockUpcomingEvents);
28+
pastEvents$ = of(mockPastEvents);
29+
}
30+
31+
describe('Event List Component', () => {
32+
33+
let fixture: ComponentFixture<EventListComponent>;
34+
let component: EventListComponent;
35+
36+
beforeEach(() => {
37+
TestBed.configureTestingModule({
38+
declarations: [ EventListComponent, EventDateRangePipe ],
39+
providers: [{ provide: EventService, useClass: TestEventService }]
40+
});
41+
42+
fixture = TestBed.createComponent(EventListComponent);
43+
component = fixture.componentInstance;
44+
});
45+
46+
it('should create', () => {
47+
expect(component).toBeTruthy();
48+
});
49+
50+
it('should set the upcomingEvents', () => {
51+
component.upcomingEvents$.subscribe(events => expect(events).toEqual(mockUpcomingEvents));
52+
});
53+
54+
it('should set the pastEvents', () => {
55+
component.pastEvents$.subscribe(events => expect(events).toEqual(mockPastEvents));
56+
});
57+
});

0 commit comments

Comments
 (0)