Skip to content

Commit

Permalink
feat: automatically determine the track
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Sep 4, 2020
1 parent 12fdec1 commit 10e5a1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
15 changes: 14 additions & 1 deletion src/components/Agenda/Agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Session from './Session';
import Time from './Time';
import useMedia from 'use-media';

const hasOwnProperty = Object.prototype.hasOwnProperty;

const Agenda = ({ children, className, tracks, mobileBreakpoint }) => {
const isMobileScreen = useMedia({ maxWidth: mobileBreakpoint });

Expand Down Expand Up @@ -53,7 +55,18 @@ const Agenda = ({ children, className, tracks, mobileBreakpoint }) => {
{!isMobileScreen && (
<Time inactive={sessions[0].props.inactive}>{time}</Time>
)}
{sessions.map((session) => cloneElement(session, { isMobileScreen }))}
{sessions.map((session, idx) => {
const trackIdx = sessions
.slice(0, idx)
.reduce((memo, session) => memo + session.props.span, 0);

return cloneElement(session, {
isMobileScreen,
track: hasOwnProperty.call(session.props, 'track')
? session.props.track
: tracks[trackIdx],
});
})}
</Fragment>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Agenda/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Session = ({
`}
>
<Badge>{time}</Badge>
<Badge>{track}</Badge>
{track && <Badge>{track}</Badge>}
</ul>
)}
</Cell>
Expand Down
21 changes: 4 additions & 17 deletions src/pages/nerd-days.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,106 +370,93 @@ const NerdDaysPage = () => {
time="8:00 AM"
title="Welcome"
speaker="Jemiah Sius"
track="DevOps journey"
track={null}
span={5}
/>
<Agenda.Session
time="8:30 AM"
title="Building Better Apps"
speaker="Anita Baker"
track="Fundamentals"
span={2}
/>
<Agenda.Session
time="8:30 AM"
title="Open DevOps"
speaker="Robert Parr"
track="DevOps journey"
span={2}
/>
<Agenda.Session
time="8:30 AM"
title="NR 101"
speaker="Jeff Osborne"
track="DevOps journey"
/>
<Agenda.Session
time="9:00 AM"
title="All seeing eye"
speaker="Dylan Hernandez"
track="Observability"
/>
<Agenda.Session
time="9:00 AM"
title="AWS Ops"
speaker="Celso Piña"
track="DevOps journey"
/>
<Agenda.Session
time="9:00 AM"
title="Main v Master"
speaker="Jeff Osborne"
track="DevOps journey"
/>
<Agenda.Session
time="9:00 AM"
title="DevOps Journey"
speaker="Jemiah Sius"
track="DevOps journey"
span={2}
/>
<Agenda.Session
time="11:00 AM"
title="Is it down? Yes."
speaker="Dylan Hernandez"
track="Fundamentals"
/>
<Agenda.Session
time="11:00 AM"
title="How much is too much?"
speaker="Natalia Lafourcade"
track="DevOps journey"
span={2}
/>
<Agenda.Session
time="11:00 AM"
title="Monolith Magic"
speaker="John McGibbons"
track="DevOps journey"
/>
<Agenda.Session
time="11:00 AM"
title="Debuggers"
speaker="Anita Baker"
track="DevOps journey"
/>
<Agenda.Session
inactive
time="12:00 AM"
time="12:00 PM"
title="Lunch Break"
speaker="Music by DJ Mykael V"
track="DevOps journey"
track={null}
span={5}
/>
<Agenda.Session
time="1:30 PM"
title="Observability and You"
speaker="Natalia Lafourcade"
track="DevOps journey"
span={3}
/>
<Agenda.Session
time="1:30 PM"
title="COVID Productivity"
speaker="Celso Piña"
track="DevOps journey"
span={2}
/>
<Agenda.Session
time="2:30 PM"
title="Closing + Swag"
speaker="Jemiah Sius and Team"
track="DevOps journey"
track={null}
span={5}
/>
<div className={cx(styles.agendaRow)}>
Expand Down

0 comments on commit 10e5a1a

Please sign in to comment.