Skip to content

Commit 2a515e0

Browse files
authored
Merge pull request #302 from cthow83/main
Allow events to have a "TBD" or "All Day" time
2 parents 14fa8da + 5f255d8 commit 2a515e0

File tree

6 files changed

+202
-61
lines changed

6 files changed

+202
-61
lines changed
+26-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: 💁🏽‍♀️ Add an event for maintainers to the calendar 🎙
22
description: Use this form to add an event for maintainers or highlighting maintainers to the Maintainer Month calendar.
3-
title: "EVENT_NAME"
3+
title: 'EVENT_NAME'
44

55
body:
66
- type: markdown
77
attributes:
88
value: |
99
:tada: Thanks for letting us know about an upcoming event! :tada:
10-
10+
1111
Use this form to add an event for maintainers or highlighting maintainers to the Maintainer Month calendar. Your request will be reviewed within 72 hours.
1212
1313
- id: eventname
@@ -16,36 +16,44 @@ body:
1616
label: Event Name
1717
validations:
1818
required: true
19-
19+
2020
- id: date
2121
type: input
2222
attributes:
2323
label: Event Date
24-
placeholder: "MM/DD"
24+
placeholder: 'MM/DD'
2525
validations:
2626
required: true
2727

28+
- id: endDate
29+
type: input
30+
attributes:
31+
label: Event End Date
32+
placeholder: 'MM/DD'
33+
validations:
34+
required: false
35+
2836
- id: UTCStartTime
2937
type: input
3038
attributes:
3139
label: Start time in UTC
32-
placeholder: "14:00"
40+
placeholder: '14:00'
3341
validations:
3442
required: true
3543

3644
- id: UTCEndTime
3745
type: input
3846
attributes:
3947
label: End time in UTC
40-
placeholder: "15:00"
48+
placeholder: '15:00'
4149
validations:
4250
required: true
4351

4452
- id: type
4553
type: dropdown
4654
attributes:
4755
label: Event Type
48-
description: "Type of event"
56+
description: 'Type of event'
4957
options:
5058
- conference
5159
- podcast
@@ -61,15 +69,15 @@ body:
6169
type: input
6270
attributes:
6371
label: Event Language
64-
description: "Primary language of the event (e.g., English, Spanish, Mandarin)"
72+
description: 'Primary language of the event (e.g., English, Spanish, Mandarin)'
6573
validations:
6674
required: true
6775

6876
- id: location
6977
type: input
7078
attributes:
7179
label: Event Location
72-
description: "Primary location of the event - either Virtual or a City + Country"
80+
description: 'Primary location of the event - either Virtual or a City + Country'
7381
validations:
7482
required: true
7583

@@ -85,25 +93,25 @@ body:
8593
type: input
8694
attributes:
8795
label: Event URL
88-
description: "Web URL of event"
89-
placeholder: "https://"
96+
description: 'Web URL of event'
97+
placeholder: 'https://'
9098

9199
- id: eventdescription
92100
type: textarea
93101
attributes:
94102
label: Event Description
95-
description: "What is this event about?"
96-
103+
description: 'What is this event about?'
104+
97105
- id: expectedparticipants
98106
type: input
99107
attributes:
100108
label: Participants
101-
description: "Expected number of participants"
102-
placeholder: "###"
103-
109+
description: 'Expected number of participants'
110+
placeholder: '###'
111+
104112
- id: expectedmaintainers
105113
type: input
106114
attributes:
107115
label: Maintainers
108-
description: "Expected number of maintainers participating"
109-
placeholder: "###"
116+
description: 'Expected number of maintainers participating'
117+
placeholder: '###'

api/events.js

+58-33
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dayjs.extend(timezone)
1414
const TBD = 'TBD'
1515

