Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show slides link #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/controls/SessionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const SessionSheet: FC<SessionSheetProps> = ({

const hasDescription = useMemo(() => session.description.length > 0, [session.description]);
const hasSpeakers = useMemo(() => session.speakers.length > 0, [session.speakers]);
const hasSlides = useMemo(() => session.slidesUrl && session.slidesUrl.length > 0, [session.slidesUrl])

const buildAdminActions = () => (
<div className="edit-actions">
Expand Down Expand Up @@ -123,7 +124,21 @@ const SessionSheet: FC<SessionSheetProps> = ({
}
}

if (!hasDescription && !hasSpeakers) {
const formatSlidesUrl = () => {
if (!session.slidesUrl) return null;

var text = session.slidesUrl;
const length = 30;
if (text.length > length) {
text = text.substring(0, length - 3) + "..."
}

return (
<a href={session.slidesUrl} target="_blank">Presentation slides</a>
);
}

if (!hasDescription && !hasSpeakers && !hasSlides) {
return (
<Paper square className="session-card">
{isEditMode ? buildAdminActions() : null}
Expand All @@ -139,8 +154,10 @@ const SessionSheet: FC<SessionSheetProps> = ({
</AccordionSummary>
<AccordionDetails>
<div className="session-content">
{ hasSlides ? <div>{formatSlidesUrl()}</div> : null }
{ hasSlides && hasDescription ? <br /> : null }
{ hasDescription ? <div dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(session.description)}} /> : null }
{ hasDescription && hasSpeakers ? <Divider className="divider" /> : null }
{ (hasDescription || hasSlides) && hasSpeakers ? <Divider className="divider" /> : null }

{ hasSpeakers ?
<div className="speakers">
Expand Down
1 change: 1 addition & 0 deletions src/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Session {
name: string;
type: string;
location?: string;
slidesUrl?: string;
speakers: string[];
description: string;
isUnscheduled?: boolean;
Expand Down