From be0139762340c74baaff70ef11245815b15481eb Mon Sep 17 00:00:00 2001 From: mayra lucia navarro Date: Mon, 5 Dec 2022 01:08:14 -0500 Subject: [PATCH] generate reusable components --- .../components/meetups/MeetupCard.jsx | 57 +++++++++++++++++++ .../components/meetups/MonthSection.jsx | 22 +++++++ .../components/meetups/YearSection.jsx | 16 ++++++ .../past_meetups/SpeakerBiosBlock.jsx | 23 ++++++++ .../past_meetups/SpeakerVideoBlock.jsx | 31 ++++++++++ .../components/past_meetups/VideoBlock.jsx | 18 ++++++ 6 files changed, 167 insertions(+) create mode 100644 app/javascript/components/meetups/MeetupCard.jsx create mode 100644 app/javascript/components/meetups/MonthSection.jsx create mode 100644 app/javascript/components/meetups/YearSection.jsx create mode 100644 app/javascript/components/past_meetups/SpeakerBiosBlock.jsx create mode 100644 app/javascript/components/past_meetups/SpeakerVideoBlock.jsx create mode 100644 app/javascript/components/past_meetups/VideoBlock.jsx diff --git a/app/javascript/components/meetups/MeetupCard.jsx b/app/javascript/components/meetups/MeetupCard.jsx new file mode 100644 index 00000000..4876bccd --- /dev/null +++ b/app/javascript/components/meetups/MeetupCard.jsx @@ -0,0 +1,57 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +export default function MeetupCard({ id_event, speakers, title = '', event_speakers }) { + const eventWithSpeaker = event_speakers.map((talk) => { + const speaker = speakers.find((speak) => speak.id === talk.speaker_id); + return { ...talk, speaker }; + }); + return ( +
  • +
    +
    +

    {title}

    + {eventWithSpeaker.length > 0 && + eventWithSpeaker.map(({ id, talk_title, speaker }) => ( +
    +
    + {talk_title} +
    +
    + +
    +

    + {speaker.name} +

    +

    + {speaker.tagline} +

    +
    +
    +
    + ))} +
    +
    + + + +
    +
    +
  • + ); +} + +MeetupCard.propTypes = { + id_event: PropTypes.number, + speakers: PropTypes.array, + title: PropTypes.string, + event_speakers: PropTypes.array, + year: PropTypes.string, + month: PropTypes.string, +}; diff --git a/app/javascript/components/meetups/MonthSection.jsx b/app/javascript/components/meetups/MonthSection.jsx new file mode 100644 index 00000000..b2d8e035 --- /dev/null +++ b/app/javascript/components/meetups/MonthSection.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +export default function MonthSection({ children, month }) { + return ( +
  • +
    +

    + {month} +

    +
    +
    +
      + {children} +
    +
  • + ); +} + +MonthSection.propTypes = { + month: PropTypes.string, + children: PropTypes.node, +}; diff --git a/app/javascript/components/meetups/YearSection.jsx b/app/javascript/components/meetups/YearSection.jsx new file mode 100644 index 00000000..83a7d83a --- /dev/null +++ b/app/javascript/components/meetups/YearSection.jsx @@ -0,0 +1,16 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +export default function YearSection({ children, year }) { + return ( +
    +

    {year}

    + +
    + ); +} + +YearSection.propTypes = { + year: PropTypes.string, + children: PropTypes.node, +}; diff --git a/app/javascript/components/past_meetups/SpeakerBiosBlock.jsx b/app/javascript/components/past_meetups/SpeakerBiosBlock.jsx new file mode 100644 index 00000000..13a47656 --- /dev/null +++ b/app/javascript/components/past_meetups/SpeakerBiosBlock.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Microphone from '../icons/Microphone'; + +export default function SpeakerBiosBlock({ speakers }) { + return ( +
    +
    + +

    About the speakers

    +
    +
    + {speakers?.map(({ id, bio }) => ( +
    {bio}
    + ))} +
    +
    + ); +} + +SpeakerBiosBlock.propTypes = { + speakers: PropTypes.arrayOf(PropTypes.object), +}; diff --git a/app/javascript/components/past_meetups/SpeakerVideoBlock.jsx b/app/javascript/components/past_meetups/SpeakerVideoBlock.jsx new file mode 100644 index 00000000..2a45dddf --- /dev/null +++ b/app/javascript/components/past_meetups/SpeakerVideoBlock.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import VideoBlock from 'components/past_meetups/VideoBlock'; + +export default function SpeakerVideoBlock({ speaker, eventSpeaker }) { + const { id, image_url: imageUrl, name, tagline } = speaker; + const { + talk_title: title, + talk_description: description, + talk_video_link: videoLink, + } = eventSpeaker; + return ( + <> + +
    + +
    +

    {name}

    +

    {tagline}

    +
    +
    +

    {description}

    + + ); +} + +SpeakerVideoBlock.propTypes = { + speaker: PropTypes.object, + eventSpeaker: PropTypes.object, +}; diff --git a/app/javascript/components/past_meetups/VideoBlock.jsx b/app/javascript/components/past_meetups/VideoBlock.jsx new file mode 100644 index 00000000..004e2539 --- /dev/null +++ b/app/javascript/components/past_meetups/VideoBlock.jsx @@ -0,0 +1,18 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +export default function VideoBlock({ videoUrl, title }) { + if (!videoUrl) { + return null; + } + return ( +
    + ; +
    + ); +} + +VideoBlock.propTypes = { + videoUrl: PropTypes.string, + title: PropTypes.string, +};