1616
export const getEvents = (year) => {
17-
const events_path = year ? `content/${year}/events` : 'content/events';
17+
const events_path = year ? `content/${year}/events` : 'content/events'
1818
const eventFiles = fs.readdirSync(events_path)
1919

2020
const events = eventFiles
@@ -30,13 +30,15 @@ export const getEvents = (year) => {
3030
}
3131

3232
export const getEventBySlug = (slug, year) => {
33-
const event = getDataFromMD(year?`content/${year}/events/${slug}.md`:`content/events/${slug}.md`)
34-
const link = year? `/${year}/schedule/${slug}` : `/schedule/${slug}`;
33+
const event = getDataFromMD(
34+
year ? `content/${year}/events/${slug}.md` : `content/events/${slug}.md`,
35+
)
36+
const link = year ? `/${year}/schedule/${slug}` : `/schedule/${slug}`
3537

3638
return {
3739
slug,
3840
...event,
39-
link
41+
link,
4042
}
4143
}
4244

@@ -59,6 +61,7 @@ export const parseEvent = (event) => {
5961
event.date,
6062
event.UTCStartTime,
6163
event.UTCEndTime,
64+
event.endDate,
6265
)
6366

6467
return {
@@ -68,9 +71,14 @@ export const parseEvent = (event) => {
6871
}
6972

7073
// TODO: refactor
71-
const formatEventDateTime = (date = dayjs.utc(), startTime, endTime) => {
74+
const formatEventDateTime = (
75+
startDate = dayjs.utc(),
76+
startTime,
77+
endTime,
78+
endDate,
79+
) => {
7280
// Date
73-
const [month, day] = date.split('/')
81+
const [month, day] = startDate.split('/')
7482

7583
if (isNaN(month) || isNaN(day)) {
7684
throw new TypeError('date must be in mm/dd format (e.g. 06/12).')
@@ -80,61 +88,78 @@ const formatEventDateTime = (date = dayjs.utc(), startTime, endTime) => {
8088
.utc()
8189
.date(day)
8290
.month(month - 1)
91+
8392
const formattedDate = UTCDate.format('MMM D')
8493

94+
let formattedEndDate = null
95+
96+
if (endDate && endDate !== startDate) {
97+
const [endMonth, endDay] = endDate.split('/')
98+
99+
if (isNaN(endMonth) || isNaN(endDay)) {
100+
throw new TypeError('date must be in mm/dd format (e.g. 06/12).')
101+
}
102+
103+
const endUTCDate = dayjs
104+
.utc()
105+
.date(endDay)
106+
.month(endMonth - 1)
107+
108+
formattedEndDate = endUTCDate.format('MMM D')
109+
}
110+
85111
// Start time
86-
let formattedStartTime = {}
112+
let formattedStartTime = {
113+
utc: TBD,
114+
pt: TBD,
115+
}
87116

88-
if (startTime && startTime !== TBD) {
117+
if (startTime) {
89118
const [startHour, startMinute] = startTime.split(':')
90119

91120
const UTCStartTime = UTCDate.hour(startHour).minute(startMinute)
92121

93-
if (isNaN(UTCStartTime)) {
94-
throw new TypeError(
95-
'UTCStartTime must be in hh:mm format (e.g. 12:30) or be "TDB".',
96-
)
97-
}
98-
99-
const PTStartTime = UTCStartTime.tz('America/Los_Angeles')
122+
if (!isNaN(UTCStartTime)) {
123+
const PTStartTime = UTCStartTime.tz('America/Los_Angeles')
100124

101-
const formattedUTCStartTime = UTCStartTime.format('HH:mm a')
102-
const formattedPTStartTime = PTStartTime.format('HH:mm a')
125+
const formattedUTCStartTime = UTCStartTime.format('HH:mm a')
126+
const formattedPTStartTime = PTStartTime.format('HH:mm a')
103127

104-
formattedStartTime = {
105-
utc: formattedUTCStartTime,
106-
pt: formattedPTStartTime,
128+
formattedStartTime = {
129+
utc: formattedUTCStartTime,
130+
pt: formattedPTStartTime,
131+
}
107132
}
108133
}
109134

110135
// End time
111-
let formattedEndTime = {}
136+
let formattedEndTime = {
137+
utc: TBD,
138+
pt: TBD,
139+
}
112140

113141
if (endTime && endTime !== TBD) {
114142
const [endHour, endMinute] = endTime.split(':')
115143

116144
const UTCEndTime = UTCDate.hour(endHour).minute(endMinute)
117145

118-
if (isNaN(UTCEndTime)) {
119-
throw new TypeError(
120-
'UTCEndTime must be in hh:mm format (e.g. 12:30) or be "TDB".',
121-
)
122-
}
123-
124-
const PTEndTime = UTCEndTime.tz('America/Los_Angeles')
146+
if (!isNaN(UTCEndTime)) {
147+
const PTEndTime = UTCEndTime.tz('America/Los_Angeles')
125148

126-
const formattedUTCEndTime = UTCEndTime.format('HH:mm a')
127-
const formattedPTEndTime = PTEndTime.format('HH:mm a')
149+
const formattedUTCEndTime = UTCEndTime.format('HH:mm a')
150+
const formattedPTEndTime = PTEndTime.format('HH:mm a')
128151

129-
formattedEndTime = {
130-
utc: formattedUTCEndTime,
131-
pt: formattedPTEndTime,
152+
formattedEndTime = {
153+
utc: formattedUTCEndTime,
154+
pt: formattedPTEndTime,
155+
}
132156
}
133157
}
134158

135159
return {
136160
date: formattedDate,
137161
startTime: formattedStartTime,
138162
endTime: formattedEndTime,
163+
endDate: formattedEndDate,
139164
}
140165
}

components/events-list/EventsList.jsx

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ import DateTimeChip from '../date-time-chip/DateTimeChip'
1212
import EventTypeChip from '../event-type-chip/EventTypeChip'
1313
import PlayLink from '../play-link/PlayLink'
1414
import Chip from '../chip/Chip'
15-
1615
const EventsList = ({ events }) => {
16+
const dateLabel = (event) =>
17+
`${event.formattedDate.date} to ${event.formattedDate.endDate}`
18+
1719
return (
1820
<section className="events-list">
1921
<div className="events-list__header">
2022
<div className="events-list__header-content">
2123
<h1 className="events-list__title">{getLiteral('schedule:title')}</h1>
22-
<p className="events-list__subtitle">{getLiteral('schedule:description')}</p>
23-
<ButtonLink
24-
href="https://github.com/github/maintainermonth/issues/new?template=add-to-calendar.yml"
24+
<p className="events-list__subtitle">
25+
{getLiteral('schedule:description')}
26+
</p>
27+
<ButtonLink
28+
href="https://github.com/github/maintainermonth/issues/new?template=add-to-calendar.yml"
2529
isExternal={true}
2630
className="events-list__add-button"
2731
>
@@ -39,7 +43,11 @@ const EventsList = ({ events }) => {
3943
})}
4044
>
4145
<div className="events-list__date">
42-
<Chip label={event.formattedDate.date} />
46+
{event.formattedDate.endDate ? (
47+
<Chip label={dateLabel(event)} />
48+
) : (
49+
<Chip label={event.formattedDate.date} />
50+
)}
4351
</div>
4452

4553
<div className="events-list__event">
@@ -68,7 +76,7 @@ const EventsList = ({ events }) => {
6876
</div>
6977

7078
<div className="events-list__info">
71-
<p
79+
<p
7280
className="events-list__text"
7381
dangerouslySetInnerHTML={{
7482
__html: md().render(event.description || ''),
@@ -80,7 +88,7 @@ const EventsList = ({ events }) => {
8088
))}
8189
</div>
8290
</section>
83-
);
84-
};
91+
)
92+
}
8593

86-
export default EventsList;
94+
export default EventsList

0 commit comments

Comments
 (0)