diff --git a/src/controls/SessionSheet.scss b/src/controls/SessionSheet.scss index 21a141d..7494380 100644 --- a/src/controls/SessionSheet.scss +++ b/src/controls/SessionSheet.scss @@ -5,6 +5,11 @@ &-header { display: flex; flex-direction: column; + + h6 { + font-weight: 100; + opacity: 0.8; + } } &-content { @@ -66,6 +71,6 @@ border-radius: 0; .session-header { - padding: 12px 24px; + padding: 12px 16px; } } diff --git a/src/controls/SessionSheet.tsx b/src/controls/SessionSheet.tsx index 151285d..28d51b4 100644 --- a/src/controls/SessionSheet.tsx +++ b/src/controls/SessionSheet.tsx @@ -1,7 +1,8 @@ -import React, { FC } from 'react'; +import React, { FC, useMemo } from 'react'; import { connect } from 'react-redux'; import { Dispatch, bindActionCreators } from 'redux'; import { DocumentReference, deleteDoc } from '@firebase/firestore'; +import { intervalToDuration } from 'date-fns/fp'; import createDOMPurify from 'dompurify'; import { Speaker } from 'models/speaker'; @@ -54,6 +55,9 @@ const SessionSheet: FC = ({ editSession(reference, session); }; + const hasDescription = useMemo(() => session.description.length > 0, [session.description]); + const hasSpeakers = useMemo(() => session.speakers.length > 0, [session.speakers]); + const buildAdminActions = () => (
@@ -69,11 +73,23 @@ const SessionSheet: FC = ({
); + const buildSessionHeader = () => { + return
+ {formatSessionTitle()} + {formatSessionLocation()} + {formatSessionDuration()} +
+ } + const formatSessionTitle = () => { let title = ''; - if (session.type) { - title += `[${session.type}] `; + switch (session.type) { + case SessionTypes.BREAK: + case SessionTypes.REGISTRATION: + break; + default: + title += `[${session.type}] `; } title += session.name; @@ -92,14 +108,26 @@ const SessionSheet: FC = ({ return `Room ${session.location}`; }; - if (session.type === SessionTypes.BREAK || session.type === SessionTypes.REGISTRATION) { + const formatSessionDuration = () => { + if (!session.startTime || !session.endTime) return null; + + const interval = intervalToDuration({ + start: session.startTime.toDate(), + end: session.endTime.toDate() + }); + + if (interval.hours > 0) { + return `${interval.hours} hr ${interval.minutes} mins`; + } else { + return `${interval.minutes} mins`; + } + } + + if (!hasDescription && !hasSpeakers) { return ( {isEditMode ? buildAdminActions() : null} -
- {session.name} - {formatSessionLocation()} -
+ {buildSessionHeader()}
); } else { @@ -107,38 +135,35 @@ const SessionSheet: FC = ({ } > {isEditMode ? buildAdminActions() : null} -
- {formatSessionTitle()} - {formatSessionLocation()} -
+ {buildSessionHeader()}
-
- - - -
- - Speakers - - { - speakers.map(speaker => ( - - - - - - - )) - } -
+ { hasDescription ?
: null } + { hasDescription && hasSpeakers ? : null } + + { hasSpeakers ? +
+ + Speakers + + { + speakers.map(speaker => ( + + + + + + + )) + } +
: null + }
); } - }; const mapStateToProps = (state: ApplicationState) => ({